Optix Linux Precompiled Samples LD_LIBRARY_PATH Autoloader

I recently downloaded the Optix SDK for Linux and tried to test out the precompiled binaries included in the package. Simply running the ./sample_name in the directory didn’t work as the samples need to know where the library paths are, even though they are in the current directory.

I created a simple python way of launching the samples instead of manually typing in the LD_LIBRARY_PATH and sample name. I’ve included it in this post for your convenience if anyone would like to use it.

Simply put it in your sample binary directory and just launch the python script.

Created on Sep 8, 2014

@author: Paul Vecchio
@summary: Automatically loads LD_LIBRARY_PATH for Optix Samples
import os
import stat   

executable = stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH
if __name__ == '__main__':
    optix_samples = []
    for filename in os.listdir('.'):
        if os.path.isfile(filename) and not ".so" in filename:
            st = os.stat(filename)
            mode = st.st_mode
            if mode & executable:
    optix_samples = sorted(optix_samples)        
    print("Optix Samples Found: ")
    for index, sample in enumerate(optix_samples):
        print(str(index) + ") " + sample)
    selected_sample = int(input('Select Optix Sample #:'))
    os.system( 'LD_LIBRARY_PATH=' + os.getcwd() + " ./" + optix_samples[selected_sample] )