[osg-users] OSG2.4 and 2.5.5 Windows static build problems

Christiansen, Brad Brad.Christiansen at thalesgroup.com.au
Mon Jul 21 22:05:02 PDT 2008


Hi,

Thanks for the suggestions. I made the changes you recomened but it
seems to have had no effect on my problems. When I tried rebuilding
after the change I got the following results:

OpenThreads, Builds fine.
osg, Builds fine.
osgUtil: 60 warnings about duplicate symbols from OpenThreads
osgText (which built osgDB first): 2126 warnings about duplicate symbols
from both OpenThreads and osg.

Some examples:

osg35-osg.lib(VertexProgram.obj) : warning LNK4006: "public: static void
__cdecl osg::VertexProgram::discardDeletedVertexProgramObjects(unsigned
int)" (?discardDeletedVertexProgramObjects at VertexProgram@osg@@SAXI at Z)
already defined in osg35-osgDB.lib(VertexProgram.obj); second definition
ignored

osg35-osg.lib(WIN32Condition.obj) : warning LNK4006: "public: virtual
int __thiscall OpenThreads::Condition::wait(class OpenThreads::Mutex
*,unsigned long)" (?wait at Condition@OpenThreads@@UAEHPAVMutex at 2@K at Z)
already defined in osg35-osgDB.lib(WIN32Condition.obj); second
definition ignored

The drails of what I did are:
I modified the files as suggested (in 16 files, I am not building any
plugins / applications or the wrappers).
I reconfigured the static project using cmake.
I checked the preprocessor definintions in Visual Studios. Osg, osgUtil,
osgDB and osgText all had OSG_LIBRARY_STATIC OT_LIBRARY_STATIC defined.

Any further suggestions would be very welcome.

Cheers,

Brad

-----Original Message-----
From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Stephan
Maximilian Huber
Sent: Monday, 21 July 2008 5:21 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] OSG2.4 and 2.5.5 Windows static build problems

Christiansen, Brad schrieb:
> Hi,
>
> I have searched the archive but cant find any mention of the problem, 
> though I think can remember reading about a solution some time ago on 
> the list.
>
> I have just tried to build the static version of OSG v2.4 and v2.5.5 
> using ViualStudio .Net 2003. When I do this build I get 5000+ warnings

> about dulpicate definitions when linking (LNK 4006). I then cannot 
> link my aplication against the resulting .libs. Has anyone else 
> encountered this problem and have a fix / workaround?
Are these link-errors related to OpenThreads? A quick and dirty fiy
would be:

change CMakeLists for all osg-libs/src from

IF   (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY)
ELSE (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF(DYNAMIC_OPENSCENEGRAPH)


to

IF   (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY)
ELSE (DYNAMIC_OPENSCENEGRAPH)
    ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
    ADD_DEFINITIONS(-DOT_LIBRARY_STATIC)
ENDIF(DYNAMIC_OPENSCENEGRAPH)


The underlying problem is:

The setting, that you compiled OpenThreads statically is not carried out
to a public header or something. If another lib includes a header-file
of  OpenThreads the compiler thinks, that OpenThreads is linked for
dynamic-usage (because OT_LIBARY_STATIC is not defined so the
EXPORT-definition for OpenThreads is not setup correctly), so you'll get
multiple defined symbols, when you try to link your app with static
OpenThreads and static osg, because osg includes OpenThreads-symbols for
dynamic-linking.

IMHO the definition of OT_LIBARY_STATIC should be carried out to
OpenThreads/Config. The same should be done for OSG_LIBRARY_STATIC. On
Linux there's no such problem, because you don't have to declare
different exports for static versus dynamic linking.

I am no expert in CMake, so perhaps somebody may jump in here?

cheers,
Stephan

_______________________________________________
osg-users mailing list
osg-users at lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g



DISCLAIMER:---------------------------------------------------------------------------
This e-mail transmission and any documents, files and previous e-mail messages
attached to it are private and confidential. They may contain proprietary or copyright
material or information that is subject to legal professional privilege. They are for
the use of the intended recipient only.  Any unauthorised viewing, use, disclosure,
copying, alteration, storage or distribution of, or reliance on, this message is
strictly prohibited. No part may be reproduced, adapted or transmitted without the
written permission of the owner. If you have received this transmission in error, or
are not an authorised recipient, please immediately notify the sender by return email,
delete this message and all copies from your e-mail system, and destroy any printed
copies. Receipt by anyone other than the intended recipient should not be deemed a
waiver of any privilege or protection. Thales Australia does not warrant or represent
that this e-mail or any documents, files and previous e-mail messages attached are
error or virus free.
--------------------------------------------------------------------------------------




More information about the osg-users mailing list