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

Author Topic: Unresolved External Symbol (One line of error?)  (Read 1572 times)

0 Members and 1 Guest are viewing this topic.

eca3101

  • Guest
Unresolved External Symbol (One line of error?)
« on: March 22, 2014, 12:00:33 am »
So I was following this series (http://www.youtube.com/watch?v=WFts4-62F6U#start=0:00;end=8:60;cycles=-1;autoreplay=false;showoptions=false) and everything ran and compiled fine until I ran into this error message: 

error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)

This is my code:
#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>

int main()
{
        sf::RenderWindow Window(sf::VideoMode(800, 500), "Hello", sf::Style::Default);

        std::string display = "";

        Window.setKeyRepeatEnabled(false);

        sf::Texture pTexture;
        sf::Sprite playerImage;
        if (!pTexture.loadFromFile("Character.png"))
                std::cout <<"Could not load player image" << std::endl;

        playerImage.setTexture(pTexture);

        while(Window.isOpen())
        {
                int index = 0;
                int axis = 0, prevAxis = 0;

                sf::Event Event;
                while(Window.pollEvent(Event))
                {
                        prevAxis = axis;
                        if (Event.type == sf::Event::Closed)
                        {
                                std::cout <<"Window closed ";
                                Window.close();
                        }
                }

                Window.draw(playerImage);
                Window.display();
        }
}

I have the image the same folder as the exe and everything  :-[
I also linked the project as it said the in the setup guide

I'm running VS C++ 2010 Express, Win 7

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Unresolved External Symbol (One line of error?)
« Reply #1 on: March 22, 2014, 09:20:31 am »
You should not follow these YouTube "tutorials", they have a lot of bad and buggy code and the explanations are often vague or simply wrong.

There's also no real advantage in using VS 2010, now that we already have VS 2013, so I suggest you get the newer version instead. ;)

As for the linking error, you need to provide the full build command.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

eca3101

  • Guest
Re: Unresolved External Symbol (One line of error?)
« Reply #2 on: March 22, 2014, 05:57:28 pm »
Thanks for all the info, here's more:

1>------ Build started: Project: SFMLpart2, Configuration: Debug Win32 ------
1>  Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  cl /c /I"C:\Users\User1\Desktop\real\SFML-2.1\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D SFML_STATIC /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
1>cl : Command line warning D9035: option 'nologo-' has been deprecated and will be removed in a future release
1> 
1>  Skipping... (no relevant changes detected)
1>  main.cpp
1>  Microsoft (R) Incremental Linker Version 10.00.30319.01
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  "/OUT:C:\Users\User1\Desktop\programs\Windows\SFML\test\SFMLpart2\Debug\SFMLpart2.exe" /INCREMENTAL:NO "/LIBPATH:C:\Users\User1\Desktop\real\SFML-2.1\lib" "sfml-main-d.lib" "sfml-network-d.lib" "sfml-audio-d.lib" "sfml-graphics-d.lib" "sfml-window-d.lib" "sfml-system-d.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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST "/ManifestFile:Debug\SFMLpart2.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\User1\Desktop\programs\Windows\SFML\test\SFMLpart2\Debug\SFMLpart2.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\User1\Desktop\programs\Windows\SFML\test\SFMLpart2\Debug\SFMLpart2.lib" /MACHINE:X86 Debug\main.obj
1>main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets(268,5): error MSB6006: "link.exe" exited with code 1120.
1>C:\Users\User1\Desktop\programs\Windows\SFML\test\SFMLpart2\Debug\SFMLpart2.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========