Solved

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

Posted on 2008-10-26
10
734 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
Comment Utility
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
Comment Utility
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
Comment Utility
What happens if you do the compile and link in two steps?
0
 

Author Comment

by:McVole
Comment Utility

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
Comment Utility
Have you tried using the system ld command?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

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

Expert Comment

by:blu
Comment Utility
/usr/ccs/bin/ld

0
 

Author Comment

by:McVole
Comment Utility
/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
Comment Utility
Instead of "-shared" use "-B dynamic"
0
 

Author Comment

by:McVole
Comment Utility
/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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now