Search code examples
gcclinker-errorsvxworks

GCC suppress flags


I'm trying to create a shared library with my gcc. It's a gcc for vxworks (thats probably the problem...).

I use the gcc as following:

./gcc -shared -B/path/to/gnutools/bin -o test.so test.c

Result:

/path/to/ld: -r and -shared may not be used together 
collect2: ld returned 1 exit status

If I try the same with the linux gcc, there's no problem. So i guess the gcc for VxWorks automatically passes the -r (or -i, which is the same and results in the same) flag to the linker. Is there a way to suppress this?

Greetz

marty

PS: making it static is not really an alternative...


Solution

  • Try compile object file separately with -fPIC and then link:

        gcc -Wall -fPIC -c -o test.o test.c
        gcc -Wall -shared -o test.so test.o
    

    Another suggestion is to use libtool (at least to figure out the correct flags).

    A workaround may be to go directly with ld:

        ld -shared -o test.so test.o -lc