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

Author Topic: SFML2 and Visual Studio 2010  (Read 8156 times)

0 Members and 1 Guest are viewing this topic.

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« on: April 23, 2010, 09:13:24 pm »
I compiled the packages with vs2010 and got linker errors.
I changed the platform toolset from v100 to v90 and it ran without a problem.
If i change the platform toolset again it compiles but it gives me an acess violation exception in WindowImplWin32.cpp line 140:

Code: [Select]
int count = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, title.c_str(), static_cast<int>(title.size()), wTitle, sizeof(wTitle) / sizeof(*wTitle));

My question is:
Is this a common problem? How do i use sfml2 or 1.6 with visual studio 2010?
Thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #1 on: April 23, 2010, 09:20:54 pm »
What linker errors did you get? Did you rebuild completely everything with VC 2010?
Laurent Gomila - SFML developer

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« Reply #2 on: April 24, 2010, 12:08:07 am »
Not everything, i left the samples. Just rebuilt the sfml-*  packages.

I was just using Window.hpp so only got a linker error regarding

sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

and App.Display(), IsOpened() and, Close().

If you need the exact message and code i will try to reproduce it.

Thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #3 on: April 24, 2010, 10:15:55 am »
Are you sure that you don't have other versions that may conflict?

If you compile the samples, do you get the same errors?
Laurent Gomila - SFML developer

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« Reply #4 on: April 24, 2010, 10:44:14 am »
Sorry, I didn't explain myself clearly.

I have no problem compiling, just using what i compiled. I compile everything but the samples and got no errors.

When i try to build the first window tutorial i got an error like the one in this post :  http://www.sfml-dev.org/forum/viewtopic.php?t=2478
but instead of errors with string, i got errors with the functions of Window.hpp that i use.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #5 on: April 24, 2010, 10:50:37 am »
It was already clear enough ;)

Stupid question: do you link to sfml-window.lib?

And you should really try to compile the samples, as they are supposed to be configured properly and produce no linker errors.
Laurent Gomila - SFML developer

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« Reply #6 on: April 24, 2010, 01:10:38 pm »
Yes, i did.

I compiled the samples without errors. When i used them they ran flawlessly too. So i copied the code from the sample window to my project and it worked  :shock: I deleted the opengl code and libs and the result was what i had previously, the window tutorial. It ran without a problem... AFAIK there was no change.

This was all in debug mode so i tried it with release mode. I got this error:

Quote
error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z)


I don't think this is equal to the error that brought me here in the first place but i could be wrong.

And now i removed the comments to paste the code, built and it ran without a problem. i didn't change absolutely anything :?

Now it just crashes in release mode, and only if i start without debugging (CTRL + F5). I debug it and it runs perfectly. Only a few times in debug mode i can see it crashes in

Code: [Select]
sf::Window window(sf::VideoMode(640, 480, 32), "SFML Window");

This is getting too strange... These crashes appear almost randomly.
Any ideas?

Incubbus

  • Newbie
  • *
  • Posts: 12
    • ICQ Messenger - 315161720
    • View Profile
    • http://incubbus.eu
SFML2 and Visual Studio 2010
« Reply #7 on: April 24, 2010, 01:23:54 pm »
do they appear to you when u run the exe when not using visual studio to start it?...

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« Reply #8 on: April 24, 2010, 02:26:04 pm »
only if i run the release exe. the debug exe runs as it should.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #9 on: April 24, 2010, 02:30:42 pm »
Do you link to the release libraries in release mode (without the "-d" suffix)?
Laurent Gomila - SFML developer

Pombal

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2 and Visual Studio 2010
« Reply #10 on: April 24, 2010, 02:39:11 pm »
yes

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
SFML2 and Visual Studio 2010
« Reply #11 on: April 24, 2010, 05:29:35 pm »
What about the external dependencies?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #12 on: April 24, 2010, 05:34:48 pm »
They are supposed to work without being recompiled; at least the VC2005 binaries work with VC2008.

But yeah, you can try.
Laurent Gomila - SFML developer

Incubbus

  • Newbie
  • *
  • Posts: 12
    • ICQ Messenger - 315161720
    • View Profile
    • http://incubbus.eu
SFML2 and Visual Studio 2010
« Reply #13 on: April 24, 2010, 07:27:26 pm »
ok... may You please tell us "exactly" what to check and how to set up visual studio for sfml 1.6, please?... I´d be very thankful, since this may help him and me(the lnk-error thread below this one)...

thanks in advance:)...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML2 and Visual Studio 2010
« Reply #14 on: April 24, 2010, 07:32:27 pm »
Nothing more than what the tutorial says. It's the same for every version of SFML and every version of Visual Studio, except that I don't provide precompiled binaries for VC2010 so you have to recompile SFML yourself.

I have no idea what's happening with you :?
Laurent Gomila - SFML developer

 

anything