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

Author Topic: Unresolved External Symbol?  (Read 4969 times)

0 Members and 1 Guest are viewing this topic.

BrainInaJar1245

  • Newbie
  • *
  • Posts: 21
    • View Profile
Unresolved External Symbol?
« on: March 14, 2012, 03:05:40 pm »
So I'm making a pong clone, and I'm currently compiling it with the following output:

1>------ Build started: Project: Pong, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Image::Create(unsigned int,unsigned int,class sf::Color const &)" (__imp_?Create@Image@sf@@QAEXIIABVColor@2@@Z) referenced in function "public: void __thiscall Display::load_resources(void)" (?load_resources@Display@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function "public: void __thiscall Display::load_resources(void)" (?load_resources@Display@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Texture::LoadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class sf::Rect<int> const &)" (__imp_?LoadFromFile@Texture@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV?$Rect@H@2@@Z) referenced in function "public: void __thiscall Display::load_resources(void)" (?load_resources@Display@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Font::LoadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?LoadFromFile@Font@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: void __thiscall Display::load_resources(void)" (?load_resources@Display@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Sprite::SetTexture(class sf::Texture const &,bool)" (__imp_?SetTexture@Sprite@sf@@QAEXABVTexture@2@_N@Z) referenced in function "public: void __thiscall Display::loadSprites(void)" (?loadSprites@Display@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Sprite::~Sprite(void)" (__imp_??1Sprite@sf@@UAE@XZ) referenced in function "public: void __thiscall Ball::setSprite(class sf::Sprite)" (?setSprite@Ball@@QAEXVSprite@sf@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::Sprite & __thiscall sf::Sprite::operator=(class sf::Sprite const &)" (__imp_??4Sprite@sf@@QAEAAV01@ABV01@@Z) referenced in function "public: void __thiscall Ball::setSprite(class sf::Sprite)" (?setSprite@Ball@@QAEXVSprite@sf@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(void)" (__imp_??0Sprite@sf@@QAE@XZ) referenced in function "public: __thiscall Ball::Ball(void)" (??0Ball@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::SetPosition(float,float)" (__imp_?SetPosition@Transformable@sf@@QAEXMM@Z) referenced in function "public: void __thiscall Ball::updateSprite(void)" (?updateSprite@Ball@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::~Image(void)" (__imp_??1Image@sf@@QAE@XZ) referenced in function __unwindfunclet$??0Display@@QAE@XZ$0
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::~Texture(void)" (__imp_??1Texture@sf@@QAE@XZ) referenced in function __unwindfunclet$??0Display@@QAE@XZ$0
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::~Font(void)" (__imp_??1Font@sf@@QAE@XZ) referenced in function __unwindfunclet$??0Display@@QAE@XZ$0
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Image::Image(void)" (__imp_??0Image@sf@@QAE@XZ) referenced in function "public: __thiscall Display::Display(void)" (??0Display@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Texture::Texture(void)" (__imp_??0Texture@sf@@QAE@XZ) referenced in function "public: __thiscall Display::Display(void)" (??0Display@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Font::Font(void)" (__imp_??0Font@sf@@QAE@XZ) referenced in function "public: __thiscall Display::Display(void)" (??0Display@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Sprite::Sprite(class sf::Sprite const &)" (__imp_??0Sprite@sf@@QAE@ABV01@@Z) referenced in function "public: void __thiscall Game::reset(void)" (?reset@Game@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl sf::Keyboard::IsKeyPressed(enum sf::Keyboard::Key)" (__imp_?IsKeyPressed@Keyboard@sf@@SA_NW4Key@12@@Z) referenced in function "public: void __thiscall Game::update(void)" (?update@Game@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Close(void)" (__imp_?Close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IABUContextSettings@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>C:\Users\Owner\Documents\Visual Studio 2010\Projects\Pong\Debug\Pong.exe : fatal error LNK1120: 22 unresolved externals


All I've read says I'm linking incorrectly, but I have all the files I should need in the include section... What am I doing wrong?
Bass gets you through in times of treble.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Unresolved External Symbol?
« Reply #1 on: March 14, 2012, 03:13:37 pm »
Including != linking

The first one brings the declarations of classes and functions into your own code, so that you can use them. A missing include will trigger "xxx undeclared" compiler errors.

The second one gathers the compiled code of all the functions that you use, from your own compiled files and the libraries that you use, into your final executable. A missing library will trigger "unresolved symbol xxx" linker errors.

So you most likely forgot to add the sfml-graphics and sfml-window libraries in your linker settings ;)
Laurent Gomila - SFML developer

BrainInaJar1245

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Unresolved External Symbol?
« Reply #2 on: March 28, 2012, 03:53:58 pm »
Could you show me a site or example of what exactly I need to do to do that? I'm pretty new to anything in C++ above the basic console app stuff. I know the language, but any sort of external library is very foreign to me.
Bass gets you through in times of treble.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Unresolved External Symbol?
« Reply #3 on: March 28, 2012, 04:10:02 pm »
There's a tutorial for that ;)
Laurent Gomila - SFML developer