Get SDL or SDL2 working correctly with Dev-C++

为君一笑 提交于 2020-01-05 04:32:07

问题


I'm really new to programming in C++ and I've seen some tutorials of this programming language.

I'm using Dev-C++ 5.11.

So I wanted to make a game seeing a tutorial on YouTube, and a step was to set up SDL2 correctly. So I started searching on Google and tried a few things that some pages explained. But it kept showing up errors. Here's the last tutorial I tried with:

The compiler log (It's a bit messy):

C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2main.a when searching for -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    cannot find -lSDL2main
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib\libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.dll.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    skipping incompatible C:/dev_lib/SDL2-2.0.4/i686-w64-mingw32/lib/libSDL2.a when searching for -lSDL2
C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\bin\ld.exe    cannot find -lSDL2
C:\Users\dubcusb\Desktop\dubcusb\CEPLUSPLUS\Empty Projy\collect2.exe    [Error] ld returned 1 exit status
25      C:\Users\dubcusb\Desktop\dubcusb\CEPLUSPLUS\Empty Projy\Makefile.win    recipe for target '"Empty' failed

So... What else can I do? Have I done something wrong? Do I have to do an extra step?

(This is the first question I ask here, so tell me if I'm doing something wrong) (I'm not native English speaker too, so if I've misspelled something, that's why)


回答1:


Bloodshed's dev-cpp is not maintained anymore. You can avoid many issues by using a different IDE.

Some free IDEs:

  • Code::Blocks
  • Visual Studio
  • Eclipse

And for tutorials on SDL, you have lazyfoo.net.




回答2:


I've seen there are some multiple questions related to how to configure Dev-C++ in order to work with SDL2 libraries.

First of all I recommend you to execute the IDE as an Administrator mode.

Once IDE started, set the SDL directories as follows:

Tools -> Compiler Options

Binaries directories

Libraries directories

Include directories

Bear in mind your compiler version, in my case I work with x86 directories instead of i686.

On the other hand, I add the includes in the code as:

#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"

At last but not least, you have to configure your project options:

Project -> Project Options

Add linker parameters:

And that's all.

I hope it helps you and other mates that have problems with SDL2 setup in Dev-C++ IDE.



来源:https://stackoverflow.com/questions/39311982/get-sdl-or-sdl2-working-correctly-with-dev-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!