我有自己的C ++库,而且我正在改变它的构建方式(从基本的Makefile转换到CMake)。
我还有一些使用这个库的C ++示例。
如果我使用Makefile构建库,那么示例运行得很好。
如果我使用CMake生成的Makefile构建,那么库似乎构建得很好,但示例将失败并显示error while loading shared libraries: libfpthread.so: cannot open shared object file: No such file or directory
。
$ cmake . -G 'Unix Makefiles'
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/joaomlneto/Documents/GitHub/fpthreads
$ make
/usr/bin/cmake -H/home/joaomlneto/Documents/GitHub/fpthreads -B/home/joaomlneto/Documents/GitHub/fpthreads --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/joaomlneto/Documents/GitHub/fpthreads/CMakeFiles /home/joaomlneto/Documents/GitHub/fpthreads/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/joaomlneto/Documents/GitHub/fpthreads'
make -f CMakeFiles/fpthread.dir/build.make CMakeFiles/fpthread.dir/depend
make[2]: Entering directory '/home/joaomlneto/Documents/GitHub/fpthreads'
cd /home/joaomlneto/Documents/GitHub/fpthreads && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/joaomlneto/Documents/GitHub/fpthreads /home/joaomlneto/Documents/GitHub/fpthreads /home/joaomlneto/Documents/GitHub/fpthreads /home/joaomlneto/Documents/GitHub/fpthreads /home/joaomlneto/Documents/GitHub/fpthreads/CMakeFiles/fpthread.dir/DependInfo.cmake --color=
Scanning dependencies of target fpthread
make[2]: Leaving directory '/home/joaomlneto/Documents/GitHub/fpthreads'
make -f CMakeFiles/fpthread.dir/build.make CMakeFiles/fpthread.dir/build
make[2]: Entering directory '/home/joaomlneto/Documents/GitHub/fpthreads'
[ 11%] Building CXX object CMakeFiles/fpthread.dir/src/nvrecovery.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/nvrecovery.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/nvrecovery.cpp
[ 22%] Building CXX object CMakeFiles/fpthread.dir/src/xthread.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/xthread.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/xthread.cpp
[ 33%] Building CXX object CMakeFiles/fpthread.dir/src/libdthread.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/libdthread.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/libdthread.cpp
[ 44%] Building CXX object CMakeFiles/fpthread.dir/src/logger.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/logger.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/logger.cpp
[ 55%] Building CXX object CMakeFiles/fpthread.dir/src/real.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/real.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/real.cpp
[ 66%] Building CXX object CMakeFiles/fpthread.dir/src/xmemory.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/xmemory.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/xmemory.cpp
[ 77%] Building CXX object CMakeFiles/fpthread.dir/src/xrun.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/xrun.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/xrun.cpp
[ 88%] Building CXX object CMakeFiles/fpthread.dir/src/prof.cpp.o
/usr/bin/c++ -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -DNDEBUG -DSSE_SUPPORT -Dfpthread_EXPORTS -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util -fPIC -g -O0 -msse2 -pthread -std=gnu++11 -o CMakeFiles/fpthread.dir/src/prof.cpp.o -c /home/joaomlneto/Documents/GitHub/fpthreads/src/prof.cpp
[100%] Linking CXX shared library libfpthread.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/fpthread.dir/link.txt --verbose=1
/usr/bin/c++ -fPIC -shared -Wl,-soname,libfpthread.so -o libfpthread.so CMakeFiles/fpthread.dir/src/nvrecovery.cpp.o CMakeFiles/fpthread.dir/src/xthread.cpp.o CMakeFiles/fpthread.dir/src/libdthread.cpp.o CMakeFiles/fpthread.dir/src/logger.cpp.o CMakeFiles/fpthread.dir/src/real.cpp.o CMakeFiles/fpthread.dir/src/xmemory.cpp.o CMakeFiles/fpthread.dir/src/xrun.cpp.o CMakeFiles/fpthread.dir/src/prof.cpp.o -ldl -pthread
make[2]: Leaving directory '/home/joaomlneto/Documents/GitHub/fpthreads'
[100%] Built target fpthread
make[1]: Leaving directory '/home/joaomlneto/Documents/GitHub/fpthreads'
/usr/bin/cmake -E cmake_progress_start /home/joaomlneto/Documents/GitHub/fpthreads/CMakeFiles 0
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(fpthread)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
file(GLOB src relative ${CMAKE_SOURCE_DIR} "src/*.cpp")
add_library(fpthread SHARED ${src})
target_include_directories(fpthread
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/heaplayers
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/heaplayers/util
)
target_link_libraries(fpthread
Threads::Threads
${CMAKE_DL_LIBS}
)
add_definitions(-g)
add_definitions(-O0)
add_definitions(-DNDEBUG)
#add_definitions(-DDEBUG)
add_definitions(-msse2 -DSSE_SUPPORT)
#add_definitions(-DCHECK_SCHEDULE)
add_definitions(-DDETERM_MEMORY_ALLOC)
add_definitions(-DENABLE_PROFILING)
#add_definitions(-DGET_CHARACTERISTICS)
#add_definitions(-DLAZY_COMMIT)
add_definitions(-DLOCK_OWNERSHIP)
#add_definitions(-DPAGE_DENSITY)
#add_definitions(-DTRACING)
#add_definitions(-D'CUSTOM_PREFIX(x)=grace\#\#x')
set(CMAKE_VERBOSE_MAKEFILE on)
message("source files:")
message(${src})
message("")
$ make -f Makefile.old
g++ -std=gnu++11 -shared -fPIC -g -DNDEBUG -msse2 -DSSE_SUPPORT -DDETERM_MEMORY_ALLOC -DENABLE_PROFILING -DLOCK_OWNERSHIP -D'CUSTOM_PREFIX(x)=grace##x' -m64 -I/home/joaomlneto/Documents/GitHub/fpthreads/include -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers -I/home/joaomlneto/Documents/GitHub/fpthreads/include/heaplayers/util /home/joaomlneto/Documents/GitHub/fpthreads/src/libdthread.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/xthread.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/xrun.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/real.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/prof.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/logger.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/xmemory.cpp /home/joaomlneto/Documents/GitHub/fpthreads/src/nvrecovery.cpp -o libfpthread.so -ldl -pthread
Makefile
CXX = g++ -std=gnu++11
SRCS=$(wildcard $(PWD)/src/*.cpp)
INCLUDE_DIRS = -I$(PWD)/include -I$(PWD)/include/heaplayers -I$(PWD)/include/heaplayers/util
TARGET_X64 = libfpthread.so
TARGET_X86 = libfpthread32.so
TARGETS = $(TARGET_X64) $(TARGET_X86)
CXXFLAGS = -shared -fPIC -g
CXXFLAGS += -DNDEBUG # -DDEBUG/-DNDEBUG: enable/disable debugging
CXXFLAGS += -msse2 -DSSE_SUPPORT # Enable SS2 Support TODO automatic detection!
#CXXFLAGS += -DCHECK_SCHEDULE # Check deterministic schedule
CXXFLAGS += -DDETERM_MEMORY_ALLOC # TODO document
CXXFLAGS += -DENABLE_PROFILING # Enable execution profiling and print statistics at the end
#CXXFLAGS += -DGET_CHARACTERISTICS # Get some characteristics about running
#CXXFLAGS += -DLAZY_COMMIT # TODO document
CXXFLAGS += -DLOCK_OWNERSHIP # TODO document
#CXXFLAGS += -DPAGE_DENSITY # TODO document
#CXXFLAGS += -DTRACING # TODO document
CXXFLAGS += -D'CUSTOM_PREFIX(x)=grace\#\#x' # TODO document
CXXFLAGS32 = $(CXXFLAGS) -m32 -DX86_32BIT
CXXFLAGS64 = $(CXXFLAGS) -m64
LIBS = -ldl -pthread
.PHONY: default all x64 x86 clean
default: x64
all: x64 x86
x64: $(TARGET_X64)
x86: $(TARGET_X86)
$(TARGET_X64): $(SRCS) Makefile
$(CXX) $(CXXFLAGS64) $(INCLUDE_DIRS) $(SRCS) -o $@ $(LIBS)
$(TARGET_X86): $(SRCS) Makefile
$(CXX) $(CXXFLAGS32) $(INCLUDE_DIRS) $(SRCS) -o $@ $(LIBS)
clean:
rm -f $(TARGETS)
尺寸略有不同。
$ file fpthread_*
fpthread_cmake.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=69aaa475c964666aad9fb04f9cb278042ef0c367, not stripped
fpthread_make.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=71178ef39a4e22eb3f8e3cae9210033c18eae3d3, not stripped
$ ls ./fpthread_* -lA
-rwxrwxr-x 1 joaomlneto joaomlneto 1100184 Apr 9 14:39 ./fpthread_cmake.so
-rwxrwxr-x 1 joaomlneto joaomlneto 1100264 Apr 9 14:37 ./fpthread_make.so
$ ldd fpthread_cmake.so
linux-vdso.so.1 => (0x00007ffe64f96000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb3604d0000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb36014e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb35ff38000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb35fd1b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb35f951000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb36092e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb35f648000)
$ ldd fpthread_make.so
linux-vdso.so.1 => (0x00007ffdd017a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcc32b6d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcc32950000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcc325ce000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcc323b8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcc31fee000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcc32fcb000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcc31ce5000)
FPTHREAD_HOME=../../
CC = g++
CFLAGS = -g -O0
PLIB = -lpthread
FPLIB = $(FPTHREAD_HOME)/libfpthread.so
#nvthread
INC_DIR = $(FPTHREAD_HOME)/include
SRC_DIR = $(FPTHREAD_HOME)/src
FPINCLUDE_DIRS = -I$(INC_DIR)
FPSRCS = $(SRC_DIR)/fprecovery.cpp
TARGETS=read-my-writes
.PHONY: all clean
all: $(TARGETS)
read-my-writes:
$(CC) $(CFLAGS) $(FPINCLUDE_DIRS) $(FPSRCS) read-my-writes.c -o $@ -rdynamic $(FPLIB) -ldl
clean:
rm -f *.o $(TARGETS)
reset:
rm -rf /mnt/ramdisk/fpthreads/*
rm -f /tmp/fplib.crash
使用CMake(libfpthread.so
)构建cmake . -G 'Unix Makefiles'; make
后:
$ LD_DEBUG=all ./read-my-writes
64187:
64187: file=libfpthread.so [0]; needed by ./read-my-writes [0]
64187: find library=libfpthread.so [0]; searching
64187: search cache=/etc/ld.so.cache
64187: search path=/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu:/lib/tls/x86_64:/lib/tls:/lib/x86_64:/lib:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/x86_64:/usr/lib (system search path)
64187: trying file=/lib/x86_64-linux-gnu/tls/x86_64/libfpthread.so
64187: trying file=/lib/x86_64-linux-gnu/tls/libfpthread.so
64187: trying file=/lib/x86_64-linux-gnu/x86_64/libfpthread.so
64187: trying file=/lib/x86_64-linux-gnu/libfpthread.so
64187: trying file=/usr/lib/x86_64-linux-gnu/tls/x86_64/libfpthread.so
64187: trying file=/usr/lib/x86_64-linux-gnu/tls/libfpthread.so
64187: trying file=/usr/lib/x86_64-linux-gnu/x86_64/libfpthread.so
64187: trying file=/usr/lib/x86_64-linux-gnu/libfpthread.so
64187: trying file=/lib/tls/x86_64/libfpthread.so
64187: trying file=/lib/tls/libfpthread.so
64187: trying file=/lib/x86_64/libfpthread.so
64187: trying file=/lib/libfpthread.so
64187: trying file=/usr/lib/tls/x86_64/libfpthread.so
64187: trying file=/usr/lib/tls/libfpthread.so
64187: trying file=/usr/lib/x86_64/libfpthread.so
64187: trying file=/usr/lib/libfpthread.so
64187:
./read-my-writes: error while loading shared libraries: libfpthread.so: cannot open shared object file: No such file or directory
使用旧的Makefile(libfpthread.so
)构建make
之后:
$ LD_DEBUG=all ./read-my-writes
63819:
63819: file=../..//libfpthread.so [0]; needed by ./read-my-writes [0]
63819: file=../..//libfpthread.so [0]; generating link map
63819: dynamic: 0x00007f13c55f5b60 base: 0x00007f13c53b2000 size: 0x0000000000259c28
63819: entry: 0x00007f13c53cd2a0 phdr: 0x00007f13c53b2040 phnum: 7
63819:
63819:
63819: file=libstdc++.so.6 [0]; needed by ./read-my-writes [0]
63819: find library=libstdc++.so.6 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
63819:
63819: file=libstdc++.so.6 [0]; generating link map
63819: dynamic: 0x00007f13c53aad50 base: 0x00007f13c5030000 size: 0x0000000000381400
63819: entry: 0x00007f13c50b9d20 phdr: 0x00007f13c5030040 phnum: 8
63819:
63819:
63819: file=libc.so.6 [0]; needed by ./read-my-writes [0]
63819: find library=libc.so.6 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/lib/x86_64-linux-gnu/libc.so.6
63819:
63819: file=libc.so.6 [0]; generating link map
63819: dynamic: 0x00007f13c5029ba0 base: 0x00007f13c4c66000 size: 0x00000000003c99a0
63819: entry: 0x00007f13c4c86950 phdr: 0x00007f13c4c66040 phnum: 10
63819:
63819:
63819: file=libdl.so.2 [0]; needed by ../..//libfpthread.so [0]
63819: find library=libdl.so.2 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/lib/x86_64-linux-gnu/libdl.so.2
63819:
63819: file=libdl.so.2 [0]; generating link map
63819: dynamic: 0x00007f13c4c64d88 base: 0x00007f13c4a62000 size: 0x00000000002030f0
63819: entry: 0x00007f13c4a62da0 phdr: 0x00007f13c4a62040 phnum: 7
63819:
63819:
63819: file=libgcc_s.so.1 [0]; needed by ../..//libfpthread.so [0]
63819: find library=libgcc_s.so.1 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/lib/x86_64-linux-gnu/libgcc_s.so.1
63819:
63819: file=libgcc_s.so.1 [0]; generating link map
63819: dynamic: 0x00007f13c4a612b0 base: 0x00007f13c484c000 size: 0x0000000000215910
63819: entry: 0x00007f13c484ea70 phdr: 0x00007f13c484c040 phnum: 6
63819:
63819:
63819: file=libpthread.so.0 [0]; needed by ../..//libfpthread.so [0]
63819: find library=libpthread.so.0 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/lib/x86_64-linux-gnu/libpthread.so.0
63819:
63819: file=libpthread.so.0 [0]; generating link map
63819: dynamic: 0x00007f13c4846d50 base: 0x00007f13c462f000 size: 0x000000000021c428
63819: entry: 0x00007f13c46350b0 phdr: 0x00007f13c462f040 phnum: 9
63819:
63819:
63819: file=libm.so.6 [0]; needed by /usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0]
63819: find library=libm.so.6 [0]; searching
63819: search cache=/etc/ld.so.cache
63819: trying file=/lib/x86_64-linux-gnu/libm.so.6
63819:
63819: file=libm.so.6 [0]; generating link map
63819: dynamic: 0x00007f13c462dd88 base: 0x00007f13c4326000 size: 0x00000000003080f8
63819: entry: 0x00007f13c432b600 phdr: 0x00007f13c4326040 phnum: 7
63819:
...
请注意:
答案 0 :(得分:2)
我想我理解你的问题,并有一个潜在的解决方案。尝试将此添加到您的CMakeLists.txt:
set_property(TARGET fpthread PROPERTY NO_SONAME ON)
重建libfpthread.so
。
发生这种情况的原因是:
当可执行文件与具有DT_SONAME字段的共享对象链接时,则在运行可执行文件时,动态链接器将尝试加载由DT_SONAME字段指定的共享对象,而不是使用为链接器指定的文件名
摘录自:https://linux.die.net/man/1/x86_64-linux-gnu-ld.bfd,位于-soname
选项文档下。
另请参阅:https://cmake.org/cmake/help/latest/prop_tgt/NO_SONAME.html