KEEP K.I.S.S.

tk's blog

Mingw + CMake + SDL2开发环境搭建

tk posted @ Sep 09, 2015 09:14:42 AM in C with tags cmake sdl , 5237 阅读

1. 安装 Mingw

如果已经安装有Mingw则可跳过此节。

这里推荐 TDM-GCC 的版本,在 Download 页面选择下载在线安装包 tdm-gcc-webdl.exe

运行在线安装包,默认选项一路Next。

安装完成后建议新打开一个命令行窗口,输入gcc --version 来检查Mingw是否已经在PATH路径中。

2. 安装 CMake

去CMake下载页面,选择 Latest Release 中的 Windows (Win32 Installer) 右侧的exe文件下载,安装时在 Install Options 界面,选择第2项 Add CMake to the system PATH for all user 或者第3项。

3. 安装 SDL2 开发库

本节参考 Setting up SDL 2 on MinGW

去SDL下载页面,选择下方的 Development Libraries 的 SDL2-devel-2.x.x-mingw.tar.gz (MinGW 32/64-bit)(当前版本是 2.0.3),下载完成后解压。

复制解压出的文件夹中的i686-w64-mingw32文件夹到某个位置,这里以D:\根目录为例,然后重命名 i686-w64-mingw32 为 mingw_dev_lib。以后类似其他的开发库也可以放在这里,便于集中管理。

SDL2.0.3的版本中有一个头文件依赖的bug,点此下载SDL_platform.h 覆盖掉目录include\SDL2中的同名文件[*]

4. SDL2 例子测试

下载压缩包 helloworld.zip 并解压,解压后文件夹应该有3个文件,分别是 CMakeLists.txtles1_hello.bmp 和 main.cpp,这里如果SDL2库安装的位置不是D:\mingw_dev_lib,则需要修改 CMakeLists.txt 中对应的路径为指定位置。

在解压后的文件夹中打开命令行窗口(Win7下Shift+鼠标右键,选择在此处打开命令窗口),
依次输入命令

mkdir build && cd build
cmake -G "MinGW Makefiles" ..
mingw32-make

如果没有任何报错,那么在文件夹中的 build 文件夹下会出现一个 main.exe,双击它然后你应该可以看到一个 Hello world 的界面。

至此,SDL2 的开发环境搭建完成。

Johny 说:
Dec 22, 2022 04:08:18 PM

I read that Post and got it fine and informative. Reverse Image Search

servo Panasonic 说:
Jan 09, 2023 05:49:50 AM

Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. servo Panasonic

buy testosterone cyp 说:
Mar 10, 2023 09:29:41 AM

I would recommend my profile is important to me, I invite you to discuss this topic... buy testosterone cypionate online

sirajuddin 说:
Mar 22, 2023 03:09:33 PM

It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. Content marketing strategy

sirajuddin 说:
Mar 22, 2023 05:29:40 PM

It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. Content marketing strategy

animix play 说:
Mar 30, 2023 02:40:04 AM

Anime is a popular form of entertainment, and in recent years, streaming anime has become increasingly popular. One such streaming service that has gained a lot of popularity is Animixplay. Animix Play is an anime streaming service that offers viewers access to a vast library of anime shows and movies. The service provides a user-friendly interface that makes it easy to find and watch your favourite anime shows and movies. Download animixplay apk mod apk form moddedstore, a securefd and trusted mod apk store.

Lost Girls Zoie Palm 说:
Apr 26, 2023 03:00:50 AM

This post is very simple to read and appreciate without leaving any details out. Great work! Lost Girls Zoie Palmer Leather Jacket

SEO 说:
May 04, 2023 07:59:54 PM

Your texts on this subject are correct, see how I wrote this site is really very good. <a href="https://oncaevol77.com">에볼루션</a>

SEO 说:
May 04, 2023 08:00:21 PM

Your texts on this subject are correct, see how I wrote this site is really very good. 에볼루션

SEO 说:
May 07, 2023 03:31:16 AM

Your texts on this subject are correct, see how I wrote this site is really very good. 메이저놀이터

SEO 说:
May 10, 2023 10:17:05 PM

I personally use them exclusively high-quality elements : you will notice these folks during: 아산출장마사지

SEO 说:
May 22, 2023 10:29:06 PM

I personally use them exclusively high-quality elements : you will notice these folks during: 링크주소

SEO 说:
May 31, 2023 08:01:10 PM

On this subject internet page, you'll see my best information, be sure to look over this level of detail. 수원출장마사지

SEO 说:
Jun 01, 2023 09:47:32 PM

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene. gmail.com

SEO 说:
Jun 04, 2023 02:44:16 PM

It is very good, but look at the information at this address. Çanakkale Escort

SEO 说:
Jun 15, 2023 08:11:43 PM I admit, I have not been on this web page in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues. 메리트카지노
SEO 说:
Jun 19, 2023 06:45:00 PM I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 우리카지노
SEO 说:
Jun 24, 2023 03:21:39 AM

Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Move in cleaning services in uk

Denver web and SEO 说:
Aug 01, 2023 12:09:49 AM

I was looking for SEO services and came across this site. Another great site I recommend is Bus Web Design for SEO experts. <a href= "https://buswebdesign.com/">Denver web and SEO</a>

Windshield Replaceme 说:
Aug 01, 2023 12:10:25 AM

In regard to this article, we also have the perfect resource for Autoglass services.

Sell My Car Denver 说:
Aug 01, 2023 12:10:52 AM

Thank you for sharing this great post! I came across this site while searching for how to sell my car for cash.

AutoCAD Specialist S 说:
Aug 01, 2023 12:11:20 AM

I was looking for staffing agencies that provide recruitment services. I came across this article and thought I should mention an employment solution provider that’s providing everything an employer is looking for. I can trust them to screen and provide me with the best candidates in the market. They always hit the mark with all their candidate submissions.

SEO Expert 说:
Nov 09, 2023 04:53:54 PM

Very useful post. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. Really its great article. Keep it up. plagiarism checker unlimited words

dark web sites 说:
Dec 04, 2023 06:15:22 AM

Navigating the digital tapestry of dark web communities with DarkWeb.Link feels like a virtual archaeological dig, uncovering the layers of online societies that have shaped the hidden web.

tech 说:
Dec 06, 2023 09:58:10 PM

With so many books and articles coming up to give gateway to make-money-online field and confusing reader even more on the actual way of earning money, เซียนแทงบอลUFABET

SEO 说:
Feb 14, 2024 08:23:27 PM

It is my first visit to your blog, and I am very impressed with the articles that you serve. Give adequate knowledge for me. Thank you for sharing useful material. I will be back for the more great post. download apk nekopoi

SEO 说:
Feb 18, 2024 04:39:04 PM

Really a great addition. I have read this marvelous post. Thanks for sharing information about it. I really like that. Thanks so lot for your convene. HappyMod APK

SEO 说:
Feb 21, 2024 06:17:09 PM

Thanks a lot for sharing this excellent info! I am looking forward to seeing more posts by you as soon as possible! I have judged that you do not compromise on quality. Free MP3 Downloads

SEO 说:
Mar 18, 2024 05:17:24 PM

An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers. Dolar Berapa Rupiah

SEO 说:
Mar 21, 2024 08:02:12 PM

I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! Dolar Berapa Rupiah

SEO 说:
Mar 26, 2024 07:51:15 PM

i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future.. Dolar

SEO agency in dubai 说:
Aug 25, 2024 09:12:41 PM

Wow, excellent post. I'd like to draft like this too - taking time and real hard work to make a great article. This post has encouraged me to write some posts that I am going to write soon.

8KBET 说:
Aug 31, 2024 08:02:00 AM

8KBET ca cuoc truc tuyen, cung cap dich vu dinh cao va kho tro choi da dang nhu the thao, da ga, game bai va casino ty le doi thuong hap dan. Tham gia de trai nghiem ca cuoc va giai tri thu vi. Website: https://8kbet-vn.com/

Sunwin 说:
Sep 01, 2024 11:39:40 PM

Sunwin là cổng game bài đổi thưởng uy tín số 1 châu Á trong nhiều năm qua. Các trò chơi hiện đại, đẳng cấp được thiết kế công phu và đã trải qua nhiều lần nâng cấp. Đa số người dân Việt Nam đều gắn bó với cổng game lớn này vì nhiều lý do, trong đó điều quan trọng nhất đó là các trò chơi dễ, và nạp rút tiền rất là nhanh.
https://sunwin90.vip/

Sun.win 说:
Sep 05, 2024 09:20:00 AM

Sun.win là địa chỉ chính thức của nhà cái Sun Win hiện nay. Nếu bạn chưa có tài khoản đăng ký ngay để tận hưởng và trải nghiệm giải trí đỉnh cao với hàng loạt game bài đa dạng và hấp dẫn. https://sunwin-games.com/

K8cc 说:
Sep 06, 2024 11:10:26 AM

K8cc la nha cai ca cuoc online hien dai bac nhat tai Viet Nam nam 2024. Ra doi vao 18/08/2017 tai Viet Nam, K8 cc da nhanh chong nhan duoc nhieu su tin cay va ung ho tu cong dong cuoc thu Viet Nam. https://fa.net.vn/

123B 说:
Sep 13, 2024 11:05:46 AM

Kham pha online dang cap tai 123B voi tro choi hap dan va giao dien dep mat. Dich vu chuyen nghiep va khong gian giai tri hien dai tai 123B cam ket mang den trai nghiem tuyet voi cho nguoi choi yeu thich casino truc tuyen
wedsite: https://123b-bet.com/

thabet 说:
Oct 17, 2024 04:46:45 PM

Thabet la mot trong nhung nha cai uy tin dung hang dau the gioi ca cuoc truc tuyen ma con bieu tuong cua su dang cap va chat luong. Ben canh do thuong hieu THABET con duoc moi nguoi danh gia cao ve cac tro choi cung voi cac dich vu giao dich nhanh chong. https://thabet-vn.com/


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter