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

Author Topic: (Solved) Need help with errors after updating SFML  (Read 7127 times)

0 Members and 1 Guest are viewing this topic.

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« on: May 25, 2011, 10:10:44 pm »
I updated to SFML 2 in January. I hadn't updated SFML again until today.
When I try to code anything with SFML I get errors.

I've tried compiling in debug/release with static and non-static libs and using SFML_STATIC in the preprocessor commands.

I'm currently trying to compile in Debug with non-static libs.
I'm linking to sfml-main, system, graphics, and window.

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow WINDOW(sf::VideoMode(400,400),"Title");
return 0;
}


Code: [Select]
1>example.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) 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::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUContextSettings@1@@Z) referenced in function _main
1>C:\User\Documents\Visual Studio 2008\Projects\example\Debug\example.exe : fatal error LNK1120: 1 unresolved externals

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #1 on: May 26, 2011, 01:23:15 am »
Would anymore mind uploading a working project file using the most recent version of SFML2 that works with just a couple of lines of code?

I have no idea what is wrong with mine =/.

PhiLLe

  • Newbie
  • *
  • Posts: 36
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #2 on: May 26, 2011, 02:37:49 pm »
Are you linking in the correct order?
In your case it should be: -lsfml-graphics -lsfml-window -lsfml-system

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #3 on: May 26, 2011, 05:11:39 pm »
Did the update make it so they have to be in a certain order now?

I tried different orders but it didn't make a difference. I might have to reinstall sfml.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(Solved) Need help with errors after updating SFML
« Reply #4 on: May 26, 2011, 05:18:13 pm »
As far as I know, order makes a difference only for gcc.
Laurent Gomila - SFML developer

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #5 on: May 26, 2011, 08:03:35 pm »
I deleted all of the SFML files and redownloaded them. I rebuilt SFML and linked directly to a folder that has the libs in it on the compiler tools. I'm getting the same error. Should I reinstall Visual Studio?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(Solved) Need help with errors after updating SFML
« Reply #6 on: May 26, 2011, 09:27:09 pm »
Quote
Should I reinstall Visual Studio?

No, this is clearly a bad configuration problem, your programming environment is not broken.

Can you upload your vcproj file?
Laurent Gomila - SFML developer

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #7 on: May 27, 2011, 04:34:33 am »
Sure, here it is.
http://www.sendspace.com/file/9ah5nh
Thanks for the help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(Solved) Need help with errors after updating SFML
« Reply #8 on: May 27, 2011, 07:57:44 am »
Do you compile SFML with STATIC_STD_LIBS disabled?
Laurent Gomila - SFML developer

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #9 on: May 27, 2011, 08:32:26 pm »
I'm not sure where that is or how to change it, but I haven't changed any settings since I updated SFML. One minute it was working and the next it wasn't. I have tried both static and dynamic libs though.

When I compiled SFML, i tried compiling certain libs to all libs to try out. I didn't try to change anything that I haven't done before :(.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(Solved) Need help with errors after updating SFML
« Reply #10 on: May 27, 2011, 11:45:58 pm »
Quote
I'm not sure where that is or how to change it

It's a CMake option.
Laurent Gomila - SFML developer

Sir Demon

  • Newbie
  • *
  • Posts: 2
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #11 on: May 28, 2011, 01:16:20 pm »
Edit: Figured it out, I had simply selected wrong generator for CMake. I figured Visual Studio 10 Win64 would be correct since I have 64 bit Windows, but that apparently is not the case. Sorry about the fuss.

I'm not sure if my issue is related but it's quite similar. I was already creating a new topic for it when I noticed this one.

I updated to a new version of SFML2 from a version that was more than a year old. So I got the latest source from Github and followed the instructions here.

I built the thing and now I'm getting the following errors:

Code: [Select]
RenderingWindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function "public: virtual __thiscall RenderingWindow::~RenderingWindow(void)" (??1RenderingWindow@@UAE@XZ)
1>RenderingWindow.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall sf::Window::OnCreate(void)" (?OnCreate@Window@sf@@EAEXXZ)
1>RenderingWindow.obj : error LNK2001: unresolved external symbol "private: virtual void __thiscall sf::Window::OnResize(void)" (?OnResize@Window@sf@@EAEXXZ)


RenderingWindow is my own class that inherits from sf::Window. I made some tests and it seems that any call to any SFML function gives this kind of error (at least several sf::Window methods, sf::Input::IsKeyDown and sf::Clock::GetElapsedTime). The source I'm using to compile SFML does have all those methds defined, obviously.

This happens with both release and debug mode. I've triple-checked that my paths to the .lib files are correct and the .dll-files are in the working directory of the project. I've tried both STATIC_STD_LIBS disabled and enabled. SFML_DYNAMIC is defined, I also tried without defining it in case things have changed since last time I set SFML up. I noticed the .dll names have "-2" affixed to them (sfml-window-d-2.dll, for example), in desperation I also tried removing the "-2", to no avail.

I'm using the same instance of Visual Studio 2010 to build both SFML and my own project, so it shouldn't be a matter of different compiler version for SFML and my own project.

I've pretty much followed the 1.6 tutorial when setting things up, and just found out SFML2 procedures differs somewhat (SFML_STATIC, for example). I'm using dynamic libraries, but are there any other gotchas that are not needed for 1.6 (and thus I would have missed them)?. The year old version of SFML2 I've been using that still used SVN worked perfectly with the 1.6 instructions. I then updated my ATi drivers which messed things up and I thought updating the SFML might work.

I apologize for intruding the thread, I just feel the issues are so close to each other that a separate thread would be unnecessary pollution.

Edit: I'm linking to

sfml-main.lib/sfml-main-d.lib
sfml-system.lib/sfml-system-d.lib
sfml-graphics.lib/sfml-graphics-d.lib
sfml-audio.lib/sfml-audio-d.lib
sfml-network.lib/sfml-network-d.lib
sfml-window.lib/sfml-window-d.lib

in case that's any help.
"We don't stop playing because we grow old; we grow old because we stop playing." -George Bernard Shaw

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #12 on: May 28, 2011, 10:21:15 pm »
It is no problem Sir Demon, we have the same problem. I'm currently downloading MSVS 2010 to see if it works for me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
(Solved) Need help with errors after updating SFML
« Reply #13 on: May 28, 2011, 10:25:11 pm »
Quote
Edit: Figured it out, I had simply selected wrong generator for CMake. I figured Visual Studio 10 Win64 would be correct since I have 64 bit Windows, but that apparently is not the case. Sorry about the fuss.

Just a tip: don't edit an existing post to write the solution to your problem. If the topic has no new post, nobody will notice your edit. Write a new message instead.
Laurent Gomila - SFML developer

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
(Solved) Need help with errors after updating SFML
« Reply #14 on: May 29, 2011, 12:15:24 am »
Ok, I didn't use CMake to help setup SFML (I guess it is a requirement now?), but I just used it and got everything to work just fine. Thanks.