Hello everyone,

I'm working on a library, and I would like the users be able to create their 
own program and liking to my library (by specifying path in cmake).

I created the library and an example to test it.
Everything compiles. 

However, when I try to run my example I have this error:
MyExample:
        libMyLib.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current 
version 56.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current 
version 169.3.0)

The problem is my example is not in the same directory as my library (not even 
in a subdirectory).
And it seems it's linking to my library with a relative path.

If I add the path of my library in DYLD_LIBRARY_PATH it works, but I would like 
the users to be able to compile and link straight forward.

To link the library to my example I use find_package(MyLib REQUIRED) and 
include(${MyLib_USE_FILE}) which basically do a LINK_DIRECTORIES with the 
absolute path of the library.

Then I do add_executable and target_link_libraries(MyExample ${MyLib_LIBRARIES})

Compilation is working fine. There is these options:

-L/Absolute/Path/To/MyLib -lMyLib

But at runtime, library cannot be found.

Would it be possible to put the full path of my library when linking in the 
CMakeLists ?

Thank you.
-Laurent



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to