简体   繁体   English

我不明白为什么这个程序不能编译

[英]I don't understand why this program don't compile

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?我正在尝试制作一个像“.Remindme”reddit 机器人这样的机器人,我发现这个 Web Scrapper 用 C 编写,但我不明白为什么它不能编译? 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.即使使用标志 -fPIE 它也不起作用,我很困惑为什么。 Any help?有什么帮助吗? :) :)

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. linker /usr/bin/ld正在谈论一些对象文件(直接和来自存档)必须事先使用-fPIE编译才能工作。

You will need to install liburiparser ( liburiparser-dev on ubuntu), and run the following command:您需要安装liburiparser (ubuntu 上liburiparser-dev ),并运行以下命令:

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.我建议你不要使用那些在其他系统上编译的.o 文件,很可能是使用不同的 CPU 架构。

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.旁注:我发现您正在使用https://github.com/iceman201/Web_Scraper ,并且似乎他们没有配置的.gitignore 来忽略这些是这里混乱的根源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM