Hey guys,
if Eclipse with its CDT plugin is your favorite IDE, this short tutorial is exactly for you! (it won't take you much time as it is really easy to setup)
EditDownloading and Installing in Windows
Look for "Eclipse IDE for C/C++ Developers" in the download section on the
Eclipse Website. This is the newest Eclipse version with the CDT (C++ Development Tools) plugin already installed.
Also, you need to have the MinGW compiler installed, therefore download it
here. Look for "Package: Automated MinGW Installer, Release: MinGW 5.1.4"
Next, install both to a directory of your choice, preferably in a path without spaces.
EditSetting up Eclipse CDT for SDL in Windows
When you start it the first time, Eclipse will ask you for a workspace folder where it will store all projects and settings. Also, Eclipse should detect your MinGW installation automatically.
Next, you can find the SDL libraries at http://www.libsdl.org/download-1.2.php. Download "SDL-devel-1.X.XX-mingw32.tar.gz" under "Development Libraries", MinGW32. Unpack them in a specific directory.
EditCompiling a NeHe-Lesson in Windows
First, create a new C++ project. Uncheck "Show project types...", choose "Executable->Empty Project" on the left and "MinGW GCC" on the right. Type in a project name and click finish. Download, for example, the new NeHe base code in the Eclipse package from
Lesson 01 (on the bottom), extract it somewhere and copy the "src" folder to your current Eclipse project folder.
Now right click on the project and choose "Properties->C/C++ Build->Settings". Then add the path to your extracted SDL include folder under "Tool settings->GCC C++ compiler->Directories. Also, under "MinGW C++ Linker->Libraries" add the libraries "mingw32", "SDLmain", "SDL", "opengl32", "glu32" (in this order!) and the SDL lib path on the bottom. This was for the Debug configuration - if you want to compile in Release mode, you have to change the current configuration on the top of the window and do all the path and lib stuff again.
You can of course just use our Eclipse project and import it to your workspace (File->Import->General->Existing projects into Workspace). Note that you have to adjust the paths to your SDL include and lib folder though, as described above.
Also copy the SDL.dll into your project's path (where your .exe is located) and make sure to ship it with your .exe if you plan to release your program.
Now you should be able to compile and run the project. If everything works fine, just continue with
Lesson 01. Otherwise, go through this tutorial again and check if you've overlooked something.
EditCompiling a NeHe-Lesson on Linux
Assuming you have the newest Elipse CDT, libSDL and GCC installed then you need to import the project exactly as above, but you need to change the toolchain to GCC insead of MinGW.
So right click on your project in the Navigation panel, Properties->C/C++ Build->Tool Chain Editor, and there you select Linux GCC. Now you go to C/C++ Build->Settings and choose GCC C++ Linker->Libraries. Remove all existing and add the following new ones: GL, GLU, SDL, SDLmain (case sensitive!!).
As the next step you need to go to Run->Run Configurations (in the main menu), select your C++ Application (if its not yet there just double click on C/C++ Local App).
Under C/C++ Application you might see a NeHeEclipse.exe, click on SearchProject next to it and choose the build without ".exe". This should do the trick.
© by AnTeevY - July 7 2008