Skip to main content
gamedev.net
🔒 Locked

Simple question

Started by Canvas 12 replies 1.7k views
Original Post
Canvas
Canvas
Hey guys, I have started to create a project with Visual studio express 2010 version C++, I have some external DLL (SDL and SDLimage), Now how do i go about actually created a compiled exe from my project? so i can give my exe and dlls to someone else, so they can use my program, i dont want to the images or have the source code, just the exe, anyone know a simple guide or simple steps to take?

Cheers

Canvas
dAND3h
dAND3h
Build -> Configuration Manager -> Active solution Configuration...set this to release.

Rebuild all/Build solution.

You will then find the newly created release folder inside the bin folder in your projects solution directory. This contains your .exe.
BeerNutts
BeerNutts

when i try that i get a error saying that it cannot open include file SDL.h, how do i fix that?


You need to include the path to SDL.h into your include directory search. There should be an option somewhere in the Build Configuration (I haven't used Visual Studio in a while). Just point it to your SDL include folder.
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)
Dragonsoulj
Dragonsoulj
If I remember right, your release version needs these to be set again. You probably set them for debug and it goes away when you switch. I think it is under Project->Project Options.
Robbie Woods
Robbie Woods
I think release uses different .lib files to debug so you need to add those rather than the debug ones
Canvas
Canvas
yep i have fixed my release, but i also have a small problem, my program uses gif's, now i dont want a user to edit them, how can i convert them to a format then decompile them in my code then feed that decompressed file to SDLimage???
Dragonsoulj
Dragonsoulj
Photoshop can save a C file. I've never tried using the actual file, but I have saved with it to see what it generates.

EDIT: May have been GIMP. I know one of them did.
Fredericvo
Fredericvo

yep i have fixed my release, but i also have a small problem, my program uses gif's, now i dont want a user to edit them, how can i convert them to a format then decompile them in my code then feed that decompressed file to SDLimage???

I use the resource compiler to embed binary assets.
Fredericvo
Fredericvo
I'm not familiar with SDL but a quick google led me to understand that the key to loading from memory instead of external files is to use SDL_LoadBMP_RW() instead of SDL_LoadBMP(). It wants a pointer rather than a filename and this is what a resource can return to you. I'm on my iPhone right now so I don't have access to one of the source files in which I use them but you can start out reading about FindResource, LoadResource, LockResource on MSDN. Have you ever used resources for icons or menus? It's with these that you can easily add binary files to your exe as well.
I'll post some example from my pc tomorrow if you can't find out by yourself.
Fredericvo
Fredericvo
OK I'm back on my PC.
Let's say yo want to embed an image, image.bmp into an exe file
First you need to create a small text file named i.e. assets.rc
This file should contain the following

#define RT_RCDATA 10

101 RT_RCDATA image.bmp
102 RT_RCDATA image2.bmp
103 RT_RCDATA image3.bmp
...

Open a command line in your C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
and issue the following first: vcvars32.bat (without this it can't find the path to rc.exe)
Then issue: rc assets.rc from the dir where assets.rc which you just created lives. For simplicity sake put it in the bin dir where you just issued vcvars32.bat

If you successfully managed the instructions above you should now have an assets.res file (maybe also assets.obj)
This one should be linked by your linker with your whatever.cpp file.
i.e. from the command-line I usually isse the following cl myprog.cpp assets.res and it will link both files.

If this succeeded you still need a way for your code to find the resource and point to it.

Yo need to create a few variables first:
HRSRC hres=NULL; //you can of course name them anything you like
HGLOBAL hgbl=NULL;
DWORD numbytes=0;
VOID *pimage;
hres = FindResource(hInst, MAKEINTRESOURCE(102), MAKEINTRESOURCE(10)); // suppose you wanted the second image (second param should always be 10 for custom binary (RT_RCDATA))
hgbl = LoadResource(hInst,hres);
numbytes = SizeofResource(hInst, hres); // optional if you need the "file" length
pimage = LockResource(hgbl);

pimage from now on is the pointer which you can feed SDL_LoadBMP_RW()
This function has a second parameter which I don't know the use for since,like I mentioned, I'm not familar with SDL.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.