Buggy ordering of g++ command line
tseemann opened this issue · comments
Error:
/usr/bin/ld: /tmp/ccNbQPgH.ltrans0.ltrans.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:192: recipe for target 'gunzip' failed
Cause:
g++-5 -o gunzip -std=c++14 -I. -Icommon -lpthread -Iexternal/type_safe/include -Iexternal/type_safe/external/debug_assert -Wall -Wundef -Wrestrict -Wnull-dereference -Wuseless-cast -Wshadow -Weffc++ -Wpedantic -Wvla -O4 -flto -march=native -mtune=native -g -D_POSIX_C_SOURCE=200809L -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H programs/gunzip.o programs/prog_util.o programs/tgetopt.o libdeflate.a -lrt
Reason:
The -lpthread is in the wrong location on this command line. All the -l options need to occur after the object files programs/gunzip.o programs/prog_util.o programs/tgetopt.o where the -lrt is currently found.
Yes, you're right !
The makefile was hacked together from the libdeflate, I didn't plan on spending time on it until we release a library.
Anyway, I pushed quick fix (should also resolve #9).