[osg-users] Can't createGraphicsContext if I statically link OSG to my app
Iñaki García
igarcia at euve.org
Wed Nov 18 10:21:01 PST 2009
Hi Robert,
I know the issue with the dynamic plugin registration, and the "mangled
names" that I have to force including in order to make the plugins link
into my binary. But what is very rare is that I *explicitly* call
createGraphicsContext, which calls windowingSystemInterfaceRef, which
returns NULL when returning a reference to a static variable. And that
doesn't make sense to me.
Under this circumstances, can the linker exclude
windowingSystemInterfaceRef? And when a non-existing function is called,
returning NULL is enough? (crash, freeze or explode seems more suitable)
Another possibility is that the function exists but that static variable
hasn't been allocated? Why shouldn't it be allocated from the beginning?
In case it can give a clue, I´m running the debug build, without
optimizations.
Chris:
Do you mean that a static "local-to-a-function" variable must be created
by someone, and that the DLL init does and my app doesn't? I'm not very
experienced on this memory-related details.
Iñaki
Robert Osfield escribió:
> 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
>>
>>
> _______________________________________________
> 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