Sdl Configuration in Eclipse Ide

Setting up SDL2 with Eclipse and MinGW on Windows

Make sure you're using the right version of the library. You can't mix 64-bit import libraries with 32-bit compiler. For the SDL2 library you downloaded(SDL2-devel-2.0.0-mingw.tar.gz) it comes with both 32-bit and 64-bit. i686-w64-mingw32 is 32-bit and x86_64-w64-mingw32 is for 64-bit.

GCC C++ Linker section on FC13

You have to tell the compiler that your program uses additional libraries.

Use the -l argument

g++ -O2 -g -Wall -fmessage-length=0  -lglut -lGL -lGLU -lX11  -c -o tw.o tw.cpp

This should help against unsatisfied link errors.

You can set these in the properties of your Project.
Properties->c/c++ Build->Settings->Tool Settings->Linker

proplem with sdl setup windows

I actually just set up SDL2 on Code::Blocks myself a day or two ago. Since I suspect your environment might not be configured correctly, here's how I did it, roughly following the tutorial here:

  1. Download both a runtime binary and a development library from the SDL2 download page. Make sure the runtime binary is appropriate for your apps - in other words, if you're building 32-bit executables, get the 32-bit SDL, and if you're building 64-bit binaries, get the 64-bit SDL.
  2. Unpack the development library into a folder of your choice, and do the same with the runtime binary. Remember what paths you used for these. I used "D:\Programming\C++\SDL\SDL2.dll" for my SDL runtime binary and "D:\Programming\C++\SDL\SDL2-2.0.3" for my development library.
  3. Open your project in Code::Blocks.
  4. Go to the Settings menu and click "Compiler..."
  5. Switch to the "Search Directories" tab, then the "Compiler" subtab.
  6. Click "Add" and browse to the folder for your development library. You'll need to pick whether you're developing for 32-bit apps or 64-bit apps here: if you're going for 32-bit, you'll want to add "\i686-w64-mingw32\include" ("D:\Programming\C++\SDL\SDL2-2.0.3\i686-w64-mingw32\include") and for 64-bit apps you'll want to add "\x86_64-w64-mingw32\include" ("D:\Programming\C++\SDL\SDL2-2.0.3\x86_64-w64-mingw32\include").
  7. Go to the "Linker" tab right next to the "Compiler" tab.
  8. Click "Add" and browse to your the folder for your development library. Once again, based on whether you're going for a 32-bit app or a 64-bit app, add "\i686-w64-mingw32\lib" ("D:\Programming\C++\SDL\SDL2-2.0.3\i686-w64-mingw32\lib") or "\x86_64-w64-mingw32\lib" ("D:\Programming\C++\SDL\SDL2-2.0.3\x86_64-w64-mingw32\lib") respectively.
  9. Take the SDL runtime binary ("D:\Programming\C++\SDL\SDL2.dll") and copy & paste it into the folder your compiled EXE will end up in. Since you're using Code::Blocks, this will usually be %PROJECT_FOLDER%\Bin\%RELEASEMODE%, where %PROJECT_FOLDER% is the path to your project and %RELEASEMODE% is Debug or Release.
  10. Build your project and verify that it works.

You can also set this up on a per-project basis rather than a global basis if you want. Just go into the Project menu and click "Build options..." instead of the Settings menu in step 4.

If SDL still doesn't work after this, I'd suggest getting an updated MinGW and making sure Code::Blocks is properly set up to use it.

Include 3rd party library in Eclipse CDT with Visual Studio Toolchain

On Windows, dynamic libraries have two parts: the .dll that contains the executable code and is needed at runtime and a .lib which is the import library that tells the linker to find the externals in the .dll. So, under "Libraries" you need to specify the import library (.lib). And put the .dll somewhere the executable can find it at runtime, e.g. in the same folder.



Related Topics



Leave a reply



Submit