This is long after the OP, but I just successfully set up Eclipse to compile and run the SFML hello world example on WinXP. I think it would be a great idea to post the tutorial; I'm a professional Java developer so I eat, drink, and breathe Eclipse, meaning that for people like me, Eclipse CDT + SFML is an ideal solution for cross-platform game development. Why? Because I can leverage my existing knowledge of Java to manipulate assets (tools and editors).
Basically, I followed the installation how-to for the Code::Blocks IDE since Eclipse CDT also uses MinGW (by recommendation). The install is perfectly analogous (almost one-to-one), and I had it running in several minutes. I then tried installing Code::Blocks since it looks very interesting. Once finished, I can now edit the same source code simultaneously in both IDEs (the project files do not conflict and the default output dirs also do not conflict). It was so refreshing to have this work so cleanly out of the box that I wanted to share my steps. Note that it's still important to have a good understanding of the concepts of search paths, compiling, and linking.
How-To Run SFML in Eclipse CDT (Windows, but *nix is similar)Install the MinGW compiler and set up operating system PATH (Windows Only):- 1. Install MinGW. Note that the stable version of MinGW runs gcc 3.4.5, and SFML was built with 4.4, so you need a build that comes with gcc 4.4; a link to a compatible MinGW is provided in the Code::Blocks install tutorial.
- 2. Download and install MSYS from the MinGW site. MSYS contains windows command-line utilities (e.g. "make") that supplement MinGW.
- 3. Add the MinGW and MSYS bin dirs to your system PATH. The dirs you need to add are typically "C:\MinGW\bin" and "C:\msys\1.0\bin" (don't forget that windows uses semi-colons as delimiters, e.g.: "...;C:\MinGW\bin;C:\msys\1.0\bin").
Install Eclipse IDE and the CDT plugin (for C++ development):- 4. Download/install the Java runtime (JRE). Eclipse runs using native SWT components under Java.
- 5. Download the Eclipse IDE and unpack into "C:\Program Files" or similar dir (no install ).
- 6. Download the latest Eclipse CDT archive file for C++ development (the authors provide a direct link in the CDT download website; they mention a bug in the repository related to the debugger).
- 7. Run Eclipse, and go to Help > Install New Software... > Add... Then, under the Add Repository dialog, select Archive... and open the "cdt-master" zipped archive. Give it a name like "CDT archive" and add. Under Work With, select the "CDT archive" from the drop-down, and check off "CDT Main Features" and "CDT Optional Features". Hit next and finish installation.
- 8. At this point, Eclipse is ready to build SFML projects as long as your path is setup correctly. Test on the command-line by typing "g++" and "make", both should run but not do anything because there's no targets.
Build and Run the Hello World Program:- 9. In Eclipse, select File > New > C++ Project. Enter a project name such as "SFMLHelloWorld". Under Project type: select "Executable" and "Hello World C++ Project", and under Toolchains: select "MinGW GCC". Press Finish, which creates the project, including Debug and Release configurations.
- 10. Replace the content of "SFMLHelloWorld.cpp" with the example program from the Code::Blocks tutorial. Before we can build it, we need to tell the project where to find the SFML header files (include), and what libraries to link to when building (lib).
- 11. By default, the Debug configuration will be selected as the Active configuration; we will edit the settings for this configuration first. In the Project Explorer, Right-click on "SFMLHelloWorld" and select Properties. In the properties dialog, select C/C++ Build > Settings > Tool Settings. This is where you configure your project for search paths, library linking, and other options. Starting top to bottom, the first thing you probably want to do is to define the SFML_DYNAMIC macro (this is for dynamic library linking, e.g. DLLs, don't do this if you are going to perform static linking). Under GCC C++ Compiler > Preprocessor, click the "plus/add" icon under Defined symbols (-D) and add "SFML_DYNAMIC" (see image).
- 12. Include the SFML header files on the search path. Under GCC C++ Compiler > Includes, click the "plus/add" icon under Include paths (-I) and add "C:\proj\lib\SFML-1.6\include" where "C:\proj\lib\SFML-1.6" is the path of your SFML installation (see image).
- 13. Tell the Linker where to find the SFML libraries. Under MinGW C++ Linker > Libraries, click the "plus/add" icon under Libraries (-l) and add "sfml-system-d". NOTE: this is the debug SFML system library; add this library if you are editing your debug configuration (as shown in the image). You can toggle between debug/release configurations at the top of this dialog under Configuration:. If this configuration is the release configuration, use the release library ("sfml-system"). You can optionally add the other libraries as shown. Note that the linking order matters (as explained in the Code::Blocks tutorial).
- 14. Add the lib dir to the library search path. Under MinGW C++ Linker > Libraries, click the "plus/add" icon under Library search path (-L) and add "C:\proj\lib\SFML-1.6\lib", again, where "C:\proj\lib\SFML-1.6" is the path of your SFML installation (see image).
- 15. Hit Apply to save changes. Perform steps 11 to 14 once more for the Release configuration by first selecting "Release" under Configuration:.
- 16. In the code editor, press ctrl+B to build the program. Run it by going to Project Explorer > SFMLHelloWorld > Binaries, right-click on "SFMLHelloWorld.exe" and select Run As > Local C/C++ Application.
That should be it! Hopefully this is helpful. I think this is enough to post under the tutorials; if Laurent would feel so inclined, please feel free to add-to/repost as another installation tutorial.
Cheers,
Bryan