yzfedora / baidudl

This is a multi-thread download tool for pan.baidu.com
GNU General Public License v3.0
199 stars 35 forks source link

Could not compile. gcc arguments are in wrong order #13

Open yuliswe opened 6 years ago

yuliswe commented 6 years ago
/mnt/c/Users/ylila/lab/baidudl/src# make
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT dlpart.o -MD -MP -MF .deps/dlpart.Tpo -c -o dlpart.o dlpart.c
mv -f .deps/dlpart.Tpo .deps/dlpart.Po
gcc  -g -O2 -Wall -Wextra -lpthread -ljansson  -o bdpandl bdpandl.o dlcommon.o dlinfo.o dlpart.o dlscrolling.o dllist.o err_handler.o dlbuffer.o dlssl.o  -lcurl -lpthread
dlpart.o: In function `baidu_error_check':
/mnt/c/Users/ylila/lab/baidudl/src/dlpart.c:47: undefined reference to `json_loadb'
/mnt/c/Users/ylila/lab/baidudl/src/dlpart.c:50: undefined reference to `json_object_get'
/mnt/c/Users/ylila/lab/baidudl/src/dlpart.c:51: undefined reference to `json_object_get'
/mnt/c/Users/ylila/lab/baidudl/src/dlpart.c:55: undefined reference to `json_integer_value'
/mnt/c/Users/ylila/lab/baidudl/src/dlpart.c:56: undefined reference to `json_string_value'
dlpart.o: In function `json_decref':
/usr/local/include/jansson.h:129: undefined reference to `json_delete'
collect2: error: ld returned 1 exit status
Makefile:345: recipe for target 'bdpandl' failed
make: *** [bdpandl] Error 1
yuliswe commented 6 years ago

-ljansson needs to be moved to the end after the object files. Otherwise the linker won't scan for the library.

yuliswe commented 6 years ago

This will correctly compile: gcc -O2 -Wall -Wextra -o bdpandl bdpandl.o dlcommon.o dlinfo.o dlpart.o dlscrolling.o dllist.o err_handler.o dlbuffer.o dlssl.o -lcurl -lpthread -I/usr/local/include -L/usr/local/lib -ljansson -lpthread

yzfedora commented 6 years ago

It looks the automake generated wrong compile command, src/Makefile.am file has a following statement:

bdpandl_LDFLAGS = -Wall -Wextra -lpthread -ljansson.

perhaps something wrong here.