[Resolved] Linking .so file (linux)

I’m using Optix SDK 3.9.1 on CUDA 7.5, Ubuntu 14.04 64bit, GTX 1050 Ti.

I want to solve a part of my project on CPU and use the result data in ray tracing. Firstly, I made a simple summation code and compiled it just for checking that linking is possible or not. I have got libsum.so file now and I want to link this shared object with tutorial.cpp. How can I link and run libsum.so with tutorial.cpp?

There is a connection between tutorial and sutil but I could not add my .so path inside build.make like libsutil.so does (SDKbuild/tutorial/CMakeFiles/tutorial.dir/build.make). In the depend.make file, it has also header files path of sutil. Unfortunately, I could not find a way to link. I hope someone can help me.

Kaan

If you want to link another library to an existing sample, you’ll need to modify the CMakeLists.txt file in the sample, not anything in the build directory. The CMake directives you need are probably “include_directories” and “target_link_libraries”. The CMakeLists.txt file in sutil does this to link in the Glut library, for example; check the online CMake documentation for details.

If you’re more comfortable with Makefiles vs. CMake, you could also build your own application that way. Same for Visual Studio on Windows. You don’t have to necessarily follow the CMake framework from the samples.

Thank you very much for your answer.I put the sum folder in SDK and I added to CMakeLists.txt the link_directories and target_link_libraries as

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/sum)
target_link_libraries( ${target_name}
    sutil
    optix
    sum
    ${optix_rpath}
    )

Then, I included the header files inside tutorial.cpp. I can use the functions inside the sum now.