SFML community forums
Help => General => Topic started by: mantracker on July 24, 2013, 10:55:19 am
-
I am sure there are millions of threads on this already, and I must have read like 90% of them and tried all sorts of different solutions, but none of them works for me.
So basicly, I followed the official tutorial here: http://www.sfml-dev.org/tutorials/2.0/start-vc.php EXACTLY! To illustrate, I will again, repeat what I have done:
1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics.lib;sfml-window.lib;sfml-system.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial
6. Then, I clicked apply and ok and wrote the code from the tutorial, this is the error I got:
1>------ Build started: Project: MyGames, Configuration: Debug Win32 ------
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::close(void)" (?close@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::isOpen(void)const " (?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::display(void)" (?display@Window@sf@@QAEXXZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (?clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Shape::~Shape(void)" (??1Shape@sf@@UAE@XZ) referenced in function "public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (??1CircleShape@sf@@UAE@XZ)
1>Source.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (?setFillColor@Shape@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (??0CircleShape@sf@@QAE@MI@Z) referenced in function _main
1>Source.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B)
1>Source.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>c:\users\documents\visual studio 2012\Projects\MyGames\Debug\MyGames.exe : fatal error LNK1120: 17 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have followed the exact 6 steps above as I wrote, nothing more nothing less. I don't understand dynamic and static parts of sfml whatsoever. I am at loss as to why it does not work for me.
As I have said already, I understand that this topic has been asked many times before and all the errors seem similar. However, after reading many threads I still can't seem to able to resolve this problem.
Thanks in advance for any one that can give me a hint as to what is wrong
-
Well it's important to not only look at the images, but also to read what the images mean.
If you want to get rid of these DLLs and have SFML directly integrated to your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.
If you want to link statically, you'll need to specify the libs with the -s suffix and define SFML_STATIC. If you want to link shared, you'll neeed to specify the libs with no -s suffix, but you're not allowed to define SFML_STATIC.
-
Well it's important to not only look at the images, but also to read what the images mean.
If you want to get rid of these DLLs and have SFML directly integrated to your executable, you must link to the static version. Static SFML libraries have the "-s" suffix: "sfml-xxx-s-d.lib" for Debug, and "sfml-xxx-s.lib" for Release.
In this case, you'll also need to define the SFML_STATIC macro in the preprocessor options of your project.
If you want to link statically, you'll need to specify the libs with the -s suffix and define SFML_STATIC. If you want to link shared, you'll neeed to specify the libs with no -s suffix, but you're not allowed to define SFML_STATIC.
Alright so, this is now an updated version of what I have done:
1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial
I still got the exact same error, is there something else Im missing?
EDIT: So now I've also added the -s-d files in, this is what I've done:
1. When creating a project, I chose "Win32 project"
2. In project properties, I chose "All configurations"->"C/C++"->"General"->"Additional include directories" and added SFML-2.0\include
3. In "Linker"->"General" of "All configurations", I added SFML-2.0\lib
4. In "Release"->"Linker"->"Input", I added "sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;", in that order and EXACTLY as what was written on the official tutorial
4. In "Debug"->"Linker"->"Input", I added "sfml-graphics-s-d.lib;sfml-window-s-d.lib;sfml-system-s-d.lib;", in that order and EXACTLY as what was written on the official tutorial
5. In "Debug"-> "C/C++" -> "Preprocessor", I added SFML_STATIC; as shown on tutorial
This is the new error I got:
1>------ Build started: Project: adfasdfasdf, Configuration: Debug Win32 ------
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Martin Liu\documents\visual studio 2012\Projects\adfasdfasdf\Debug\adfasdfasdf.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
EDIT 2: nevermind, thanks for your help. I resolved that error and now everything works just fine