Clion,CMake DSO在构建simple2d时丢失

我从一个使用simple2d库(https://github.com/simple2d/simple2d)的项目开始。但是,当我尝试构建小型示例项目时,出现了DSO丢失错误。我认为必须设法将依赖关系链接到simple2d,但显然我还是有事情。

以下是输出:

> ====================[ Build | c_game | Debug ]==================================
/home/fredrik/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/192.5728.100/bin/cmake/linux/bin/cmake --build /home/fredrik/Repos/c_game/cmake-build-debug --target c_game -- -j 2 -m
[ 50%] Linking C executable c_game
/usr/bin/ld: /usr/local/lib/libsimple2d.a(gl.o): undefined reference to symbol 'fmin@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/c_game.dir/build.make:85: recipe for target 'c_game' failed
make[3]: *** [c_game] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/c_game.dir/all' failed
make[2]: *** [CMakeFiles/c_game.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/c_game.dir/rule' failed
make[1]: *** [CMakeFiles/c_game.dir/rule] Error 2
Makefile:118: recipe for target 'c_game' failed
make: *** [c_game] Error 2

这是我的CMakeList.txt,希望有人可以帮助我。

cmake_minimum_required(VERSION 3.14)
project(c_game C)

set(CMAKE_C_STANDARD 11)

find_package(SDL2 REQUIRED)
find_package(GLEW REQUIRED)

include_directories(${SDL2_INCLUDE_DIRS})

add_executable(c_game main.c)

find_library(SIMPLE2D_LIB libsimple2d.a /usr/local/lib)
message(${SIMPLE2D_LIB})
message(${SDL2_INCLUDE_DIRS})
message(${GLEW_INCLUDE_DIRS})
target_include_directories(c_game PUBLIC ${SDL2_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS})
target_link_libraries(c_game ${SIMPLE2D_LIB} ${SDL2_libraRIES} ${GLEW_libraRIES})
hongfuxiao 回答:Clion,CMake DSO在构建simple2d时丢失

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2918208.html

大家都在问