Le mardi 06 septembre 2016 à 08:30 +0800, 彭怀敏 a écrit : > Hi, I am using Ubuntu16.04, with GNU make 4.1. > I was failed while built my project which referenced to libpthread > and libm, but it was OK while used Ubuntu10.04 with GNU make 3.81. > I found the difference of the "strace make" output between the two > versions of make, that LD will open libpthread after open libc in > v3.81, but it will not open libpthread in v4.1, and thus I got a lot > of "undefined reference to", and "collect2: error: ld returned 1 exit > status". >
It's likely not related to make: your toolchains (binutils, gcc) and libraries are differents between Ubuntu from 2010 and Ubuntu from 2014. > Here is part of my makefile, a simple makefile: > > OBJS = median.o EventParam.o Filter.o OtdrAlgo.o Otdr.o \ > OtdrEdma.o OtdrMain.o OtdrTable.o NetworkSocket.o \ > Utility.o OtdrTouch.o Event.o > > CFLAGS = -g -Wall > LDFLAGS = -lm -lpthread > -lm -lpthread should not be in variable $(LDFLAGS) as it's passed before the object file to link. For example, put them in $(LIBS) LIBS := -lm -lpthread > #CROSS_COMPILE = /opt/itop/4.3.2/bin/arm-linux- > > linuxotdr: $(OBJS) > $(CROSS_COMPILE)gcc $(CFLAGS) $(LDFLAGS) -o $@ $^ > Libraries should be listed after the object files that might need them: With the previous change, use recipe instead: $(CROSS_COMPILE)gcc $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) > Event.o : Event.c Otdr.h prototypes.h protocol.h DspFpgaReg.h > $(CROSS_COMPILE)gcc -c $(CFLAGS) $^ > ......... > > I don't know how to solve it, could you help me? > Thanks very much. > > Regards. -- Yann Droneaud OPTEYA _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make