I can add more details, but when I find the right solution to your problems. So please describe what happened, post the error messages, instead of solutions that happen to work by chance.
Hi Laurent,
Here is the step-by-step procedure that I have to use to get the sample C++ code from the SFML 2.0 tutorial working in VC++ 2010 Express. Note that up to step-6, the procedures are what are shown in the SFML 2.0 Tutorial.
Step-7 corrects the errors in step-6. Step-9 corrects the error in step-8. These steps were not apparent to me as a SFML beginner, by reading the 2.0 tutorial.
1. Open VC++ 2010 Express
2. Click "New Project":
.... a. Select "Visual C++" in left pane.
.... b. Select "Empty Project" in right pane.
.... c. In Name text box, enter name of project.
.... d. In Location text box, enter path where project will be stored.
.... e. Click OK.
3. In VC++:
.... a. Click "Project > Add New Item".
.... b. Select "Code" in left pane. (do not select "Visual C++" or CLR warning will appear)
.... c. Select "C++ File (.cpp)" in right pane.
.... d. Enter name of the .cpp file as "main".
.... e. Click ADD.
.... f. A blank main.cpp file opens in right pane.
4. Paste the sample SFML code from "file:///D:/SFML%20-2.0%20Install%20Tutorial/Install%20SFML%20for%20VC++.htm"
5. Click "Project > ProjectName Properties.
.... a. Click + to expand "Configuration Properties".
.... b. Select "C/C++ > General" in left pane.
........ 1. *** Select "All Configurations" in the Configuration text box. ***
........ 2. Click "Additional Include Directories" in right pane, click down arrow > Edit.
........ 3. Type or navigate to "D:\SFML -2.0\include" (where ever "include" is on your computer).
........ 4. Click APPLY.
.... c. Select "Linker > General" in left pane.
........ 1. *** Select "All Configurations" in the Configuration text box. ***
........ 2. Click "Additional Library Directories" in right pane, click down arrow > Edit.
........ 3. Type or navigate to "D:\SFML -2.0\lib" (where ever "lib" is on your computer).
........ 4. Click APPLY.
.... d. Select "Linker > Input" in left pane.
........ 1. *** Select "Release" in the Configuration text box. ***
........ 2. Click "Additional Dependencies" in right pane, click down arrow > Edit.
........ 3. Type the links to the SFML libraries you will need. The five libraries are:
............ a. sfml-graphics.lib, sfml-window.lib, sfml-system.lib, sfml-audio.lib, sfml-network.lib
............ b. For windows application, also link to: sfml-main.lib
6. Run VC++ debug:
.... a. Got the following errors:
1>------ Build started: Project: Test 02, Configuration: Debug Win32 ------
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??
1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Text::~Text(void)" (__imp_??1Text@sf@@UAE@XZ) referenced in
function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ)
referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates
const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?
Default@RenderStates@sf@@2V12@B)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?
clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)"
(__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ)
referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?
pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?
isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in
function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Text::Text(class sf::String const &,class sf::Font const &,unsigned int)"
(__imp_??0Text@sf@@QAE@ABVString@1@ABVFont@1@I@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class sf::Font const & __cdecl sf::Font::getDefaultFont(void)" (__imp_?
getDefaultFont@Font@sf@@SAABV12@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??
0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??
0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IABUContextSettings@1@@Z) referenced in function
_main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??
0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>D:\C++ Projects\Test 02\Debug\Test 02.exe : fatal error LNK1120: 16 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
7. To get rid of these errors:
.... a. Select "Linker > Input" in left pane.
........ 1. *** Select "Debug" in the Configuration text box. ***
........ 2. Click "Additional Dependencies" in right pane, click down arrow > Edit.
........ 3. Type the links to the SFML libraries you will need. The five libraries are:
............ a. sfml-graphics-d.lib, sfml-window-d.lib, sfml-system-d.lib, sfml-audio-d.lib, sfml-network-d.lib
............ b. For windows application, also link to: sfml-main-d.lib
8. Run VC++ debug:
.... a. Got the following error:
Test 02.exe - System Error
The program caan't start because sfml-graphics-d-2.dll is missing from
your computer. Try reinstalling the program to fix this problem.
9. To get rid of this error:
.... a. Copy and paste all of the SFML dll files in the bin folder to the same folder the main.cpp file is in:
........ 1. Go to D:\SFML-2.0\bin.
........ 2. Copy all of the dll files.
........ 3. In VC++, right click the "main.cpp" tab at the top of the right pane to open the folder where main.cpp is stored.
........ 4. Paste all of the dll files.
10. Run VC++ debug:
.... a. Now everything compiles without errors and the SFML window is displayed with "Hello SFML" text displayed.
11. ==== DONE ====
BTW, is step-5.d.3.b "....b. For windows application, also link to: sfml-main.lib" correct?
The link to sfml-main.lib was added per:
"If you chose to create a "Windows application" project, then the entry point of your code has to be the "WinMain" function instead of "main". Since it's Windows specific, and your code would therefore not compile on Linux or Mac OS X, SFML provides a way to keep a standard "main" entry point in this case: link your project to the sfml-main module ("sfml-main-d.lib" in Debug, "sfml-main.lib" in Release), the same way you linked sfml-graphics, sfml-window and sfml-system. "
Thanks,
Raptor