libsqlite3.dylib与CMake链接

时间:2017-05-04 23:14:59

标签: c++ sqlite cmake

我正在尝试使用CMake将libsqlite3.dylib与C ++链接,但我不断收到以下错误:

Undefined symbols for architecture x86_64:
  "_sqlite3_close", referenced from:
      OpnavCamera::~OpnavCamera() in opnav_camera.cpp.o
      OpnavCamera::updateState() in opnav_camera.cpp.o
  "_sqlite3_exec", referenced from:
      select_stmt(char const*) in opnav_camera.cpp.o
  "_sqlite3_open", referenced from:
      OpnavCamera::updateState() in opnav_camera.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../modules/opnav_camera/_opnav_camera.so] Error 1
make[1]: *** [SimCode/CMakeFiles/_opnav_camera.dir/all] Error 2
make: *** [all] Error 2

环顾四周,看起来我没有成功连接图书馆。我是CMake的新手,所以我不知道我在做什么。

我已将以下内容添加到我的CMakelists.txt:

#SQLite 3

# Look for the header file.
FIND_PATH(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)

# Look for the library.
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3.0)

# Handle the QUIETLY and REQUIRED arguments and set SQLITE3_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)

# Copy the results to the output variables.
IF(SQLITE3_FOUND)
  SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
  SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
  message( " Found ")
ELSE(SQLITE3_FOUND)
  SET(SQLITE3_LIBRARIES)
  SET(SQLITE3_INCLUDE_DIRS)
ENDIF(SQLITE3_FOUND)

set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")

MARK_AS_ADVANCED(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)

CMake正在寻找图书馆,但我想我只是错过了如何实际链接它的一步。 enter image description here

我错过了什么?

0 个答案:

没有答案