[osg-users] Can't createGraphicsContext if I statically link OSG to my app

Robert Osfield robert.osfield at gmail.com
Wed Nov 18 09:38:46 PST 2009


Hi Iñaki? García?

Could you sign with the name you wish to be addressed as, as it makes
it easier to avoid addressing you incorrectly, thanks.

W.r.t getting things working under a static build, the main problem
that you have to deal with is that the compiler will not bother
linking in symbols that aren't explicitly used, so they default the
OSG's proxy registration schemes such as used in osgViewer and osgDB
for the plugins.  This means you have to add these symbols in your
app.  Have a look at the osgstaticviewer to see the easist way to do
this.

Robert.

On Wed, Nov 18, 2009 at 5:22 PM, Iñaki García <igarcia at euve.org> wrote:
> Hi everybody:
>
> I've a working application (Windows, MFC) with an OSG scene in one window,
> that works correctly when I use OSG's DLLs. But, in order to distribute it,
> I prefer an all-in-one executable, so I've built OSG v2.8.2 statically,
> linked to my app with success.
>
> But when I run it, it does not display anything in its window. I've debugged
> the differences between the statically and dynamically versions to a point.
> In the statically built, the:
> osg::GraphicsContext::createGraphicsContext(traits.get())
> returns NULL, and in dynamically doesn't.
>
> If I debug deeper, I find it's because:
> windowingSystemInterfaceRef()
> returns NULL
>
> And that's because that function is:
> static ref_ptr<GraphicsContext::WindowingSystemInterface>
> &windowingSystemInterfaceRef()
> {
>   static ref_ptr<GraphicsContext::WindowingSystemInterface>
> s_WindowingSystemInterface;
>   return s_WindowingSystemInterface;
> }
>
> My questions:
> How can that function return NULL? Why a different behaviour between static
> and dynamic linkage?
>
> Best regards
> --
> * Iñaki García
> División de Ingeniería - Engineering Division
> European Virtual Engineering (EUVE) <http://www.euve.org>*
> Avenida de los Huetos 79, "Edificio azucarera"
> 01010 Vitoria-Gasteiz (Álava) - Spain
> Tel: +34 945 21 46 46   Fax: +34 945 21 46 47
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list