Mac OS上安装SDL库并在vscode中进行调试

需要在Mac OS上编写一个SDL库的图像程序, 并在vscode中进行调试.整个安装配置的过程如下:

1. 按照vscode的官网步骤安装C/C++的编译调试环境, MacOS中使用clang对C/C++进行编译.

C++ programming with Visual Studio Code

2. 安装CMake, 使用CMake进行编译/运行配置

之前从CMake网站上下载过CMake的应用进行安装,发现与vscode设置配不上, 没有调查为什么,改用MacOS的brew进行安装. 

- MacOS的Brew安装, 国内最好使用清华的数据源镜像,速度快,好用. 具体安装步骤参考清华的镜像说明 Brew清华镜像安装说明

-brew安装好以后, 调用 brew install cmake 就可以安装最新的cmake了.

-安装vscode的cmake插件(CMake, CMake Langua support, CMake Tools)

使用COMMAND+SHIFT+P , 输入CMAKE QSTART就可以开始建立一个CMAKE的基础工程了

可以以基础工程CMAKE进行编译等操作,编译等使用CMake:Build, 或者使用vscode的底部的cmake工具条

3. 安装SDL Library

这里碰见一个坑,安装SDL的官方文档说明下载了一个SDL.dmg, 按照需求是需要将SDL Framework拷贝到/libray/frameworks目录下使用. 按照这个步骤做执行的时候MacOS就会报告没有签名不让用.  

解决方法就是不用这个官方安装包进行安装,使用brew进行安装就可以解决了, 也有人说不拷贝到系统的Library下,自己建一个目录,在CMake中再制定可以解决,我没有尝试.

正常的方法就是: brew install sdl

4.配置CMakefileList.txt 

file(GLOB_RECURSE sources  src/*.c src/*.h)
find_package(SDL2 REQUIRED COMPONENTS SDL2)
add_executable(robot ${sources})
target_link_libraries(robot PRIVATE SDL2::SDL2)

我的执行程序叫robot, 需要根据需要自己进行修改.

至此整个配置完毕,可以开始SDL编程了.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SDL是一款开源软件,使用SDL进行商业开发是完全允许的。你可以在你的项目包含SDL的源代码,也可以将SDL作为动态链接使用。然而,在使用SDL时,你需要遵守其开源协议,即zlib协议。该协议要求你在你的代码包含SDL的版权声明和许可证。你需要在你的代码包含以下声明: ``` Copyright (c) <year> Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ``` 此外,你还需要在你的代码包含SDL的许可证,可以在SDL的源代码包找到。如果你将SDL作为动态链接使用,则需要在你的应用程序包含SDL的动态链接许可证。 总之,在使用SDL时,请确保遵守其开源协议并包含版权声明和许可证。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值