Thread overview
Linking stlp45dm_debug.lib
Jan 14, 2004
Scott Michel
Jan 14, 2004
Rajiv Bhagwat
Re: Linking stlp45dm_debug.lib (global constructors not being run?)
Jan 14, 2004
Scott Michel
Jan 14, 2004
Scott Michel
January 14, 2004
I tried to compile up the "smoke screen" hello.cpp, linked the object file with
\dm\lib\stlp45dm_debug.lib, produced hello.exe

When I run hello.exe, I get an
access violation (the actual address is
irrelevant), but the stack trace is:
std::_M_init(basic_ostream<_CharT, _Traits)& __str) [_ostream.c, line 38]
std::_basic_ostream<>::sentry [stl_ostream.h, line 164]
std::operator<<(basic_ostream<_CharT, _Traits)& __os, const char *__s)
[stl_ostream.h, line 300)
main

Any clue or help? If I don't explicitly link
with stlp45dm_debug.lib, the error
goes away, presumably because it's linking
with a static version of the
library.


-scooter


January 14, 2004
Hi,
I had similar linker errors (just like you - only for the Debug version!),
which vanished when the "Smart Linking" flag was turned on in IDDE.
- Rajiv

"Scott Michel" <Scott_member@pathlink.com> wrote in message news:bu21n0$1hkm$1@digitaldaemon.com...
> I tried to compile up the "smoke screen" hello.cpp, linked the object file
with
> \dm\lib\stlp45dm_debug.lib, produced hello.exe
>
> When I run hello.exe, I get an
> access violation (the actual address is
> irrelevant), but the stack trace is:
> std::_M_init(basic_ostream<_CharT, _Traits)& __str) [_ostream.c, line 38]
> std::_basic_ostream<>::sentry [stl_ostream.h, line 164]
> std::operator<<(basic_ostream<_CharT, _Traits)& __os, const char *__s)
> [stl_ostream.h, line 300)
> main
>
> Any clue or help? If I don't explicitly link
> with stlp45dm_debug.lib, the error
> goes away, presumably because it's linking
> with a static version of the
> library.
>
>
> -scooter
>
>


January 14, 2004
Rajiv Bhagwat wrote:

> Hi,
> I had similar linker errors (just like you - only for the Debug version!),
> which vanished when the "Smart Linking" flag was turned on in IDDE.
> - Rajiv

I just tried this and produced the same result (with stlp45dm and stlp45dm_debug.) Retracing down a bit further, the data inspector claims that std::basic_ios<> is not instantiated. It almost seems like global constructors aren't being run.


-scooter


> "Scott Michel" <Scott_member@pathlink.com> wrote in message news:bu21n0$1hkm$1@digitaldaemon.com...
>> I tried to compile up the "smoke screen" hello.cpp, linked the object file
> with
>> \dm\lib\stlp45dm_debug.lib, produced hello.exe
>>
>> When I run hello.exe, I get an
>> access violation (the actual address is
>> irrelevant), but the stack trace is:
>> std::_M_init(basic_ostream<_CharT, _Traits)& __str) [_ostream.c, line 38]
>> std::_basic_ostream<>::sentry [stl_ostream.h, line 164]
>> std::operator<<(basic_ostream<_CharT, _Traits)& __os, const char *__s)
>> [stl_ostream.h, line 300)
>> main
>>
>> Any clue or help? If I don't explicitly link
>> with stlp45dm_debug.lib, the error
>> goes away, presumably because it's linking
>> with a static version of the
>> library.
>>
>>
>> -scooter
>>
>>

January 14, 2004
Scott Michel wrote:

> Rajiv Bhagwat wrote:
> 
>> Hi,
>> I had similar linker errors (just like you - only for the Debug
>> version!), which vanished when the "Smart Linking" flag was turned on in
>> IDDE. - Rajiv
> 
> I just tried this and produced the same result (with stlp45dm and stlp45dm_debug.) Retracing down a bit further, the data inspector claims that std::basic_ios<> is not instantiated. It almost seems like global constructors aren't being run.
> 
> 
> -scooter

After dicking around with the various IDDE compilation options, I was able to make the problem go away with checking the Compiler>Code Generation "Use DLL run time library flag". Dunno why, but looking at the resulting executable, the symbols imported include the all-important "? 0Init@ios_base@std@@QAE@XZ" symbol. I did figure out that this symbol is the mangled form of std::ios_base::Init::Init() and calling this ctor is totally critical to the stlp45dm* DLLs iostream initialization.

If the DLL run time lib flag isn't checked, for some reason, std::ios_base::Init::Init() doesn't get called.

Smart linking doesn't appear to affect much in this trivial case.


-scooter



>> "Scott Michel" <Scott_member@pathlink.com> wrote in message news:bu21n0$1hkm$1@digitaldaemon.com...
>>> I tried to compile up the "smoke screen" hello.cpp, linked the object file
>> with
>>> \dm\lib\stlp45dm_debug.lib, produced hello.exe
>>>
>>> When I run hello.exe, I get an
>>> access violation (the actual address is
>>> irrelevant), but the stack trace is:
>>> std::_M_init(basic_ostream<_CharT, _Traits)& __str) [_ostream.c, line
>>> 38] std::_basic_ostream<>::sentry [stl_ostream.h, line 164]
>>> std::operator<<(basic_ostream<_CharT, _Traits)& __os, const char *__s)
>>> [stl_ostream.h, line 300)
>>> main
>>>
>>> Any clue or help? If I don't explicitly link
>>> with stlp45dm_debug.lib, the error
>>> goes away, presumably because it's linking
>>> with a static version of the
>>> library.
>>>
>>>
>>> -scooter
>>>
>>>