Shared Lib: Linker Fehler

Gast #4435694
Lesenswert?

Hallo,

ich versuche ein recht einfaches Programm als shared Library zu bauen.

Ich bekomme aber eine komische Fehlermeldung.
Laut google tritt dieser Fehler auf, wenn man versucht eine statische 
Lib einzubauen. Das tue ich aber nicht.

Hier Fehlermeldung + Makefile
1
$ make
2
/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.03_linux/bin/arm-linux-gnueabihf-gcc -shared -fPIC  -std=gnu99 -I/home/include -o libmy.so /home/src/common.o /home/src/types.o /home/src/sys.o  
3
/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.03_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: /home/src/types.o: relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
4
/home/src/types.o: error adding symbols: Bad value
5
collect2: error: ld returned 1 exit status
6
Makefile:17: recipe for target 'libmy.so' failed
7
make: *** [libmy.so] Error 1
1
SHELL = /bin/sh
2
CC    = /opt/gcc-linaro-arm-linux-gnueabihf-4.8-2014.03_linux/bin/arm-linux-gnueabihf-gcc
3
CFLAGS       = -shared -fPIC  -std=gnu99
4
INCL = -I/home/include
5

6
TARGET  = libmy.so
7
OBJECTS = /home/src/common.o  \
8
  /home/src/types.o      \
9
  /home/src/sys.o  
10

11

12
all: $(TARGET)
13

14
$(TARGET): $(OBJECTS)
15
  $(CC) $(CFLAGS) $(INCL) -o $(TARGET) $(OBJECTS)

Was soll ich den davon halten "recompile with -fPIC"?
Das ist doch schon als CFLAG gesetzt.
Gast #4435892
Lesenswert?

So?
1
...
2
all: $(TARGET)
3

4
$(TARGET): $(OBJECTS)
5
  $(CC) $(CFLAGS) $(INCL) -o $(TARGET) $(OBJECTS)
6

7
%.o: %.c
8
    $(CC) $(CFLAGS) $(INCL) -c -o $@ $<

Leider kein Unterschied.

Ich habe es aber auch schon direkt mit 'gcc -shared -fPIC ...' probiert, 
mit dem gleichen ERR.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren