2008-04-30 13:19:34     make pthread error !

Document created by Aaronwu Employee on Aug 6, 2013
Version 1Show Document
  • View in full screen mode

2008-04-30 13:19:34     make pthread error !


Message: 55307    Hi !


make in source project:


test_gcc# make

bfin-uclinux-gcc    -c -o main.o main.c

bfin-uclinux-gcc    -c -o socket_read.o socket_read.c

bfin-uclinux-gcc    -c -o socket_write.o socket_write.c

bfin-uclinux-gcc -Wl,-elf2flt main.c -o main -lpthread

/tmp/ccgF8Xns.o: In function `_main':

main.c:(.text+0x26): undefined reference to `_socket_read'

main.c:(.text+0x2a): undefined reference to `_socket_read'

main.c:(.text+0x3e): undefined reference to `_socket_write'

main.c:(.text+0x42): undefined reference to `_socket_write'

collect2: ld returned 1 exit status

make: *** [main] Error 1


help !!!


make for debian, no problems !

make for uclinux problems !



My Makefile:


CC   = bfin-uclinux-gcc

LDFLAGS = -Wl,-elf2flt

EXEC = main

OBJS = main.o socket_read.o socket_write.o

LDLIBS = -lpthread


all: $(EXEC)


$(EXEC): $(OBJS)

       $(CC) $(LDFLAGS) $@.c -o $(EXEC) $(LDLIBS)



       $(ROMFSINST) /bin/$(EXEC)



       -rm -f $(EXEC) *.elf *.gdb *.o


project include..






2008-04-30 16:14:49     Re: make pthread error !

Mike Frysinger (UNITED STATES)

Message: 55314    i highly doubt you're building it the same way on your host as you are when cross-compiling it when your Makefile is clearly broken.  there is absolutely no way it could have worked.


if you actually look and figure out the output from make, the answer is pretty obvious:

bfin-uclinux-gcc -Wl,-elf2flt main.c -o main -lpthread


you're trying to produce "main" with only main.c ?  that means your main target is wrong:

$(EXEC): $(OBJS)

       $(CC) $(LDFLAGS) $@.c -o $(EXEC) $(LDLIBS)


well, you've only listed "$@.c" as the source, so it's the only one that is going to get used ...