g++ fails with error

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

g++ fails with error

bharath144
Hello,

I have a c++ shared object that I am compiling using the following command.

g++ -g -Wall -c -o cpplib.o cpplib.cpp

And I am creating the shared object using the following command.

g++ -shared -o libcpplib.so cpplib.o

(I am aware that I can do this one single command, these are two separate invocations because I had the project setup on eclipse and that's how eclipse cdt does it.).

My host runs a RedHat 6.x x86_64 OS.

The compilation fails with the following error.

[root@dev-80 cpplib]# g++ -g -Wall -fPIC -c -o cpplib.o cpplib.cpp
[root@dev-80 cpplib]# g++ -shared -fPIC -o libcpplib.so cpplib.o
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a(ios_init.o): relocation R_X86_64_32 against `pthread_cancel' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
[root@dev-80 cpplib]#

I am certain that I haven't used the 'pthread_cancel' function in my code.

Can anyone help me with this?

Regards,
Bharath
_______________________________________________
help-gplusplus mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-gplusplus
Reply | Threaded
Open this post in threaded view
|

Re: g++ fails with error

Maurizio Loreti
g++ 4.4 and its shared library are quite old.  Try to upgrade to
4.8.1...

--
(@_  | Maurizio Loreti
//\  |
V_/_ | EMail/ROT13: [hidden email]
_______________________________________________
help-gplusplus mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-gplusplus
Reply | Threaded
Open this post in threaded view
|

Re: g++ fails with error

Gerhard Fiedler
In reply to this post by bharath144
[hidden email] wrote:

> Hello,
>
> I have a c++ shared object that I am compiling using the following command.
>
> g++ -g -Wall -c -o cpplib.o cpplib.cpp
>
> And I am creating the shared object using the following command.
>
> g++ -shared -o libcpplib.so cpplib.o
>
> (I am aware that I can do this one single command, these are two separate invocations because I had the project setup on eclipse and that's how eclipse cdt does it.).
>
> My host runs a RedHat 6.x x86_64 OS.
>
> The compilation fails with the following error.
>
> [root@dev-80 cpplib]# g++ -g -Wall -fPIC -c -o cpplib.o cpplib.cpp
> [root@dev-80 cpplib]# g++ -shared -fPIC -o libcpplib.so cpplib.o
> /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a(ios_init.o): relocation R_X86_64_32 against `pthread_cancel' can not be used when making a shared object; recompile with -fPIC
> /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a: could not read symbols: Bad value
> collect2: ld returned 1 exit status
> [root@dev-80 cpplib]#
>
> I am certain that I haven't used the 'pthread_cancel' function in my code.
>
> Can anyone help me with this?

Did you try what the error message says? That is,

g++ -g -Wall -fPIC -c -o cpplib.o cpplib.cpp

Gerhard


_______________________________________________
help-gplusplus mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-gplusplus
Reply | Threaded
Open this post in threaded view
|

Re: g++ fails with error

bharath144
In reply to this post by bharath144
On Thursday, August 15, 2013 12:54:48 AM UTC+5:30, Gerhard Fiedler wrote:

> wrote:
>
>
>
> > Hello,
>
> >
>
> > I have a c++ shared object that I am compiling using the following command.
>
> >
>
> > g++ -g -Wall -c -o cpplib.o cpplib.cpp
>
> >
>
> > And I am creating the shared object using the following command.
>
> >
>
> > g++ -shared -o libcpplib.so cpplib.o
>
> >
>
> > (I am aware that I can do this one single command, these are two separate invocations because I had the project setup on eclipse and that's how eclipse cdt does it.).
>
> >
>
> > My host runs a RedHat 6.x x86_64 OS.
>
> >
>
> > The compilation fails with the following error.
>
> >
>
> > [root@dev-80 cpplib]# g++ -g -Wall -fPIC -c -o cpplib.o cpplib.cpp
>
> > [root@dev-80 cpplib]# g++ -shared -fPIC -o libcpplib.so cpplib.o
>
> > /usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a(ios_init.o): relocation R_X86_64_32 against `pthread_cancel' can not be used when making a shared object; recompile with -fPIC
>
> > /usr/lib/gcc/x86_64-redhat-linux/4.4.7/libstdc++.a: could not read symbols: Bad value
>
> > collect2: ld returned 1 exit status
>
> > [root@dev-80 cpplib]#
>
> >
>
> > I am certain that I haven't used the 'pthread_cancel' function in my code.
>
> >
>
> > Can anyone help me with this?
>
>
>
> Did you try what the error message says? That is,
>
>
>
> g++ -g -Wall -fPIC -c -o cpplib.o cpplib.cpp
>
>
>
> Gerhard

Well, I have tried that. Moreover, My first step (which is the compilation) already has the -fPIC option included.
_______________________________________________
help-gplusplus mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-gplusplus