SFML community forums
Help => General => Topic started by: toast9 on March 29, 2015, 10:36:01 am
-
I'm setting up a sfml project for the first time and I can't seem to get a shape drawn to the screen. I get two linker errors: error lnk2001 unresolved external symbol. One doesn't like sfml's Color:Red and the others doesn't like RenderStates. I can create a window just fine, just can't put anything on it.
Here's the code:
#include<iostream>
#include <SFML/Graphics.hpp>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(600, 800), "SFML works!");
sf::CircleShape circle;
circle.setRadius(40);
circle.setPosition(100, 100);
circle.setFillColor(sf::Color::Red);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(circle);
window.display();
}
return 0;
}
-
Read the following link and post output.
http://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
-
Here are the errors in full:
Error 1 error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)
Error 2 error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
-
Still no use.... I will only say it one more time.
Read the following link and post output.
http://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
-
I am using Visual Studios 2013. Here's the build:
1>------ Build started: Project: FinalProject, Configuration: Debug Win32 ------
1> Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x86
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> cl /c /I"SFML-2.2/include" /I../../../shared/DeanLib /ZI /W3 /WX- /sdl /Od /Oy- /D SFML_STATIC /D _MBCS /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
1>
1> Skipping... (no relevant changes detected)
1> main.cpp
1> Microsoft (R) Incremental Linker Version 12.00.21005.1
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> "/OUT:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.exe" /INCREMENTAL "/LIBPATH:SFML-2.2/lib" /LIBPATH:../../../shared/DeanLib/ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "sfml-graphics-d.lib" "sfml-window-d.lib" "sfml-audio-d.lib" "sfml-network-d.lib" "sfml-main-d.lib" "sfml-system-d.lib" ../../../shared/DeanLib/Debug/DeanLib.lib /MANIFEST "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG "/PDB:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.pdb" /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.lib" /MACHINE:X86 Debug\main.obj
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-
If you want to link statically (you defined SFML_STATIC so I suppose you want to) you have to link to the -s version of SFML. (sfml-graphics-s etc. (-s-d for debug))
You also have to link SFML dependencies. (opengl32 etc.)
Everything is in the tutorial (http://www.sfml-dev.org/tutorials/2.2/start-vc.php).
-
I've decided to go with dynamic instead, and modified the properties receptively. It's all working now, thanks both of you for your help!