Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED]Problem with debuging VisualStudio 2012 AGAIN  (Read 5850 times)

0 Members and 1 Guest are viewing this topic.

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
[SOLVED]Problem with debuging VisualStudio 2012 AGAIN
« 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...

« Last Edit: July 08, 2013, 05:50:50 pm by Szedou »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Problem with debuging VisualStudio 2012 AGAIN
« Reply #1 on: July 06, 2013, 04:31:38 pm »
Are you linking against the debug libraries (sfml-xxx-d.lib) in debug mode, as described in the tutorial?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #2 on: July 06, 2013, 10:10:46 pm »
Yes, look:



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)?
« Last Edit: July 06, 2013, 10:17:13 pm by Szedou »

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #3 on: July 07, 2013, 08:33:07 am »
Quote
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).

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #4 on: July 07, 2013, 10:05:50 am »
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.

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #5 on: July 07, 2013, 03:44:14 pm »
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.

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #6 on: July 07, 2013, 05:16:19 pm »
I have D:\SFML-2.0\lib path there.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #7 on: July 07, 2013, 05:32:02 pm »
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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #8 on: July 07, 2013, 07:49:47 pm »
Here it is:

Quote
#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;
}

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #9 on: July 07, 2013, 09:06:42 pm »
Quote
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.

« Last Edit: July 07, 2013, 09:11:35 pm by Kojay »

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #10 on: July 08, 2013, 08:33:29 am »
Ok i rebuilt my code with tutorial one:

Quote
#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...

Quote
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!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #11 on: July 08, 2013, 10:09:28 am »
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. ;)

Quote
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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Szedou

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Problem with debuging VisualStudio 2012 AGAIN
« Reply #12 on: July 08, 2013, 05:48:53 pm »
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...