Solved

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

Posted on 2008-10-26
10
750 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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: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

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 172
Best way to handle awk return value 6 79
Execute multiple curl cmds with sleep and send output to file 10 121
awk sed variable in file 3 109
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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

738 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