Link to home
Start Free TrialLog in
Avatar of McVole
McVole

asked on

What command line options do I need to build a shared object with g++ on solaris 8 ?

I tried to build a simple shared object on Solaris 8 as follows. There's nothing remotely complex in mylib.cpp

g++ -fPIC -shared -o mylib.so mylib.cpp

and got several error messages all of the same form, as follows.

/opt/gnu/bin/ld: fde encoding in /var/tmp//ccJnUCJ3.o(.eh_frame) prevents .eh_frame_hdr table being created

What do I need to do to get the build to work?
Avatar of Brian Utterback
Brian Utterback
Flag of United States of America image

Not sure what is going on. It looks like a linker bug. It's a long shot, but try adding -eh-frame-hdr to the compile command line.
Avatar of McVole
McVole

ASKER

OK, I added -eh-frame-hdr to the compile command line, and got the same problem.

/opt/gnu/bin/ld: fde encoding in /var/tmp//ccTSAAaN.o(.eh_frame) prevents .eh_frame_hdr table being created.

I also found that if I built a shared library in C with gcc on the same box, it worked. And if I omitted the -fPIC from the g++ command line it worked, i.e.

g++ -shared -o mylib.so mylib.cpp

worked. But then it probably won't get shared.

What happens if you do the compile and link in two steps?
Avatar of McVole

ASKER


I compiled mylib.cpp into mylib.o with -fPIC with no problems. When I attempted to link a shared object I go the following error.

ld: fde encoding in mylib.o(.eh_frame) prevents .eh_frame_hdr table being created.
Have you tried using the system ld command?
Avatar of McVole

ASKER

No, just the gnu linker.
Is it binary compatible?
Where am I likely to find it?
/usr/ccs/bin/ld

Avatar of McVole

ASKER

/usr/ccs/bin/ld -shared -o mylib.so mylib.o
ld: fatal: option -h and building a dynamic executable are incompatible
ld: fatal: Flags processing errors

Did I get the command line options right?
ASKER CERTIFIED SOLUTION
Avatar of Brian Utterback
Brian Utterback
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McVole

ASKER

/usr/ccs/bin/ld -B dynamic -o mylib.so mylib.o
Undefined                       first referenced
 symbol                             in file
__gxx_personality_v0                mylib.o
ld: fatal: Symbol referencing errors. No output written to mylib.so

(and it worked fine with analogous gcc output).

So it's g++ not the linker!

Thank you, that was worth knowing. It seems to be gcc 4.1 on solaris 8, so I've requested a move to 4.2 in the hope the problem goes away. You'll hear from me. Any more ideas?