Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-10-26
10
Medium Priority
?
758 Views
Last Modified: 2013-12-27
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?
0
Comment
Question by:McVole
  • 5
  • 5
10 Comments
 
LVL 22

Expert Comment

by:Brian Utterback
ID: 22830189
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.
0
 

Author Comment

by:McVole
ID: 22831527
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.

0
 
LVL 22

Expert Comment

by:Brian Utterback
ID: 22832206
What happens if you do the compile and link in two steps?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:McVole
ID: 22834356

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.
0
 
LVL 22

Expert Comment

by:Brian Utterback
ID: 22834527
Have you tried using the system ld command?
0
 

Author Comment

by:McVole
ID: 22834605
No, just the gnu linker.
Is it binary compatible?
Where am I likely to find it?
0
 
LVL 22

Expert Comment

by:Brian Utterback
ID: 22834659
/usr/ccs/bin/ld

0
 

Author Comment

by:McVole
ID: 22834870
/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?
0
 
LVL 22

Accepted Solution

by:
Brian Utterback earned 1500 total points
ID: 22839887
Instead of "-shared" use "-B dynamic"
0
 

Author Comment

by:McVole
ID: 22880126
/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?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month11 days, 8 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question