Linking C and C++ code object files with 'ld'?

Linking C and C++ code object files with 'ld'?

Post by Gerd Kless » Sat, 24 Feb 1996 04:00:00



Hi,

I'm using gcc2.7.0. I wonder if it is possible to use 'ld' to
link object file, that come from both C and C++ source code in
**one** program?

Please help
Gerd

 
 
 

1. C++, ld & global object's constructors

I have a problem i am fed up with....

First of all here is the compiler i am using and
the OS i am working on :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I a developping a plugin for netscape 3.0 : a plugin consists
in a shared library used by netscape in order to
enhance its capabilities. The library i am writing is supposed
to loaded by netscape : because i don't link netscape with
my dll, i suppose the libdl (with dlopen, dlsym functions)
is used (by netscape) to load my library...

The problem is that i HAVE (because of the existing code i am using)
to deal with  global objects in my library. And of course, the constructors are not
called...

I have read the g++ FAQ and especially the part entitled << Global
constructors aren't being called >>. However I have no problem with
global object when they are part of "normal" (ie static program)...
That's the reason why i think that the FAQ cannot apply to my problem
(i am maybe wrong ; if i am, i could try to patch my linker as
proposed in the FAQ).

The problem seems to be due to the linker (solaris ld). Indeed,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have no problem using GNU linker under Linux

Information :
~~~~~~~~~~~

I build  
- foo.so like this:
          g++ -shared -o foo.so foo1.o foo2.o ... fooN.o

- and fooY.o like this :
          g++ -fpic -c fooY.c

I would be happy not to upgrade my compiler with a more recent version...

Thank's in advance

--


--
+---------------------------------------+


+---------------------------------------+

2. Trantor T-160 and Linux

3. 'ld' crashes for large shared objects

4. sysadm

5. How to use ld to link C object codes?

6. queueing mail to /var/mail/'owner' in sendmail 8.9.3?

7. linking C++ code to a shared object on AIX

8. squid: usernames in access.log

9. Linking C++ object code with C linker

10. Generating demangled C++ object files -- Guru's Needed For this one!!!!

11. what does 'ld: Output file requires shared library `libc.so.4'' mean?

12. How to link the gcc and nasm 's object file!!help!!