如何设置CMAKE静态链接(对`dlopen'的未定义引用)? [英] How to set CMAKE static linking ( undefined reference to `dlopen' )?

查看:1451
本文介绍了如何设置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),需要静态链接(添加静态设备),但是当我这样做的时候

 

我得到:

'pre> /arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libsqlite3.a(sqlite3.o):在功能`unixDlOpen':
sqlite3的.c :( .text + 0x3e5d4):对`dlopen'的未定义引用

如何设置静态链接的SQLite没有得到这个错误?或者,也许我的根系统缺少一些东西?

解决方案

静态链接一些存档时,需要指定其依赖关系libdl)自己。请注意,在链接器命令行中指定存档文件的顺序比链接共享对象更重要。


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.

这篇关于如何设置CMAKE静态链接(对`dlopen'的未定义引用)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆