SFML community forums

Help => Window => Topic started by: bnz on January 21, 2010, 08:15:06 pm

Title: Question on window tutorial
Post by: bnz on January 21, 2010, 08:15:06 pm
Hello,

I'm new to SFML and also quite new to C++ in general, so I tried the official tutorials as a start.
However I'm now stuck at the tutorial on creating windows (http://www.sfml-dev.org/tutorials/1.5/window-window.php). I compiles fine (using MSVC++ 2010 beta2 and the code included in the tutorial), but when I start the application I get the following message:
"Unhandled exception at 0x75f19f11 in SFML Window.exe: 0xC0000005: Access violation reading location 0x6e695720."

When I start the exe directly from the Windows Explorer it simply says that the exe doesn't work anylonger.
I'm using Windows 7, by the way.

Do I need Qt or wxWidgets to succesfully run this program? Do you have any idea what I'm doing wrong?

Thanks,
bnz
Title: Question on window tutorial
Post by: Mr. X on January 21, 2010, 08:59:32 pm
Have you linked the correct Libs? (-d for Debug)...
Title: Question on window tutorial
Post by: bnz on January 21, 2010, 09:20:35 pm
Yes, at least I think so.
Here are two screenshots of the properties:
(http://www4.pic-upload.de/thumb/21.01.10/u6zmzcckdrlh.jpg) (http://www.pic-upload.de/view-4328457/kljhk.jpg.html) (http://www4.pic-upload.de/thumb/21.01.10/bvxbh3mmpoa.jpg) (http://www.pic-upload.de/view-4328458/Unbenannt.jpg.html)
In the folder, where the executable is located, I added the sfml-window-d.dll and the sfml-system-d.dll.

bnz
Title: Question on window tutorial
Post by: Flawe on January 21, 2010, 11:46:28 pm
You're linking only to window and main, not system. Add sfml-system-d.lib to the list.
Title: Question on window tutorial
Post by: bnz on January 22, 2010, 10:03:23 am
Unfortunately that didn't change anything.
The exeption is thrown at the following line:
Code: [Select]
sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

By the way: Why did I have to link to smfl-system-d? Wouldn't the compiler complain if something was missing?

bnz

EDIT: Just for the fun of it, I tried to link to the non-debug versions of the librarys and after copying the needed dlls into the executable's folder it worked.
I hope this gives you some clues, why it is not working with the debug versions.

bnz
Title: Question on window tutorial
Post by: Laurent on January 22, 2010, 10:12:49 am
You should recompile SFML with your Visual Studio 2010. VS versions are highly incompatible, and the SFML SDK only provides precompiled binaries for VS 2005 and 2008.
Title: Question on window tutorial
Post by: bnz on January 22, 2010, 10:16:35 am
Oh, okay.
I will try that this evening.

Thanks,
bnz
Title: Question on window tutorial
Post by: bnz on January 22, 2010, 06:40:54 pm
Well, I just tried to build SFML with Visual Studio 2010 beta2 and I'm quite lost. =)
Following the tutorial does not really work or at least I'm not doing it right.
When I open the SFML.sln, the "Visual Studio Conversion Wizard" starts and wants to convert the project. When I then select the whole solution, containing 18 projects, and select "Build" it does something, but I actually have no clue what it does or how I could manipulate it.
It also seems strange that the projects contains sub-projects like "pong" or "wxwdgets".

Well, as you see I am a little confused and it would be great, if you could give me a pointer on how to compile SFML correctly, so that I have all needed files (all .dll and .lib files with all the different endings) at the end.

Thanks,
bnz
Title: Question on window tutorial
Post by: Laurent on January 22, 2010, 09:59:59 pm
Quote
When I then select the whole solution, containing 18 projects, and select "Build" it does something, but I actually have no clue what it does or how I could manipulate it

Do you have the "output" tab opened? What messages does it show?

Quote
It also seems strange that the projects contains sub-projects like "pong" or "wxwdgets".

It's not sub-projects, I just put them in virtual folders to separate between SFML libraries and example applications.

Quote
Well, as you see I am a little confused and it would be great, if you could give me a pointer on how to compile SFML correctly, so that I have all needed files (all .dll and .lib files with all the different endings) at the end.

It should really not be harder than clicking on "build" (after selecting the configuration that you want to build) ;)
Title: Question on window tutorial
Post by: bnz on January 22, 2010, 10:45:09 pm
I think now I got it! Well, almost.

The problem was, that I did not exactly know where to look for the files, now I realized that they are directly created in the correct folder. =)

So in the end it was really not harder than "clicking on "build"", as you said. ;)

Now to the reason I said "almost":
When compiling the Release DLLs it says:
Rebuild All: 1 succeeded, 5 failed, 12 skipped

But all files are there. Could that be a problem?

bnz

EDIT:
Still one problem: How can I create the "sfml-xxx-d.lib" files? I only can choose between Debug DLL (sfml-xxx-d.dll) and Debug static (sfml-xxx-s-d.lib).
Title: Question on window tutorial
Post by: Laurent on January 22, 2010, 11:13:37 pm
Quote
When compiling the Release DLLs it says:
Rebuild All: 1 succeeded, 5 failed, 12 skipped

But all files are there. Could that be a problem?

The 5 projects that fail are probably samples. You can easily see that in the output tab.

Quote
How can I create the "sfml-xxx-d.lib" files? I only can choose between Debug DLL (sfml-xxx-d.dll) and Debug static (sfml-xxx-s-d.lib).

Hmm, you should also have "Release static" and "Release DLL". Maybe something went wrong with the conversion wizard?
Title: Question on window tutorial
Post by: bnz on January 22, 2010, 11:41:56 pm
Quote
Hmm, you should also have "Release static" and "Release DLL". Maybe something went wrong with the conversion wizard?

Sorry, I was a bit imprecise here.

I meant that "Debug DLL" and "Debug static" are the only two "debug modes" that I can choose between. I assume that for the "sfml-xxx-d.lib" I need a simple "Debug", like the one I can choose for the "sfml-main" project.

There are also "Release static" and "Release DLL" but none of them results in "sfml-xxx-d.lib" files.

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 10:15:32 am
No no, sfml-xxx-d.lib is the dynamic debug version.

Suffixes are defined so that "-d" is debug and "-s" is static (release and dynamic have no suffix).
Title: Question on window tutorial
Post by: bnz on January 23, 2010, 01:04:40 pm
Okay, but how can I create the "sfml-xxx-d.lib" files?
Here are some screenshots, that show all different configurations I tried:
(http://www4.pic-upload.de/thumb/23.01.10/t6lzr7ydmul.jpg) (http://www.pic-upload.de/view-4343428/cfg1.jpg.html) (http://www4.pic-upload.de/thumb/23.01.10/31xvymr8teos.jpg) (http://www.pic-upload.de/view-4343429/cfg2.jpg.html) (http://www4.pic-upload.de/thumb/23.01.10/r6wqhfupjbsd.jpg) (http://www.pic-upload.de/view-4343430/cfg3.jpg.html) (http://www4.pic-upload.de/thumb/23.01.10/3v6ug917xom.jpg) (http://www.pic-upload.de/view-4343431/cfg4.jpg.html)

And these are the resulting files:
(http://www4.pic-upload.de/thumb/23.01.10/vcd4qzmuuk5w.jpg) (http://www.pic-upload.de/view-4343432/files.jpg.html)

(By the way: Can I delete the .ilk files? )
As you see, the "sfml-xxx-d.lib" files are missing.

Since this is the first library I have to compile by myself, please forgive my, if my questions are trivial. =)

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 02:09:47 pm
You don't change the current active configuration in this window (this is the solution's properties, I almost never go there), you just setup which configuration for each project correspond to the "global" configuration (the one in the top-left corner). Like I said, you don't have to do such complicated things to build SFML ;)

To actually select the configuration to build, you should have a combobox in the toolbar.
Title: Question on window tutorial
Post by: bnz on January 23, 2010, 03:14:36 pm
Quote
To actually select the configuration to build, you should have a combobox in the toolbar.

So when I simply change select another build mode in the dropdown menu, framed red in the following picture, it should build the correct files?(http://www4.pic-upload.de/thumb/23.01.10/6v63e2xh44ft.jpg) (http://www.pic-upload.de/view-4344770/Unbenannt.jpg.html)

Because I tried that. I built in "Debug", "Debug DLL", "Debug static", "Release", "Release DLL" and "Release static" mode and I still didn't get the "sfml-xxx-d.lib" files. The only -d.lib file I get, is "sfml-main-d.lib".

So just to make sure I'm doing everything correctly, I'm going to list the single steps:
Is it correct that "sfml-xxx-s-d.lib" files are created, when I only select "Debug" as build mode? Because when I afterward select "Debug static" as build mode, it says that the 6 files were already up-to-date.

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 05:17:52 pm
You should never select "Debug" or "Release" (they exist only for samples). I think that it maps to the static configurations for the SFML libraries (which answers your last question).

- Debug static produces sfml-xxx-s-d.lib files
- Debug dynamic produces sfml-xxx-d.lib (and .dll) files
- Release static produces sfml-xxx-s.lib files
- Release dynamic produces sfml-xxx.lib (and .dll) files
Title: Question on window tutorial
Post by: bnz on January 23, 2010, 05:34:40 pm
I think I'm getting closer.  :D
Quote
Debug dynamic produces sfml-xxx-d.lib (and .dll) files

With "Debug dynamic" you mean "Debug DLL", right?
Because, if so, it produces sfml-xxx-d.dll files and sfml-xxx-d.ilk files, not sfml-xxx-d.lib files.
Is there maybe a setting, which changes the file ending from .ilk to .lib (or can I simply do so by myself :) )?

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 05:39:30 pm
Quote
With "Debug dynamic" you mean "Debug DLL", right?

Yep, sorry.

Quote
Because, if so, it produces sfml-xxx-d.dll files and sfml-xxx-d.ilk files, not sfml-xxx-d.lib files.

You can ignore .ilk files, they are for debugging.
Maybe something was changed or lost during the conversion. Have you searched the .lib files in other directories?
You can also check one option in any SFML project: "Linker" -> "Advanced" -> "Import library" -> this should be the path and name of the produced .lib file.
Title: Question on window tutorial
Post by: bnz on January 23, 2010, 06:32:45 pm
Then I guess something went wrong during conversion, because  "Linker" -> "Advanced" -> "Import library" is empty.
The follwing picture shows the situation:
(http://www3.pic-upload.de/thumb/23.01.10/4jwnde14yd.jpg) (http://www.pic-upload.de/view-4347425/pic.jpg.html)

I don't know if this is of any help, but here is the Build-Log of the build with "Debug DLL" setting: BuildLog.txt (http://www.file-upload.net/download-2189402/BuildLog.txt.html)

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 06:37:30 pm
Quote
Then I guess something went wrong during conversion, because "Linker" -> "Advanced" -> "Import library" is empty.

Weird. Anyway, try to put "$(TargetDir)$(TargetName).lib" there.
Title: Question on window tutorial
Post by: bnz on January 23, 2010, 06:51:00 pm
(http://www3.pic-upload.de/thumb/23.01.10/mx21zzbui.jpg) (http://www.pic-upload.de/view-4347629/pic.jpg.html)

I changed the properties of every sfml project to the above, but it still doesn't produce the sfml-xxx-d.lib files.

bnz
Title: Question on window tutorial
Post by: Laurent on January 23, 2010, 11:49:22 pm
What does the build log say?
Title: Question on window tutorial
Post by: bnz on January 24, 2010, 12:01:35 am
I uploaded the new build log here (http://www.file-upload.net/download-2190504/BuildLogNew.txt.html).

For my taste there are too many fatal errors and warnings, but I don't know in how far this is "normal".

bnz
Title: Question on window tutorial
Post by: Laurent on January 24, 2010, 12:44:36 am
There are two interesting things:

Quote
Creating library C:\Users\bnz\Downloads\SFML-1.5-sdk-windows-vc2008\SFML-1.5\Temp\vc2008\sfml-network\Debug DLL\sfml-network.lib

--> this is where the .lib files are created

Quote
warning MSB8012: TargetName(sfml-network) does not match the Linker's OutputFile property value (sfml-network-d). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

--> that seems to be the problem

I don't know what happens here, but it seems to be related to some new stuff in VS 2010.
Title: Question on window tutorial
Post by: bnz on January 24, 2010, 01:14:02 am
So what would you suggest to do?
Is there another way to compile the library?

bnz
Title: Question on window tutorial
Post by: Laurent on January 24, 2010, 05:37:52 pm
I'm not familiar at all with VS 2010 and MSBuild, so I'm affraid I can't help you further, sorry.

But you should find the lib files in "C:\Users\bnz\Downloads\SFML-1.5-sdk-windows-vc2008\SFML-1.5\Temp\vc2008\sfml-network\Debug DLL", don't you?
Title: Question on window tutorial
Post by: bnz on January 24, 2010, 06:16:37 pm
Quote
But you should find the lib files in "C:\Users\bnz\Downloads\SFML-1.5-sdk-windows-vc2008\SFML-1.5\Temp\vc2008\sfml-network\Debug DLL", don't you?

Yes, I do.
For now, I simply renamed them to "sfml-xxx-d.lib", and it seems to work fine, finally. =)

Thanks for all your patience, help and of course for this great library! I just continued with the tutorial and I am stunned how easy things are!

I guess, when Visual Studio 2010 goes out of beta, you will provide precompiled files, as for VS 2008?

bnz
Title: Question on window tutorial
Post by: Laurent on January 24, 2010, 06:33:38 pm
Quote
For now, I simply renamed them to "sfml-xxx-d.lib", and it seems to work fine, finally. =)

Renamed to what? They seem to have the right name, from the build log.

Quote
I guess, when Visual Studio 2010 goes out of beta, you will provide precompiled files, as for VS 2008?

Probably :)
Title: Question on window tutorial
Post by: bnz on January 24, 2010, 06:46:31 pm
Quote
Renamed to what? They seem to have the right name, from the build log.

The only .lib files I could find in the directory you mentioned were called "sfml-xxx.lib". The suffix "-d" was missing, so I went ahead and added it. =)

bnz
Title: Question on window tutorial
Post by: Laurent on January 24, 2010, 06:50:20 pm
Ah, you're right :)