SFML community forums

Help => General => Topic started by: Geners on October 26, 2012, 05:10:42 am

Title: Why can't I compile this? What are these errors?
Post by: Geners on October 26, 2012, 05:10:42 am
I am using Micrsoft visual studios C++ 2008

I opened a C++ console window after installing and following all the directions for install and including all the libraries for the project.

This is the code

#include "stdafx.h"


#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>


int main() {

        sf::RenderWindow Game(sf::VideoMode (800, 600, 32), "SFML window test" );
                sf::Event Event;
                while(Game.IsOpened())
                {
                        while(Game.GetEvent(Event)) {

                                if ( Event.Type == sf::Event::Closed)
                                        Game.Close();

                        }
                        Game.Clear();

                        Game.Display();

                }
        return EXIT_SUCCESS;
}


 


And here are the errors

1>Linking...
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003A9) "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AA) "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@$$FQAE@EEEE@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AB) "public: void __thiscall sf::RenderTarget::Clear(class sf::Color const &)" (?Clear@RenderTarget@sf@@$$FQAEXABVColor@2@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AC) "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AD) "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@$$FQAE_NAAVEvent@2@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AE) "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@$$FQBE_NXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003AF) "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@$$FUAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003B0) "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@$$FQAE@III@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2028: unresolved token (0A0003B1) "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (??0RenderWindow@sf@@$$FQAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (??1RenderWindow@sf@@$$FUAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::RenderTarget::Clear(class sf::Color const &)" (?Clear@RenderTarget@sf@@$$FQAEXABVColor@2@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@$$FQAE@EEEE@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@$$FQAE_NAAVEvent@2@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@$$FQBE_NXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (??0RenderWindow@sf@@$$FQAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>Testing_sfml.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@$$FQAE@III@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>C:\Users\michalan\Documents\Visual Studio 2008\Projects\Testing_sfml\Debug\Testing_sfml.exe : fatal error LNK1120: 18 unresolved externals
Title: Re: Why can't I compile this? What are these errors?
Post by: Laurent on October 26, 2012, 08:15:07 am
You must link to sfml-graphics and sfml-window.
Title: Re: Why can't I compile this? What are these errors?
Post by: Geners on October 26, 2012, 08:38:08 am
You must link to sfml-graphics and sfml-window.

Oh thank you! A reply :)

How do I link? D:
Title: Re: Why can't I compile this? What are these errors?
Post by: Laurent on October 26, 2012, 08:40:03 am
It is explained in the "Getting started" tutorial.
Title: Re: Why can't I compile this? What are these errors?
Post by: Geners on October 26, 2012, 08:54:00 am
It is explained in the "Getting started" tutorial.

Alright cool, So I went into additional dependencies and put in  sfml-graphics; sfml-window

But when I tried to run it, it gave me this fatal error.

1>LINK : fatal error LNK1104: cannot open file 'sfml-graphics;.obj'
Title: Re: Why can't I compile this? What are these errors?
Post by: Laurent on October 26, 2012, 09:16:05 am
Please read the tutorial carefully. Look at the screenshots.
Title: Re: Why can't I compile this? What are these errors?
Post by: Geners on October 26, 2012, 11:31:59 am
Please read the tutorial carefully. Look at the screenshots.
I found my solution, for some odd reason I was putting .dll instead of .lib

Thank you so much for being patient with me and showing me where I needed to be. :)