Jump to content

  • Log In with Google      Sign In   
  • Create Account


Visual Studio 2010 SDL Setup


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 14 July 2010 - 02:33 PM

I am having a lot of problems setting up SDL to control input/drawing. I've looked at several different guides, and so far I've seen a lot of conflicting directions as to what is needed. Is this because of VS 10 is still new...ish? The closest that I got to succesfully installing it ended when I ran into a blank VS config window informing me that that particular option has been deprecated, and my next attempt seemed to have succeeded until I actually attempted to use some functions.

So, now I have just deleted(or at least attempted to) all of the random files that I had copied into various places attempting to setup SDL, and would love if someone could please explain to me what exactly is *required* to succesfully implement SDl.

I noticed that the example solution from a tutorial that I was looking at(made with VS 08) had a folder that contained some(but not all) of the same items as the download from SDL's main site along with another folder for primitive handling functions. So is it necessary to download various function groups separately? and is it necessary to copy the SDL folder to the same directory as each project?

EDIT: Also, is it *better* to create app specific equivalents as opposed to directly using SDL functions? For example...'draw_circle(...)' as opposed to 'SDL_DrawCircle(...).'

Sponsor:

#2 nobodynews   Crossbones+   -  Reputation: 1760

Like
1Likes
Like

Posted 14 July 2010 - 03:33 PM

You say a lot of the steps you took but you didn't really mention any concrete thing you tried along with a concrete description of what exactly failed when you tried it. If you said "I followed so-and-so tutorial (here's a link) and I get these errors" then that gives us something meaty to work with! So, what have you specifically tried?

#3 thade   Members   -  Reputation: 1652

Like
1Likes
Like

Posted 14 July 2010 - 04:54 PM

I actually went through this exact process myself yesterday. I downloaded and installed Visual Studio C++, downloaded SDL for Windows, and banged my head against it for a while. I did get it working, but it took me following several tutorials and some thinking.

First, there's a VisualC.html file you need to read and follow in the SDL directory; it instructs you on how to build the SDL library for Visual C/Windows. You'll want to unzip it (and pay close attention to make sure that there's a Visual C directory with files in it and not a Visual C directory with it's own Visual C subdirectory) and otherwise follow the instructions in that html file. The only thing that caught me here was that I didn't have the DirectX SDK downloaded...and you need it to build SDL for Windows. (If it's complaining about no dxguid.something, that's why.)

When you want to open up the SDL solution to build it, double click on the .sln file, not the .dsw. I don't know why, but one successfully converts to a VS2010 project, and the other does not. (Let it make whatever changes it wishes.)

After I got it built, I got three files out of it. SDL.dll, SDL.lib, and SDLmain.lib. Note where these files are.

Next I followed this tutorial:

http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet2010e/index.php

If you noted where those files were, you know what directories to add when you add to the library path.

Finally, each time you make a program using the SDL, you need to put a copy of SDL.dll in the directory with the source code. (You can use either the one you built - which I presume has debug information in it due to it's size - or the one for release versions which is smaller. I recommend the first.) You *can* put the SDL.dll in your SYSTEMx directory, but this may come to haunt you later if there's ever an update. Just stick it in your source directories as needed.


If none of this helps, as nobodynews says, we need more to go on. <3

EDIT: I forgot a small part.

#4 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 14 July 2010 - 05:52 PM

Thank you for the time, I repeated(and documented) my failure via the method you described in an excessively large picture...

fail

I thought that maybe I was reading it wrong somehow and copied all of the files in VisualC directly into the folder with the instruction file but had very similar results with both projects. I'm expecting to have overlooked something obvious and having spent several hours on this now...this seems extremely embarassing.

EDIT: I'm downloading/installing DirectX at the moment to try again, but I never saw the error message that you mentioned.
EDIT:: Same result sadly.

#5 thade   Members   -  Reputation: 1652

Like
1Likes
Like

Posted 14 July 2010 - 06:06 PM

It was the DirectX SDK I was referring to; if you search for DirectX SDK, it'll (likely) be the first link (on msdn.microsoft.com or some such).

So, we have a massive picture. Now, narrate for us, step by step, what you did. =) I have several guesses, and they all have very different solutions (and perhaps all of my guesses are wrong).



#6 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 14 July 2010 - 06:31 PM

Ok, I'll try my best to describe my thought processes...

First I went to http://www.libsdl.org/download-1.2.php and downloaded the third/last link under source code "SDL-1.2.14.zip" and saved it to the desktop.

Then I saved the second link, "SDL-devel-1.2.14-VC8.zip", under 'Development Libraries:/Win32'.

Unzipped both, then extracted the 'VisualC' subfolder into the other extracted folder where the html telling me to do <- was located.

Then I opened the solution file in the VisualC folder, let it convert to Vs10, and then right-clicked and selected build on the projects 'SDL' and 'SDLmain.' The picture only shows the errors from the first build, but a similar list was shown for the second as well.

I will try to install SDK now and hopefully learn what sdk stands for in the process.
EDIT: Is it Standard Development Kit? If so, I am an awesome guesser.
EDIT:: Software damn, close. Well I think I would remmeber if I had downloaded 571 mb before so I assume this was my problem but will find out in....15 minutes, if it is, thank you in advance.
EDIT::: Sadly, no change, but at least now I have the latest SDK and whatever benefits that may include...
EDIT:::: Completely off topic, but is it better to use '#pragma once' or '#ifndef''#define'---'#endif'? The former seems obviously better to me but every single tutorial(and VStudio default) that I've seen uses the latter.
EDIT::::: Also, what happens if you don't call 'SDL_Quit'/free memory etc before you exit?

[Edited by - wioneo on July 15, 2010 1:31:03 AM]

#7 thade   Members   -  Reputation: 1652

Like
1Likes
Like

Posted 15 July 2010 - 02:47 AM

So, I googled "fatal error c1083 cannot open source file" (something I recommend you do) and determined (perhaps as you have) that VS can't find the source files that the project want it to build. Simple answer is you unzipped it improperly, though I can't guess how. Or perhaps there is some limit to how many subdirectories VS can deal with (which would be weird, but not unheard of).

I did everything you did, except I put the SDL folder in the root directory of one of my drives, so there's only two directories or so between the root and the src. If you're trying to build this from the Desktop, there are many, many more.

As for what to do...barring any sage advice from another user, I'd personally grit my teeth and clean it all up. Start again from scratch. (You probably needn't re-install VS, but I'd scrub all the SDL stuff.)

Try SDL-devel-1.2.14-VC6.zip; that's the one I used, I'm pretty sure.

In answer to your off-topic questions:
- pragma is platform-specific (won't work everywhere); ifndef works on any system. I use the latter out of habit, myself, so I can't speak to pragma from experience.
- If your program exits without deallocating all of it's object instances, it's usually not a big deal (if the process is a stand-alone, anyway). Once it's memory is given back to the OS, it's going to get dealloc'd anyway. However, not calling SDL_Quit might not release other resources (video hardware, for instance) that should be released. This may clean itself up, but it may not. If you're worried about multiple exit points or something, do this:

atexit(SDL_Quit);

right after you call SDL_Init(). That'll register SDL_Quit() to happen as the program exits.

#8 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 15 July 2010 - 10:51 AM

Ok I see my problem now, everything that I downloaded beside the original link under source was completely useless, and there are 2 VisualC.html's in 2 separate(one useless) directories.

That said, I'm now getting the error that you mentioned...

...
1> SDL_yuv.c
1> SDL_yuv_sw.c
1> Generating Code...
1>LINK : fatal error LNK1104: cannot open file 'dxguid.lib'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:15.54
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

...which is irritating, but googleable.

EDIT: added to the lib list in properties and it builds now.
EDIT:: Why did Microsoft take out the directories setting that I see in old tutorials? That seems to be so much less complicated than the current method.

[Edited by - wioneo on July 15, 2010 5:51:30 PM]

#9 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 15 July 2010 - 04:47 PM

Ok, now my problem with setup and everythign is solved, but I have one unanswered question...

Is there a list of libraries such as "SDL_Gfx" that describes their contents? I would rather assemble everything potentially useful in one go instead of gradually. So far I've only found the Gfx library by itself, which elads me to believe that it might be theonly one of thats pecific type.

I also noticed that there are no SDL (named) libraries in the library list on SDL's main site, am I missing something? Or is the Gfx library third party?

EDIT: Now I'm reading that the "export template" button in VS 10 is just for show and perpetually grayed out, and that to actually use the feature you need to create a wizard, using the wizard creation wizard, that creates project templates. That's just far too much idiocy packed into one file menu option.

[Edited by - wioneo on July 15, 2010 11:47:14 PM]

#10 nobodynews   Crossbones+   -  Reputation: 1760

Like
1Likes
Like

Posted 16 July 2010 - 02:09 PM

Quote:
Original post by wioneo
EDIT:: Why did Microsoft take out the directories setting that I see in old tutorials? That seems to be so much less complicated than the current method.
It might be because of the switch from VCBuild to MSBuild. There's also an argument to be made that libraries should be configured per-project instead of per-IDE installation. What if you want to use different versions of the same library in different projects? Harder to do that in VS 2008, I believe (I've not used Visual C++ 2010 much or multiple versions of the same library ever so I'm not certain).

Quote:
Original post by wioneo
Is there a list of libraries such as "SDL_Gfx" that describes their contents?
I'm not sure what you mean. You've looked here? All it does is let you search for SDL-based libraries. The only "catogories" provided are "other", "graphis", "interface", "sound", and "C++ API". That's probably the best you'll find except for perhaps Lazy Foo's tutorials which talk about some popular libraries.

Quote:
I would rather assemble everything potentially useful in one go instead of gradually.
Why not do it gradually? You might benefit from reading about YAGNI.

Quote:
Now I'm reading that the "export template" button in VS 10 is just for show and perpetually grayed out, and that to actually use the feature you need to create a wizard, using the wizard creation wizard, that creates project templates. That's just far too much idiocy packed into one file menu option.
It's probably 'just for show' with Visual C++ only. I bet if you had a C# project that option would work just fine. There's probably a decent reason for that particular functionality to be unavailable with Visual C++ but I admit I can't think of one off hand.

#11 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 16 July 2010 - 02:18 PM

I clicked to check this topic and there wer eno replies, then during the 5 seconds it took to load the main forum you posted...strange.

Anyways...Yagni is completely the opposite of the way I live my life lol.

Personally I usually make a list of things that I need beforehand(like loading images, rotating images, and keyboard input, for tetris), rotating bit particularly was why I was looking at the gfx libraries.

#12 nobodynews   Crossbones+   -  Reputation: 1760

Like
1Likes
Like

Posted 17 July 2010 - 11:12 AM

Quote:
Original post by wioneo
Personally I usually make a list of things that I need beforehand(like loading images, rotating images, and keyboard input, for tetris), rotating bit particularly was why I was looking at the gfx libraries.
Doing this is a big part about not doing what you don't need. You collect your requirements and you find tools that will help you fulfill those requirements. You don't say "hmm, maybe someday I'll want to do Z so I'll get a library and write code for it... even though for now I only want to do W, X, and Y". You obviously need to load images, and get input. But rotating is one of those things that you probably don't actually need in tetris.

If you're thinking "I want to rotate the piece so I need to rotate an image" you are probably going about tetris the hard way. A piece is composed of some squares arranged in a grid (4x4 for every piece). You can either rotate the location of squares in the grid using some algorithm or you can just make a 4x4x4 array for each piece. The last dimension will hold all 4 possible rotations for each piece.

Ok, but now let's say you do need image rotation for some other reason. While the library you mention, SDL_gfx, does contain an image rotation library I've heard it's very slow. Basically, it's not hardware accelerated. What I've read indicated that it should mainly be used to pre-rotate images instead of rotating them on-the-fly. Rather than saying "I would like to rotate this image by 25 degrees because the user just hit the left arrow" you would say "I will take this image and rotate it in 5 degree increments and store all of those rotations in memory. Then, when the user hits the left arrow I will grab the 25 degree rotated image from memory". This method does take more memory than rotating on-the-fly, but memory will probably not be your bottleneck for most 2D games.

Hope this helps.

#13 wioneo   Members   -  Reputation: 110

Like
1Likes
Like

Posted 17 July 2010 - 09:26 PM

Thank you for taking the time to pass on all of that advice. I ended up going with a massive array instead of rotation, in all honesty though, that was mostly because I couldn't figure out how to setup this other library :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS