链接第三方库

ant*_*009 5 cmake

我创建了一个工作正常的简单应用程序.但是,现在我需要链接以下目录中的一些库.

/opt/norton/lib
Run Code Online (Sandbox Code Playgroud)

在我的make文件中,我有以下作品,但我需要使用cmake

LIBS_PATH = -L/opt/norton/lib
INC_PATH = -I/opt/norton/inc

LIBS = -lntctrl
Run Code Online (Sandbox Code Playgroud)

在我的CMakeList.txt我有这个,但不起作用我继续得到以下错误:

undefined reference to `nt_init'
Run Code Online (Sandbox Code Playgroud)

这是我的CMakeList.txt

# Includes files
INCLUDE_DIRECTORIES(/opt/norton/inc)

# Link libraries
LINK_DIRECTORIES(/opt/norton/lib)

# Add the library that is used by nt_init
TARGET_LINK_LIBRARIES(-lntctrl)

ADD_LIBRARY(application initialize_nw) 
Run Code Online (Sandbox Code Playgroud)

非常感谢任何建议,

jde*_*aan 8

试试看TARGET_LINK_LIBRARIES(ntctrl),-l不应该在那里使用旗帜(根据我的想法猜测)

这是我写cmake文件的方式:

include_directories(/opt/norton/inc)
link_directories(/opt/norton/lib)
add_executable(application initialize_nw)
target_link_libraries(application ntctrl)
Run Code Online (Sandbox Code Playgroud)

要显示make期间运行的实际命令行,请使用:

make VERBOSE=1
Run Code Online (Sandbox Code Playgroud)

也许这会向您显示手动运行的内容与cmake生成的命令之间的区别.