Issues with linking against a library built w/ -D_REENTRANT

Issues with linking against a library built w/ -D_REENTRANT

Post by Eric We » Fri, 18 Oct 2002 06:08:43



(1) Are there side effects that I should be aware of if I compile
single threaded application code without -D_REENTRANT (or
-D_POSIX_C_SOURCE=199506L) and link the resulting object file to a
library I created w/ -D_REENTRANT
-D_POSIX_C_SOURCE=199506L. The library is not multi-threaded, but may
be linked against code that is threaded. That code /does/ serialize
calls to my library.

(2) What side effects may be encountered if the threaded object code
assumes non-POSIX thread semantics if linked against my aforementioned
library that was compiled with -D_REENTRANT -D_POSIX_C_SOURCE=199506L
flags? Is errno still thread safe?

(3) Can single threaded code be "safely" linked to libraries created
with and without -D_REENTRANT -D_POSIX_C_SOURCE=199506L. I understand
this is not the case with thread code.

Basically, can I assume building a library with -D_REENTRANT flag is
nearly a noop in terms of effects for the case that it is linked to
single threaded objects built without that flag?

BTW, does -D_REENTRANT require the -mt switch?

Thanks in advance.

   --Eric West

 
 
 

Issues with linking against a library built w/ -D_REENTRANT

Post by Casper H.S. Di » Sat, 19 Oct 2002 07:38:37



>(1) Are there side effects that I should be aware of if I compile
>single threaded application code without -D_REENTRANT (or
>-D_POSIX_C_SOURCE=199506L) and link the resulting object file to a
>library I created w/ -D_REENTRANT
>-D_POSIX_C_SOURCE=199506L. The library is not multi-threaded, but may
>be linked against code that is threaded. That code /does/ serialize
>calls to my library.

No issues; that's how all Solaris libraries are build; single threaded
non reentrant apps just work fine.

Quote:>(2) What side effects may be encountered if the threaded object code
>assumes non-POSIX thread semantics if linked against my aforementioned
>library that was compiled with -D_REENTRANT -D_POSIX_C_SOURCE=199506L
>flags? Is errno still thread safe?

No issues; the semantic differences are visible to the modules
you compile with that particular option (it redefines a few functions).

Quote:>(3) Can single threaded code be "safely" linked to libraries created
>with and without -D_REENTRANT -D_POSIX_C_SOURCE=199506L. I understand
>this is not the case with thread code.

Yes.

Quote:>Basically, can I assume building a library with -D_REENTRANT flag is
>nearly a noop in terms of effects for the case that it is linked to
>single threaded objects built without that flag?
>BTW, does -D_REENTRANT require the -mt switch?

Only when linking.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

1. linking static library against another library

Hi,

I'm trying to link a static library against another static library, but I
get lot of 'undefined reference' errors.

here's what I have

/Common
        some cpp files resulting to libCommon.a

/Simulation
        some cpp files, which use classes from /Common, resulting to
        libSimulation.a
/
        main.cpp, using libSimulation.a

I want compile all the /Common stuff into a single static library,
libCommon.a. This will then get used by libraries for specific
applications, e.g. Simulation. I want the /Simulation stuff also to be
compiled into a library, which uses the libCommon.a

Both libraries compile and link, but when I try to link the main executable
it complains about undefined references in libSimulation.a

Some help please?

Morfeas

--
www.freecfm.com/m/morfeas

2. Venix/286

3. link compat=4 built library with a compat=5 build code

4. mosfet-liquid is dead

5. Linking against SCO static Library ?

6. DOSEmu for NetBSD1.0?

7. linking against old shared libraries

8. Shared Library/Object dynamic loading: Portability.

9. Linking against static libraries

10. linking against shared libraries

11. linking statically against shared libraries

12. Linking against Sybase libraries for Linux; `ld got fatal signal 6'

13. Linking against SunOS 4.1.x libraries in Solaris 2.5.1