Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

errors linking standard functions on solaris

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
0
0
Hi,

Compiling the below problem on solaris 5.9 with gcc 3.2, I get the following errors linking :

Code:
#include <stdlib.h>
#include <stdio.h>

void simple_func() {
        FILE* mylog = fopen("/tmp/simple_func.mylog", "at");
        fclose(mylog);
}

Compiling using :

gcc bla.c -o bla.so -shared

gives the errors :

Code:
Text relocation remains                         referenced
    against symbol                  offset      in file
<unknown>                           0x4         /var/tmp//ccqx8rg9.o
<unknown>                           0x8         /var/tmp//ccqx8rg9.o
<unknown>                           0xc         /var/tmp//ccqx8rg9.o
<unknown>                           0x10        /var/tmp//ccqx8rg9.o
fopen                               0x14        /var/tmp//ccqx8rg9.o
fclose                              0x24        /var/tmp//ccqx8rg9.o
ld: fatal: relocations remain against allocatable but non-writable sections
collect2: ld returned 1 exit status

Another weird thing is if I alter the code so its not a shared lib, has a 'main', and compile to an exe, then it links just fine.

Never had these problems on Linux x86 platforms .... anybody got an idea of the problem ?

Thanks for any help !
 
Why is it you can spend ages googling, finally post a question, and then find the answer yourself 2 minutes later ?!

Anyhow, I added the switch -fPIC , and it compiled up.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top