Operating System - HP-UX
1846654 Members
2936 Online
110256 Solutions
New Discussion

Problem Creating Shared Library

 
Lalit Seth
Frequent Advisor

Problem Creating Shared Library

Hi,

I m using gcc 3.3.3 11.11/32 bit binary created by Merjin on hppa2.0w.

I have created xaa.cpp
#include

void name()
{
cout<<"Name"<}

Then compile it using
g++ -c -g xaa.cpp
which does fine
now when i create shared library of this using
g++ -g -shared -fPIC -o xaa.so xaa.o
results in
/usr/ccs/bin/ld: Invalid loader fixup in text space needed in output file for symbol "std::basic_ostream >& std::endl >(std::basic_ostream >&)" in input file "xaa.o"
collect2: ld returned 1 exit status

How can i resolve this???

Rgds
Lalit
8 REPLIES 8
Elmar P. Kolkman
Honored Contributor

Re: Problem Creating Shared Library

Try doing the first compile from C++-code to object file with the -shared option. That should help, according to the man-page description of -shared option of g++.
Every problem has at least one solution. Only some solutions are harder to find.
Lalit Seth
Frequent Advisor

Re: Problem Creating Shared Library

Thnks,

Still Error Occurs :(

What next ????
Elmar P. Kolkman
Honored Contributor

Re: Problem Creating Shared Library

Have you tried without the debugging code? (remove the -g options from both g++ calls)
Every problem has at least one solution. Only some solutions are harder to find.
Lalit Seth
Frequent Advisor

Re: Problem Creating Shared Library

No Luck Same Error
Lalit Seth
Frequent Advisor

Re: Problem Creating Shared Library

Tryed this
g++ -c -fPIC -shared xaa.cpp
g++ -fPIC -shared -o xaa.so xaa.o

and got

/usr/ccs/bin/ld: Invalid loader fixup in text space needed in output file for symbol "__gxx_personality_sj0" in input file "../HPUXGCC3.3.3-32/pa20_32/lib/libstdc++.a(ios.o)"
collect2: ld returned 1 exit status

Lalit Seth
Frequent Advisor

Re: Problem Creating Shared Library

Does anybody know how to get rid of this????
Maxim Tseitlin
New Member

Re: Problem Creating Shared Library

The problem is that libstdc++.a is not compiled as Position Independent Code (-fPIC).

You have 2 options:
* Recompile libstdc++.a as position independent.
* Link with libstdc++.sl shared library.

I have recompiled libstdc++.a as position independent and this problem was disappeared.

Maxim
Paddy_1
Valued Contributor

Re: Problem Creating Shared Library

Could you try compiling xaa.o with the +z/+Z option which enables it to be linked as a shared library.

You might also try linking with with standrad c library with "-lc" tag if that doesnt work.
The sufficiency of my merit is to know that my merit is NOT sufficient