SFML community forums
Help => General => Topic started by: Szedou on July 06, 2013, 11:26:57 am
-
Hi! I have problems with debuging with visualstudio2012 again...
I set up SFML2.0 with VisualStudio2012 as same as in tutorial and errors appear:
Error 2 error LNK1120: 1 unresolved externals D:\VisualProjects\SFML Project_1\Debug\SFML Project_1.exe SFML Project_1
and
Error 1 error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B) D:\VisualProjects\SFML Project_1\SFML Project_1\main.obj SFML Project_1
I think I linked files good and have audio-2.dll,graphics-2.dll,network-2.dll,system-2.dll,window-2.dll,openal32.ddll and libsndfile-1.dll in same folder as my .exe file ( Release folder ).
And in my Debug folder I have files like: audio-d-2.dll, graphics-d-2.dll, network-d-2.dll, system-d-2.dll, window-d-2.dll.
And I don't know what am I doing wrong, please help...
-
Are you linking against the debug libraries (sfml-xxx-d.lib) in debug mode, as described in the tutorial?
-
Yes, look:
(http://s1.pokazywarka.pl/i/2131371/417603/screen.jpg)
Do I need to copy something else than audio-d-2.dll, graphics-d-2.dll, network-d-2.dll, system-d-2.dll, window-d-2.dll files into Release folder(.exe directory)?
-
Do I need to copy something else than audio-d-2.dll, graphics-d-2.dll, network-d-2.dll, system-d-2.dll, window-d-2.dll files into Release folder(.exe directory)?
These should be in your debug folder. If my VS2010 is anything to go by, there are two pairs of debug/release folders.
One pair in the same folder as the source code - not the one you want.
One pair in the project directory - these contain the executables and this is where you should put the DLLs (but only appear if you have built the project in debug/release at least once).
-
eh.. I have (sfml-audio-d-2 , sfml-graphics-d-2, sfml-network-d-2, sfml-system-d-2,sfml-window-d-2) in my Debug folder and (sfml-audio-2 , sfml-graphics-2, sfml-network-2, sfml-system-2,sfml-window-2) in my Release folder.
-
Come to think of it, if that was the issue then it would build.
Can the linker find the lib files? If they 're not in path you must add the lib folder in Linker->General->additional folders or something along those lines.
-
I have D:\SFML-2.0\lib path there.
-
The DLL files themselves are only important once you get to run your application, but if it doesn't even build they are not the cause of any problem. If the linker wouldn't have been able to find the LIB files, it would spit out a different error and not an "unresolved symbol" issue.
Can you provide the code you're trying to compile?
-
Here it is:
#include <SFML/Graphics.hpp>
#include <iostream>
using namespace sf;
using namespace std;
int main()
{
RenderWindow window(VideoMode(800, 600), "SFML works!");
cout << "-----SFML2.0 is working!-----" << endl;
Time _czas;
Clock _zegar;
Sprite playerSprite;
Texture player_txt;
if(!player_txt.loadFromFile("spritesheet.png", IntRect(0,0,30,65))){ //wyswietlanie czesci obrazka a-startingPos(X),b-startingPos(Y),c-width,d-height
cout<< "Error, could not load player image" << endl;
}
playerSprite.setTexture(player_txt);
playerSprite.setPosition(0,0);
int attack = 0; //przyklad definiowania przyciskow w grze
//cout << _czas.asSeconds() << endl;
while (window.isOpen())
{
sf::Event zdarzenie;
while (window.pollEvent(zdarzenie))
{
switch(zdarzenie.type){
case Event::Closed:
window.close();
break;
case Event::MouseEntered:
cout<<"Mouse within screen bounds."<<endl;
break;
case Event::MouseLeft:
cout<< "Mouse out of screen bounds."<< endl;
case Event::MouseMoved:
//cout<<"X: " << zdarzenie.mouseMove.x << "Y: " << zdarzenie.mouseMove.y<<endl;
break;
case Event::MouseButtonPressed:
if(zdarzenie.mouseButton.button == Mouse::Left){
//cout<< "Left mouse button pressed at: " << " X: "<< zdarzenie.mouseButton.x << "Y "<< zdarzenie.mouseButton.y << endl;
}
break;
case Event::MouseWheelMoved:
cout<< "delta: " << zdarzenie.mouseWheel.delta << endl;
break;
case Event::GainedFocus:
cout << "Window Active" << endl;
break;
case Event::LostFocus:
cout << "Window not Active" << endl;
break;
case Event::Resized:
cout<< "X: "<< zdarzenie.size.width << " Y: " << zdarzenie.size.height << endl;
break;
case Event::TextEntered:
if(zdarzenie.text.unicode >= 33 && zdarzenie.text.unicode <=126)
cout << (char)zdarzenie.text.unicode;
break;
case Event::JoystickConnected:
cout << " GAMEPAD " << zdarzenie.joystickConnect.joystickId + 1 << " is Connected" << endl;
break;
case Event::JoystickDisconnected:
cout << "GAMEPAD " << zdarzenie.joystickConnect.joystickId + 1 << " is Disconnected" <<endl;
break;
case Event::JoystickButtonPressed:
cout << "Button: " << zdarzenie.joystickButton.button << endl;
attack = zdarzenie.joystickButton.button; // odczytywanie wcisnietego przycisku do attacku..
break;
case Event::JoystickMoved:
if(zdarzenie.joystickMove.axis == sf::Joystick::X){
cout<< "position: " << zdarzenie.joystickMove.position << endl;
}
}
}
_czas = _zegar.getElapsedTime();
//cout << _czas.asSeconds() << endl;
//_zegar.restart();
window.clear();
window.draw(playerSprite);
window.display();
}
return 0;
}
-
using namespace sf;
using namespace std;
This is pretty bad. You 're creating conflicts between the keywords in the two namespaces and your own code. Neither should be used.
-
Ok i rebuilt my code with tutorial one:
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
and Its not works anyway...
Error 3 error LNK1120: 2 unresolved externals D:\VisualProjects\SFML Project_1\Debug\SFML Project_1.exe 1 1 SFML Project_1
Error 1 error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B) D:\VisualProjects\SFML Project_1\SFML Project_1\main.obj SFML Project_1
Error 2 error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B) D:\VisualProjects\SFML Project_1\SFML Project_1\main.obj SFML Project_1
Arghhhh!
-
This is pretty bad. You 're creating conflicts between the keywords in the two namespaces and your own code. Neither should be used.
Although you're right, it would've been better trying to stay on topic, since it was obviously not a problem with namespace conflicts. ;)
Error 1 error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Green" (?Green@Color@sf@@2V12@B) D:\VisualProjects\SFML Project_1\SFML Project_1\main.obj SFML Project_1
Error 2 error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B) D:\VisualProjects\SFML Project_1\SFML Project_1\main.obj SFML Project_1
Those are still linking errors and now that we've the code, we can be sure, that it's a setup issue.
The common issues with linking libraries are:
- Mixing debug and release modes (you apparently don't).
- Using the wrong library version vs compiler version. You've downloaded the VS 2012 package of SFML, right?
- Defining SFML_STATIC although you're linking dynamically.
- Mixing runtime library versions.
If you've really been following the tutorial to 200% and done everything and read everything, then it will work.
At best you upload the project file, so we can take a look at what you setup wrongly. ;)
-
Oh, now it works!!!!
I just deleted SFML_STATIC to change to static version and it is working now!
Thanks a lot all of You guys! You are great! and sorry for problems...