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

Author Topic: creating a shape gives linker errors  (Read 2025 times)

0 Members and 1 Guest are viewing this topic.

toast9

  • Newbie
  • *
  • Posts: 8
    • View Profile
creating a shape gives linker errors
« on: March 29, 2015, 10:36:01 am »
I'm setting up a sfml project for the first time and I can't seem to get a shape drawn to the screen. I get two linker errors: error lnk2001 unresolved external symbol. One doesn't like sfml's Color:Red and the others doesn't like RenderStates. I can create a window just fine, just can't put anything on it.

Here's the code:


#include<iostream>
#include <SFML/Graphics.hpp>
using namespace std;

int main()
{
   sf::RenderWindow window(sf::VideoMode(600, 800), "SFML works!");

   sf::CircleShape circle;
   circle.setRadius(40);
   circle.setPosition(100, 100);
   circle.setFillColor(sf::Color::Red);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
      window.clear();
      window.draw(circle);
      window.display();
    }
   return 0;
}

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: creating a shape gives linker errors
« Reply #1 on: March 29, 2015, 12:57:06 pm »
Read the following link and post output.

http://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

toast9

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: creating a shape gives linker errors
« Reply #2 on: March 29, 2015, 08:02:25 pm »
Here are the errors in full:

Error   1   error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)

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

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: creating a shape gives linker errors
« Reply #3 on: March 29, 2015, 09:31:44 pm »
Still no use.... I will only say it one more time.

Read the following link and post output.

http://www.sfml-dev.org/faq.php#tr-grl-verbose-ide
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

toast9

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: creating a shape gives linker errors
« Reply #4 on: March 30, 2015, 12:25:07 am »
I am using Visual Studios 2013. Here's the build:

Code: [Select]
1>------ Build started: Project: FinalProject, Configuration: Debug Win32 ------
1>  Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x86
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  cl /c /I"SFML-2.2/include" /I../../../shared/DeanLib /ZI /W3 /WX- /sdl /Od /Oy- /D SFML_STATIC /D _MBCS /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
1> 
1>  Skipping... (no relevant changes detected)
1>  main.cpp
1>  Microsoft (R) Incremental Linker Version 12.00.21005.1
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  "/OUT:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.exe" /INCREMENTAL "/LIBPATH:SFML-2.2/lib" /LIBPATH:../../../shared/DeanLib/ 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 "sfml-graphics-d.lib" "sfml-window-d.lib" "sfml-audio-d.lib" "sfml-network-d.lib" "sfml-main-d.lib" "sfml-system-d.lib" ../../../shared/DeanLib/Debug/DeanLib.lib /MANIFEST "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG "/PDB:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.pdb" /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.lib" /MACHINE:X86 Debug\main.obj
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)
1>main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)
1>C:\Users\Gabrielle\Desktop\Game Arch\Final Project\Gabby.Mary.FinalProject\FinalProject\Debug\FinalProject.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
« Last Edit: March 30, 2015, 12:27:13 am by toast9 »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: creating a shape gives linker errors
« Reply #5 on: March 30, 2015, 02:12:30 am »
If you want to link statically (you defined SFML_STATIC so I suppose you want to) you have to link to the -s version of SFML. (sfml-graphics-s etc. (-s-d for debug))

You also have to link SFML dependencies. (opengl32 etc.)
Everything is in the tutorial.
« Last Edit: March 30, 2015, 02:18:07 am by G. »

toast9

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: creating a shape gives linker errors
« Reply #6 on: March 30, 2015, 03:22:20 am »
I've decided to go with dynamic instead, and modified the properties receptively. It's all working now, thanks both of you for your help!

 

anything