Skip to main content
GameDev.net gamedev.net
🔒 Locked

bitmap resources in a library?

Started by mayonaise Nov 3, 2004 at 4:18 PM 8 replies 550+ views
Original Post
mayonaise
mayonaise
I wrote a program that included a bitmap resource. The program ran fine and used the resource on it's own. Now, however, i've converted this standalone program to a static library (.lib) so i can use create it, and run it from an MFC GUI. when i run it from the GUI, however, the resource cannot be found. I'm pretty sure the library is including the resource when it builds, because if i remove it entirely from the project, the filesize of the library shrinks about 1 mb (about the size of the bitmap). The compiled GUI program, however, does not show the same change in filesize. how can i preserve the bitmap resource in a library when i link to it from another program??
mayonaise
mayonaise
bump..

anyone have any ideas at all?
daerid
daerid
Ummm... only .exe's and .dll's can have embedded resources.

A static lib doesn't have a resource section, so I don't think you can have embedded resources in libs
daerid@gmail.com
mayonaise
mayonaise
Quote:
Original post by daerid
Ummm... only .exe's and .dll's can have embedded resources.

A static lib doesn't have a resource section, so I don't think you can have embedded resources in libs
can you recommend how i should continue? what i have is a class compiled into a library so that it can be used with other programs.. this class needs to be able to display a default bitmap if none is given to it. when it was a standalone program, embedding a resource was easy enough. i've never used DLLs before, however, but it seems like that is the way to go?

thanks for the response!
chollida1
chollida1
Most programs use resource DLL's or, not as nice solution, put them in the exe. The resource DLL is nice because you can easily have multiple resource DLL's if you translate your programs.

MFC has a nice resource DLL setup if your using it.

Cheers
Chris
CheersChris
mayonaise
mayonaise
Quote:
Original post by doynax
Static libraries can have resources. It does introduce some new complexities though and the dialog editor probably won't like it.
Including resources in Static Library projects
thanks for the link.. but unless i'm doing something wrong, this technique isn't working with bitmaps. i'm following everything step by step (with the exception of creating a new resource script, because the static library already has one).. the filenames and identifiers are all unique, the bitmap file does exist, and i included the static library's resource script and .h file into the main program's resources.

when i build, the main program complains that it can't find the bitmap, however. the static library doesn't doesn't have this problem. if i copy the bitmap into the main program directory, it stops complaining... i do not think this is the source of the problem.
doynax
doynax
Quote:
Original post by mayonaise
when i build, the main program complains that it can't find the bitmap, however. the static library doesn't doesn't have this problem. if i copy the bitmap into the main program directory, it stops complaining... i do not think this is the source of the problem.
You have to add the library's data directory to the main project as an additional resource path.

So I guess the data isn't actually included in the static library itself. However it's still a useful technique when you need share resources between multiple projects.

Back to my Naruto marathon =)
mayonaise
mayonaise
Quote:
Original post by doynax
Quote:
Original post by mayonaise
when i build, the main program complains that it can't find the bitmap, however. the static library doesn't doesn't have this problem. if i copy the bitmap into the main program directory, it stops complaining... i do not think this is the source of the problem.
You have to add the library's data directory to the main project as an additional resource path.

So I guess the data isn't actually included in the static library itself. However it's still a useful technique when you need share resources between multiple projects.

Back to my Naruto marathon =)
well i managed to get it to work, although i'm not sure how. i must have just *thought* i changed a project setting the first time, when in fact i didn't.

thanks a lot, tho! really appreciate the help!

edit: i went back to do a few tests on the project settings. in the "Additional Include Directories" setting (VC++7.1), adding the path to the directory where the bitmap is isn't sufficient. unless you're referring to a different setting, the bitmap needs to be copied into the directory of the main program as well.
doynax
doynax
Quote:
Original post by mayonaise
edit: i went back to do a few tests on the project settings. in the "Additional Include Directories" setting (VC++7.1), adding the path to the directory where the bitmap is isn't sufficient. unless you're referring to a different setting, the bitmap needs to be copied into the directory of the main program as well.
It needs to be added as a resource include directory, not as a preprocessor one. In VC6 it's at the resource tab of the project settings.
I'm looking at a working project with a foreign resource directory right now, so it's got to be possible.

Topic Locked

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

Sign in to reply to this topic.