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

Author Topic: Why can't I compile this? What are these errors?  (Read 5043 times)

0 Members and 1 Guest are viewing this topic.

Geners

  • Newbie
  • *
  • Posts: 9
    • View Profile
Why can't I compile this? What are these errors?
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Why can't I compile this? What are these errors?
« Reply #1 on: October 26, 2012, 08:15:07 am »
You must link to sfml-graphics and sfml-window.
Laurent Gomila - SFML developer

Geners

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Why can't I compile this? What are these errors?
« Reply #2 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:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Why can't I compile this? What are these errors?
« Reply #3 on: October 26, 2012, 08:40:03 am »
It is explained in the "Getting started" tutorial.
Laurent Gomila - SFML developer

Geners

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Why can't I compile this? What are these errors?
« Reply #4 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'

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Why can't I compile this? What are these errors?
« Reply #5 on: October 26, 2012, 09:16:05 am »
Please read the tutorial carefully. Look at the screenshots.
Laurent Gomila - SFML developer

Geners

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Why can't I compile this? What are these errors?
« Reply #6 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. :)

 

anything