如何在 cmake 中使用 SDL2 和 SDL_image
问题描述
我正在寻找使用 SDL2 和 SDL_image 和 cmake 编译 c++ 程序的最简单方法.
I'm looking for the simplest way to compile a c++ program using SDL2 and SDL_image with cmake.
经过数小时的搜索,这是我的最佳尝试:
Here is my best attempt, after hours of searching:
CMakeLists.txt
我收到这些错误:
这是函数调用:
我很绝望.请帮我!谢谢!:)
I am desperate. Please help me! Thanks! :)
推荐答案
我认为以下方法会起作用,因为它会在我的 ubuntu 系统上找到库,并且您提供的示例函数可以链接:
I think that the following will work, as it finds the libraries on my ubuntu system and the example function you provided can link:
如果使用 --debug-output 执行 cmake,它会输出:
If cmake is executed with --debug-output it outputs:
这让我检查了
我注意到 SDL2_image.pc 包含名称:SDL2_image我认为应该将第三个参数与此库的 PKG_SEARCH_MODULE 匹配.
I noticed that SDL2_image.pc contains Name: SDL2_image which I assumed should match the third parameter to PKG_SEARCH_MODULE for this library.
这篇关于如何在 cmake 中使用 SDL2 和 SDL_image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!