SFML community forums

Help => General => Topic started by: Pombal on April 23, 2010, 09:13:24 pm

Title: SFML2 and Visual Studio 2010
Post by: Pombal 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
Title: SFML2 and Visual Studio 2010
Post by: Laurent on April 23, 2010, 09:20:54 pm
What linker errors did you get? Did you rebuild completely everything with VC 2010?
Title: SFML2 and Visual Studio 2010
Post by: Pombal 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.
Title: SFML2 and Visual Studio 2010
Post by: Laurent 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?
Title: SFML2 and Visual Studio 2010
Post by: Pombal 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.
Title: SFML2 and Visual Studio 2010
Post by: Laurent 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.
Title: SFML2 and Visual Studio 2010
Post by: Pombal 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?
Title: SFML2 and Visual Studio 2010
Post by: Incubbus 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?...
Title: SFML2 and Visual Studio 2010
Post by: Pombal on April 24, 2010, 02:26:04 pm
only if i run the release exe. the debug exe runs as it should.
Title: SFML2 and Visual Studio 2010
Post by: Laurent on April 24, 2010, 02:30:42 pm
Do you link to the release libraries in release mode (without the "-d" suffix)?
Title: SFML2 and Visual Studio 2010
Post by: Pombal on April 24, 2010, 02:39:11 pm
yes
Title: SFML2 and Visual Studio 2010
Post by: panithadrum on April 24, 2010, 05:29:35 pm
What about the external dependencies?
Title: SFML2 and Visual Studio 2010
Post by: Laurent 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.
Title: SFML2 and Visual Studio 2010
Post by: Incubbus 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:)...
Title: SFML2 and Visual Studio 2010
Post by: Laurent 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 :?
Title: SFML2 and Visual Studio 2010
Post by: Incubbus on April 26, 2010, 02:07:50 am
If I want to run the sample from the documentations first page... what libs do i have to include and which macros to define?...

i get way over 250 errors... 51 unresolved external symbols...

e.g.:Error   311   error LNK2001: unresolved external symbol "__declspec(dllimport) bool __cdecl std::operator==<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (__imp_??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z)   C:\Users\Incubbus\Documents\Visual Studio 2010\Projects\Zeros-Test\Zeros-Test\sfml-graphics-s-d.lib(ImageLoader.obj)
Title: SFML2 and Visual Studio 2010
Post by: Incubbus on April 26, 2010, 03:01:36 am
ok... somehow the compilation and linking succeeds...

but then when the console window does appear there is an system error telling me that the sfml-audio.dll does not exist (and hell it does)...
Title: SFML2 and Visual Studio 2010
Post by: Incubbus on April 26, 2010, 02:59:17 pm
i think im going back to DirectX... it seems way easier to get it running ^^...
Title: SFML2 and Visual Studio 2010
Post by: Laurent on April 26, 2010, 03:09:41 pm
Quote
but then when the console window does appear there is an system error telling me that the sfml-audio.dll does not exist (and hell it does)...

If it says so, it must be right... ;)

Is this DLL in a directory contained in the PATH evironment variable, or in the same directory as the executable?
Title: SFML2 and Visual Studio 2010
Post by: Incubbus on April 26, 2010, 03:46:08 pm
Quote
Is this DLL in a directory contained in the PATH evironment variable, or in the same directory as the executable?


It is in an directoy on my desktop and I did make an entry in the VC-Directories property page

On the following screenshot I show the property pages setting, the error(im sorry - its in german, but it says:
Quote
The program can not be started, because sfml-system-s-d.dll is missing on the system. Please reinstall the application...


(http://www.incubbus.eu/sfml.jpg)[/code]


EDIT: I even did redownload the sfml-package...


EDIT 2: If i copy the dll into the exe-directory and retry running the application, there does occur an application error, that says:
Quote
The Application could not start correctly (0xc0150002). Click "OK" to close the Application.
[/b]
Title: SFML2 and Visual Studio 2010
Post by: Incubbus on April 28, 2010, 12:17:53 am
and... any clues?...
Title: SFML2 and Visual Studio 2010
Post by: lukaszw on June 12, 2010, 11:12:54 am
I had the same problem as it's shown  at the first post. To solve it I recompiled the SFML solution in configuration Release DLL witht runtime library set to Multu-threaded DLL. And now - it works!
Title: SFML2 and Visual Studio 2010
Post by: Zweistein on June 12, 2010, 06:04:05 pm
through you pragma comment the -s-d lib, why does he want a dll???

Try to put that specific dll in the project homedirectory. it should be where the *.sln file is.