[SDL]SDL的扩展库

[SDL][CodeBlocks]配置Code::Blocks开发SDL程序

Ervin posted @ 2010年8月17日 23:23 in SDL , 14618 阅读

    首先,在SDL的官网(www.libsdl.org/)下载SDL库的Mingw版本。

    解压之后,得到一堆文件,但有用的主要是:/bin下的dll文件,/lib下的所有文件,/include下的SDL文件夹。/bin下的dll文件用于动态链接,将其复制到C:\windows\system32下;/include下的SDL文件夹复制到Code::Blocks自带的Mingw下的include文件夹下;/lib下的所有文件复制到Mingw下的lib文件夹中。

    /lib下的三个文件分别是:libSDL.dll.a,用于动态链接;libSDLmain.a,用于静态链接;libSDL.la,用于静态链接。虽然已经将这三个文件复制到Mingw的目录下,但默认情况下并不会链接这几个库。所以稍后我们需要手工添加这几个库。

    在Code::Blocks中建立一个控制台项目。此时可以包含SDL库的头文件并进行编译,但是会遇到编译问题:提示SDL_main的原型不匹配。造成这个问题的原因是SDL_main.h中有如下一句:

#define main	SDL_main

虽然我们不知道这一句的动机是什么,但毫无疑问注释掉是个好主意。然后就可以顺利通过编译,但还是无法通过链接,原因如上。解决方法:Project->Build Options->Linker settings,点击Add添加库,如果是静态链接添加libSDLmain.a,动态链接添加libSDL.dll.a。注意此时进行的是Debug版的配置,Release版还需单独配置。

    经过上述步骤,就可以使用Code::Blocks开发SDL程序了。

Avatar_small
NCERT Evs Sample Pap 说:
2022年9月28日 18:52

Environmental education or Environmental studies makes people understand the importance of renewable energy. Non-renewable sources of energy like petrol, diesel etc are the major sources of the world’s pollution. NCERT Evs Sample Paper Class 9 In Environment education using renewable sources, like solar energy, wind energy etc, is encouraged as it is imperative in the fight against global warming. Environmental education or Environmental studies makes people understand the importance of renewable energy. Non-renewable sources of energy like petrol, diesel etc are the major sources of the world’s pollution.


登录 *


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