I'm trying to make a bot like the "!Remindme" reddit bot and i found this Web Scrapper written in C but i don't understand why it don't compile. Can someone help me ? The compiler throw me this :
gcc -o crawler src/crawler.o src/html.o src/http.o src/list.o src/queue.o src/url.o -g -Wall -fPIE -lpthread lib/liburiparser.a
/usr/bin/ld: src/crawler.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: src/html.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: src/http.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: src/url.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: lib/liburiparser.a(UriNormalizeBase.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: lib/liburiparser.a(UriParse.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: lib/liburiparser.a(UriCommon.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: lib/liburiparser.a(UriIp4.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: crawler] Error 1
Even with the flag -fPIE it doesn't work and i'm confuse why. Any help ? :)
CodePudding user response:
You are not compiling you are linking. The linker /usr/bin/ld is talking about that some of the objects files (both direct and from the archive) have to be compiled previously with the -fPIE to work.
CodePudding user response:
You will need to install liburiparser (liburiparser-dev on ubuntu), and run the following command:
gcc -o crawler src/crawler.c src/html.c src/http.c src/list.c src/queue.c src/url.c -g -Wall -lpthread -luriparser -I./include
I suggest you do not use those .o files compiled on other systems, most likely with different CPU architectures.
Side note: I found that you are using https://github.com/iceman201/Web_Scraper, and it seems that they don't have a configured .gitignore to ignore these .o files which are the source of confusion here.
