This is a bit tricky:
You have to force symbol references to the readers as the linker optimizes them out. To get your symbols, use the "dumpbin" tool which comes with VC7 and is located in the same dir as cl.exe.

dumpbin /LINKERMEMBER:1 OSGSystemLnk.lib

The symbol reference we want to force is the one to the static "the" variable of the reader. So filter the output of dumpbin with grep (cygwin) or find (cmd):

(I just discoverd that I accidentally compiled OpenSG without jpeg support the last time, so I did the following example for PNG)

dumpbin /LINKERMEMBER:1 OSGSystemLnk.lib | grep the | grep PNGImageFileType

This leads to the symbol name
[EMAIL PROTECTED]@osg@@[EMAIL PROTECTED]

The easiest way to tell the linker about a forced symbol references is a #pragma in a sourcefile (probably the one you load your images in):
#pragma comment(linker, "/include:[EMAIL PROTECTED]@osg@@[EMAIL PROTECTED]");

The Symbol names may differ with your compiler (I use cl.net2003), so you should to do your own dumpbin-run.

Hope that solves your problem!

Regards,
Thomas


Hi,

I want to use OpenSG as a static lib to link to my program. I managed to
compile BaseLib and SystemLib statically in VS7. Therefore I changed the
runtime library to multithreaded-debug and removed every OSG_BUILD_DLL
macro from the project. The libs build fine and I can link to it. But
whenever I want to read an image or load an object from a vrml file the
app crashes. I managed to follow the crash to this line:

bool ok = ImageFileHandler::the().read(iPtr, fileName);
in bool Image::read(const Char8 *fileName)
in the file osgimage.cpp

Same with the SceneFileHandler. Is there a way to fix this? What's going
wrong anyway? I know, it must have something to do with the static
linking, cause when I link to the DLLs my code works fine. Do I have to
add a hidden linker flag or some another macro definition?

Thanks for helping me!
Martin




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to