Solved

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

Posted on 2008-10-26
10
744 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:blu
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:blu
ID: 22832206
What happens if you do the compile and link in two steps?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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:blu
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:blu
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:
blu earned 500 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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 how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

821 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