Shared Library Solaris

Hi!

I tried to create a shared library which is linked to OpenMP (libgomp) on Solaris. But I always get a relocation Error:

ld: fatal: relocation error: R_386_TLS_LE: file /vol/gcc-4.3/lib/gcc/i386-pc-solaris2.10/4.3.2/libgomp.a(team.o): symbol gomp_tls_data: relocation illegal when building a shared object

Below I've posted a minimal example of my code:
func.c
1
2
3
4
5
6
7
#include "func.h"
void function(){
        #pragma omp parallel for
        for(int i=0;i<15;i++){
                std::cout<<omp_get_num_threads()<<std::endl;
        }
}

func.h
1
2
3
#include <iostream>
#include <omp.h>
void function();

I compile it with these commandos

g++ -fPIC -DPIC -fopenmp -c func.c
g++ -shared -o libfunc.so func.o -lgomp

gcc version

Reading specs from /vol/gcc-4.3/lib/gcc/i386-pc-solaris2.10/4.3.2/specs
Target: i386-pc-solaris2.10
Configured with: /.cache/gcc/gcc-4.3.2/configure --prefix=/vol/gcc-4.3 --libexecdir=/vol/gcc-4.3/lib --with-gnu-as --with-as=/usr/sfw/bin/gas --enable-languages=c,c++,fortran,objc,java --enable-version-specific-runtime-libs --enable-shared=libstdc++ --with-gmp-include=/vol/gnu/include --with-gmp-lib=/vol/gnu/lib --with-mpfr-include=/vol/local/include --with-mpfr-lib=/vol/local/lib --disable-nls
Thread model: posix
gcc version 4.3.2 (GCC) 

ld Version
GNU ld (GNU Binutils) 2.20

System
uname -a                                                                                                                                                                                              [10028]
SunOS opteron 5.10 Generic_139556-08 i86pc i386 i86pc Solaris

During my search in the internet I found that you get such an error if you don't compile with -fPIC. But I've done that. Is this probably a problem of the gcc installed on system. With my Macbook everything works fine.
Please help me!
Last edited on
Aw, hell. Google gives nine results for "relocation illegal when building a shared object". The third one is this thread.
Screw it, I'll just guess. Uh... Did you try without that flag? What about using it when linking, instead of compiling?
Topic archived. No new replies allowed.