Cmake for shared libraries without using the full path

I have CMakeLists.txt:

set( PROJECT_LINK_LIBS lib1.so lib2.so )
link_directories( path/to/libs ) # lib1.so and lib2.so are there.

add_library( ${PROJECT_NAME} SHARED ${PROJECT_SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${PROJECT_LINK_LIBS} )

Which compilation and links are excellent.

But when I do this:

ldd -d mylib.so

I get:

  • libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf529b000)
  • linux-gate.so.1 => (0xf777a000)
  • /lib/ld-linux.so.2 (0xf777b000)
  • lib1.so => /path/to/libs/lib1.so (0xf56a2000)
  • lib2.so => /path/to/libs/lib2.so (0xf548f000)

My questions:

  • How to remove / path / to / libs / for 4. and 5 .. Something related to LD_LIBRARY_PATH?
  • Auto Answer: . I understand what it means 1. Find libc.so.6 in this way. But what about 2. and 3.? locate linux-gate.so.1gives nothing. Why 3. does not have the symbol =>? (found the answer here )
+4
source share
2 answers

Well found the answer:

set( CMAKE_SKIP_BUILD_RPATH true )

It did.

+2
source

, ldd? : Linux, . ( CMake) , . , LD_LIBRARY_PATH , .

0

All Articles