简体   繁体   中英

How to set CMAKE static linking ( undefined reference to `dlopen' )?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM