Configuring a C++ project in Eclipse for example SFML application

All kind time of day! When you configure the project in Eclipse I ran into a few problems. After attempts to find a solution to these problems, I found the obvious tips on foreign forums that did not solve the problem. Scratching his head, I began to solve the problems himself. In this article I will describe in detail the configuration of the Eclipse CDT, MinGW, connection s headers and libraries. The article is designed for beginners.

the

Definitions


Eclipse CDT integrated development environment C and C++ based on Eclipse platform.

MinGW — compiler, native software port of the GNU Compiler Collection (GCC) under Microsoft Windows, along with a set of freely distributable import libraries and header files for the Windows API. MinGW allows developers to create native Microsoft Windows applications.

SFML is a free cross-platform multimedia library written in C++.

the

Installing Eclipse and MinGW


For work Eclipse requires a Java.

Download Eclipse CDT from official website and unpack in any convenient place, for example C:\eclipse. Run eclipse.exe if it worked, perfectly.

Then download MinGW installer. Run it. See the description pane, click on Install. If you need to change the installation location and press Continue.

Note to install the mingw-32-base and mingw-gcc-g++.



After that, click Installation - > Apply Changes. On the window press Apply and wait until is downloaded and installed components. Once the installation is complete, download msys. I think during the installation difficulty will arise. Now you need to add in system variable Path the path to the folder bin MinGW, and to the folder bin msys.

I got this: d:\MinGW\bin\;d:\msys\1.0\bin\

Download SFML MinGW, and unpack anywhere you like.
This training is over.

the

Creating and configuring a C++project


Launch Eclipse, click File -> New -> C++ Project. Create a project Hello World and select MinGW as the picture.



Next, RMB on the created project - > Properties, open C/C++ Build -> Settings -> Tool settings - > GCC C++ Compiler - > Includes.
1. Press Add.
2. Select the includes folder of the directory where we unpacked SFML.



After this, proceed to paragraph Preprocessor Defined Symbols and add SFML_DYNAMIC.

Here we come to the point where I got the first error. If we connect the library with the extension .using a MinGW C++ Linker - > Libraries, nothing would work. These libraries need to connect via MinGW C++ Linker - > Miscellaneous as Other Object. Specify the path to the SFML libraries that you need to connect the libsfml-graphics.a, libsfml-window.a, libsfml-main.a



the

building the project


Replaced all code in the automatically generated .cpp this:

the
#include "SFML/Graphics.hpp"

int main() 
{
sf::RenderWindow window(sf::VideoMode(640, 480), "Test");

while(window.isOpen()){

sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed){
window.close();
}

window.clear();
window.display();
}
}

return 0;
}


Click Build

Everything is going successfully but will not work, as there is no dll. Copy everything from the bin folder of the SFML directory in the Debug folder of our project.
Now click the RMB on .exe file located in the Debug folder of our project choose Run As - > Run Configurations, click the C/C++ Application and click the New launch configuration, then press Run without changing anything.



Then run the project using Ctrl + F11 or the appropriate icon in the toolbar.

See a window with a black background.

PS Wrote an article a long time ago and forgot about it =) something may be out of date.
Article based on information from habrahabr.ru

Популярные сообщения из этого блога

Approval of WSUS updates: import, export, copy

The Hilbert curve vs. Z-order