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

Author Topic: LNK2001 Error after starting VS again  (Read 3092 times)

0 Members and 2 Guests are viewing this topic.

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
LNK2001 Error after starting VS again
« on: February 27, 2015, 05:31:11 pm »
Hi everybody,

i was working on the first chapter of SFML Game Development yesterday. I made the cyan circle move and everything was working fine. I saved the files and closed the project.
Today i wanted to work again on the Project and i get a lot LNK2001 : unresolved external symbol
problems.
I looked on the Internet and most Threads go about how the linking was done wrong, but since it worked yesterday I don't think thats the case.
Still i checked and everything looked fine.
Any suggestions?

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: LNK2001 Error after starting VS again
« Reply #1 on: February 27, 2015, 08:23:30 pm »
Sadly, my magic ball is broken.

Without information on how you linked, what is the unresolved symbols, the command line to build the project, it won't be possible really for us to help you.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #2 on: March 05, 2015, 05:27:20 pm »
Hi
im sorry your right.
I linked static.
http://imgur.com/xNGJWDN
These are the Error messages i get.
What do you mean with command line? i build with ctrl+shift+b

Thanks

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: LNK2001 Error after starting VS again
« Reply #3 on: March 05, 2015, 05:39:24 pm »
You may build by pressing a key combo, but what happens "under the hood" is that visual studio invokes the compiler (cl.exe) with a number of commandline arguments (just like you'd do if building by hand from a cmd shell). That commandline is what you are being asked for.

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #4 on: March 05, 2015, 08:06:01 pm »
Is that what your looking for?
Debug:
/GS /analyze- /W3 /Zc:wchar_t /I"C:\Users\Robert\Desktop\SFML-2.2\include" /ZI /Gm /Od /sdl /Fd"Debug\vc120.pdb" /fp:precise /D "SFML_STATIC" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\projekt-buch.pch"
Release:
/GS /GL /analyze- /W3 /Gy /Zc:wchar_t /I"C:\Users\Robert\Desktop\SFML-2.2\include" /Zi /Gm- /O2 /sdl /Fd"Release\vc120.pdb" /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\projekt-buch.pch"


zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: LNK2001 Error after starting VS again
« Reply #5 on: March 05, 2015, 08:35:37 pm »
Either that isn't the full command line, or no where there do you link to sfml - so add sfml libs to your linker settings. And don't reply "how do I link" because if you don't know google is your best friend.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #6 on: March 05, 2015, 08:43:10 pm »
As said in the beginning it already worked.
So it was linked properly otherwise it would not work the first time.
This problem occured after i closed VS and opened up the project again.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: LNK2001 Error after starting VS again
« Reply #7 on: March 05, 2015, 08:59:39 pm »
Follow this and show us the full command line. That will eliminate having to guess more than we should.

Your assumption that something which functions will not cease to function if you don't actively do something to change it doesn't hold all the time, especially with Microsoft products. They advertise with being able to make "intelligent decisions" for you in certain situations, but this can also go wrong sometimes. Always check things that you don't expect changed. It literally takes you 20 seconds, and saves us 2 hours of guessing.

Those errors are linker errors, so something is not right regarding the compile/link process. We will be able to tell you with 95% probability what it is if you just show us the full command line, so I would recommend you try to do that.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #8 on: March 05, 2015, 09:44:47 pm »
Code: [Select]
1>------ Build started: Project: projekt-buch, Configuration: Release Win32 ------
1>  Microsoft (R) Incremental Linker Version 12.00.31101.0
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  "/OUT:C:\Users\Robert\documents\visual studio 2013\Projects\projekt-buch\Release\projekt-buch.exe" "/LIBPATH:C:\Users\Robert\Desktop\SFML-2.2\lib" "sfml-main.lib" "sfml-system-s.lib" "sfml-network-s.lib" "sfml-audio-s.lib" "sfml-window-s.lib" "sfml-graphics-s.lib" winmm.lib ws2_32.lib sndfile.lib openal32.lib opengl32.lib gdi32.lib glew.lib freetype.lib jpeg.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 /MANIFEST "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG "/PDB:C:\Users\Robert\documents\visual studio 2013\Projects\projekt-buch\Release\projekt-buch.pdb" /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\Robert\documents\visual studio 2013\Projects\projekt-buch\Release\projekt-buch.lib" /MACHINE:X86 /SAFESEH Release\Game.obj
1>  Release\main.obj
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::Color const sf::Color::Cyan" (__imp_?Cyan@Color@sf@@2V12@B)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Shape::setFillColor(class sf::Color const &)" (__imp_?setFillColor@Shape@sf@@QAEXABVColor@2@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::move(class sf::Vector2<float> const &)" (__imp_?move@Transformable@sf@@QAEXABV?$Vector2@M@2@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Transformable::setPosition(float,float)" (__imp_?setPosition@Transformable@sf@@QAEXMM@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::display(void)" (__imp_?display@Window@sf@@QAEXXZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class sf::RenderStates const sf::RenderStates::Default" (__imp_?Default@RenderStates@sf@@2V12@B)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::CircleShape::setRadius(float)" (__imp_?setRadius@CircleShape@sf@@QAEXM@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::CircleShape::CircleShape(float,unsigned int)" (__imp_??0CircleShape@sf@@QAE@MI@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: float __thiscall sf::Time::asSeconds(void)const " (__imp_?asSeconds@Time@sf@@QBEMXZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class sf::Time __thiscall sf::Clock::restart(void)" (__imp_?restart@Clock@sf@@QAE?AVTime@2@XZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Clock::Clock(void)" (__imp_??0Clock@sf@@QAE@XZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) class sf::Time __cdecl sf::seconds(float)" (__imp_?seconds@sf@@YA?AVTime@1@M@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::draw(class sf::Drawable const &,class sf::RenderStates const &)" (__imp_?draw@RenderTarget@sf@@QAEXABVDrawable@2@ABVRenderStates@2@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::clear(class sf::Color const &)" (__imp_?clear@RenderTarget@sf@@QAEXABVColor@2@@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::CircleShape::~CircleShape(void)" (__imp_??1CircleShape@sf@@UAE@XZ)
1>Game.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ)
1>C:\Users\Robert\documents\visual studio 2013\Projects\projekt-buch\Release\projekt-buch.exe : fatal error LNK1120: 24 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: LNK2001 Error after starting VS again
« Reply #9 on: March 05, 2015, 11:06:58 pm »
You will need to do a full rebuild of your project (this is the equivalent of cleaning it and building again) and post the full command line here. What you posted only contains the link step, since the compile step was already successful in a previous run. The compiler flags are just as important for a proper diagnosis, so it is necessary in this case.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #10 on: March 06, 2015, 08:07:09 am »
Can't get the whole output on here so i made a txt file
« Last Edit: March 06, 2015, 08:25:47 am by bobby »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: LNK2001 Error after starting VS again
« Reply #11 on: March 06, 2015, 09:45:14 am »
You can search that file for SFML_STATIC, because it isn't there. This means that Visual Studio isn't passing it to the compiler, so your project settings are wrong, and thus you are getting linker errors. Now you know what to fix.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

bobby

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: LNK2001 Error after starting VS again
« Reply #12 on: March 06, 2015, 10:02:43 am »
Thank you all very much!
I had SFML_STATIC only in the debug configuration not in the release.
So i added it also to the release configuration and now it works :) !!

But why did it work in the first place then?
This is what confused me in the first place.

Thanks a lot

 

anything