Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

(似乎已解决)Windows下 cmake 引用已有动态库 h lib dll

似乎是dll不兼容,cmake文件我是写对的


文件目录结构

gts.lib, gts.dll, gts.h文件都有了

CMakeLists.txt里面要怎么写?如果可以的话麻烦写一份完整的代码
Windows下 cmake 引用已有动态库
三年前有个一样的问题,但是回答似乎用不上

现在的写法是这样的:

根目录CMakeLists.txt

cmake_minimum_required(VERSION 3.17)
project(MotionDaemon)
set(CMAKE_CXX_STANDARD 11)

include_directories(${PROJECT_NAME}/include)
link_directories(${PROJECT_NAME}/library)

add_subdirectory(res)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} utils gts)

子目录res的CMakeLists.txt, 这部分不重要

aux_source_directory(. DIR_LIB_SRCS)
add_library(utils ${DIR_LIB_SRCS})

使用以上设置会报错
D:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgts

查了很多资料都没辙,大部分是罗列一些指令然后开始火箭跳跃。所以只能在这当一次伸手党。LZ非科班新手,没学过编译原理,如果有好的CMake教程麻烦也推荐一下。感激不尽!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...