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

Author Topic: sf::Color linker error  (Read 6698 times)

0 Members and 1 Guest are viewing this topic.

scyth3s

  • Newbie
  • *
  • Posts: 20
    • View Profile
sf::Color linker error
« on: May 17, 2011, 06:42:36 pm »
When I try to use the following code

Code: [Select]

        this->selectedColor = sf::Color::Green;
this->deselectedColor = sf::Color::Red;


Where selectedColor and deselectedColor are variables of type sf::Color, I get the following linker error.


Error   11   error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)   C:\Users\Daniel\documents\visual studio 2010\Projects\Game Template\Game Template\GButton.obj


THis is followed by an equivilent error for the green color call, and any other colors I use. If I specify the colors manually (sf::Color(0,255,0)), then I get a runtime error that breakpoints me somewhere in the middle of xutility.cpp.

My linker settings are this:
Code: [Select]
sfml-graphics.lib
sfml-window.lib
sfml-system.lib
sfml-audio.lib
sfml-main.lib
opengl32.lib
glu32.lib


and I include <SFML/Graphics.hpp> in the relevant file. What am I doing wrong?
"My church is not full of..."

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Color linker error
« Reply #1 on: May 17, 2011, 06:51:45 pm »
You must read the tutorial carefully, it is explained in bold characters... ;)
Laurent Gomila - SFML developer

scyth3s

  • Newbie
  • *
  • Posts: 20
    • View Profile
sf::Color linker error
« Reply #2 on: May 17, 2011, 07:52:41 pm »
Which tutorial? I haven't been able to find any bold print, and nothing explaing linking or anything like that.
"My church is not full of..."

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Color linker error
« Reply #3 on: May 17, 2011, 08:32:22 pm »
In "Getting started": "SFML and Visual Studio"
http://www.sfml-dev.org/tutorials/1.6/start-vc.php

The relevant part is:
Quote
Important: if you link against the dynamic libraries, you have to define the SFML_DYNAMIC macro in your project's settings. If you don't, you'll get linker errors when compiling your application.
Laurent Gomila - SFML developer

scyth3s

  • Newbie
  • *
  • Posts: 20
    • View Profile
sf::Color linker error
« Reply #4 on: May 18, 2011, 03:00:36 am »
Who this is the first I've ever had an issue without doing that... Thanks!
"My church is not full of..."

Dolotboy

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sf::Color linker error
« Reply #5 on: August 21, 2023, 04:29:40 am »
In "Getting started": "SFML and Visual Studio"
http://www.sfml-dev.org/tutorials/1.6/start-vc.php

The relevant part is:
Quote
Important: if you link against the dynamic libraries, you have to define the SFML_DYNAMIC macro in your project's settings. If you don't, you'll get linker errors when compiling your application.

I did everything as shown and I followed what you said but I get 17 errors:
Error   LNK2019   unresolved external symbol "public: __thiscall sf::String::String(char const *,class std::locale const &)" (??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main   GameEngine   E:\Programmation\Apps\GameEngine\GameEngine\main.obj   1

Error   LNK2019   unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main   GameEngine   E:\Programmation\Apps\GameEngine\GameEngine\main.obj   1   

Error   LNK2019   unresolved external symbol "public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (??0Color@sf@@QAE@EEEE@Z) referenced in function _main   GameEngine   E:\Programmation\Apps\GameEngine\GameEngine\main.obj   1   

... and 14 more for Video::Video, Window::Window etc... Can you help me ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: sf::Color linker error
« Reply #6 on: August 21, 2023, 09:57:44 am »
Sometimes it's useful to look at the date something was posted on. This thread is from 2011 and talks about SFML 1.6, which is very old... ;)

SFML_DYNAMIC doesn't exist in SFML 2.x, just make sure, you're actually linking SFML
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Dolotboy

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: sf::Color linker error
« Reply #7 on: August 21, 2023, 05:54:34 pm »
Sometimes it's useful to look at the date something was posted on. This thread is from 2011 and talks about SFML 1.6, which is very old... ;)

SFML_DYNAMIC doesn't exist in SFML 2.x, just make sure, you're actually linking SFML

https://www.sfml-dev.org/tutorials/2.6/start-vc.php
SMFL STATIC does exist in SFML 2.* as it is written in the documentations that I followed step by step but get the 17 errors anyway

 

anything