• Advertisement
Sign in to follow this  

Simple question

This topic is 2085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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. Edited by dAND3h

Share this post


Link to post
Share on other sites
when i try that i get a error saying that it cannot open include file SDL.h, how do i fix that?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
I have in VC++ Directories, I have the location of my SDL folder, the code compilers fine in debug but not release still

Share this post


Link to post
Share on other sites
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???

Share this post


Link to post
Share on other sites
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. Edited by Dragonsoulj

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. Edited by Fredericvo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement