
问 题
I need to set static linking for my project.
Current state is :
target_link_libraries(armd
${SQLITE3_LIBRARY}
${CMAKE_THREAD_LIBS_INIT}
rt)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O0 -Wall -fmessage-length=0")

doesn't work on device, I need to link statically (add -static for device) but when I do
set(CMAKE_CXX_FLAGS "-O0 -Wall -fmessage-length=0 -static")
I'm getting:
/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libsqlite3.a(sqlite3.o): In function `unixDlOpen': sqlite3.c:(.text+0x3e5d4): undefined reference to `dlopen'

How do I set static linking for sqlite without getting this error? Or maybe my root system is missing something?
解决方案
When statically linking some archives, you need to specify its dependencies (in this case libdl) yourself. Be aware of that the order in which you specify the archive files on the linker command line is more important than for linking shared objects.
本文地址:IT屋 如何修改CMAKE静态链接(对`dlopen'的未定义引用)?

问 题
当前状态是:
target_link_libraries(ARMD
$ {SQLITE3_LIBRARY}
$ {CMAKE_THREAD_LIBS_INIT}
RT)
如果(CMAKE_COMPILER_IS_GNUCXX)
组(CMAKE_CXX_FLAGS -O0 -Wall -fmessage-length = 0)
在设备上不起作用,I (CMAKE_CXX_FLAGS-O0 -Wall -fmessage-a)cmake 未定义的引用,需要静态链接(添加静态设备),但是当我这样做的之后

)
我得到:
'pre> /arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libsqlite3.a(sqlite3.o):在功能`unixDlOpen':
sqlite3的.c :( .text + 0x3e5d4):对`dlopen'的未定义引用
如何修改静态链接的SQLite没有得到这个错误?或者,也许我的根系统缺乏一些东西?
解决方案
静态链接一些存档时,需要选定其依赖关系libdl)自己。请注意cmake 未定义的引用,在链接器命令行中选定存档文件的排序比链接共享对象更重要。
本文地址:IT屋 如何修改CMAKE静态链接(对`dlopen'的未定义引用)?
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/ruanjian/article-143553-1.html
那你们下场一定会很悲惨
差了一代