提问人:DmqCsm 提问时间:10/19/2016 更新时间:10/19/2016 访问量:4235
将 dll/lib 链接到 cmake 项目
Linking dll/lib to a cmake project
问:
我试图将库链接到我的 cmake 项目,但我遇到了链接器错误。我花了 2 个小时试图解决这个问题,我创建了一个简单的项目,我在其中对所有路径进行了硬编码。
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(Testing CXX)
INCLUDE_DIRECTORIES("B:/Projects/TMH/Libraries/Awesomium/inc")
SET(SOURCE_FILES
src/Main.cpp
src/Application.cpp
src/Window.cpp
)
ADD_EXECUTABLE(Testing ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(Testing B:/Projects/TMH/Libraries/Awesomium/bin/awesomium.dll)
但即使该代码也无法编译并引发链接器错误,如下所示:
CMakeFiles\Testing.dir/objects.a(Application.cpp.obj): In function `ZN9PXLClient11ApplicationD2Ev':
B:/Projects/TMH/Testing/src/Application.cpp:15: undefined reference to `_imp___ZN9Awesomium7WebCore8ShutdownEv'
CMakeFiles\Testing.dir/objects.a(Application.cpp.obj): In function `ZN9PXLClient11Application3RunEv':
B:/Projects/TMH/Testing/src/Application.cpp:20: undefined reference to `_imp___ZN9Awesomium9WebConfigC1Ev'
我要么尝试链接.lib文件,要么链接.dll文件。我改变了
TARGET_LINK_LIBRARIES(Testing B:/Projects/TMH/Libraries/Awesomium/bin/awesomium.dll)
自
TARGET_LINK_LIBRARIES(Testing B:/Projects/TMH/Libraries/Awesomium/lib/Awesomium.lib)
但是我得到了完全相同的错误。我 100% 确定两条路径都是正确的。
如何正确地将 dll/lib 链接到 cmake 项目?
答: 暂无答案
评论