简体   繁体   English

如何在ubuntu上使用Makefile编译C程序?

[英]How can i compile C programs with Makefile on ubuntu?

I am trying to compile some programs i have found on github. 我正在尝试编译一些我在github上找到的程序。 The repository is at the following URL: [enter link description here][1] 存储库位于以下URL:[在此处输入链接描述] [1]

https://github.com/iagox86/nbtool https://github.com/iagox86/nbtool

I have little knowledge of C programs, however when i try to use GCC with the following command i receive errors. 我对C程序知之甚少,但是,当我尝试通过以下命令使用GCC时,会收到错误消息。 the command i have tried is: 我尝试过的命令是:

gcc -o dnslogger dnslogger.c

I receive the following error: 我收到以下错误:

/tmp/ccLRFQbp.o: In function `dns_callback':
dnslogger.c:(.text+0x51): undefined reference to `dns_create_from_packet'
dnslogger.c:(.text+0x5f): undefined reference to `dns_create'
dnslogger.c:(.text+0x10e): undefined reference to `dns_add_question'
dnslogger.c:(.text+0x179): undefined reference to `dns_add_answer_A'
dnslogger.c:(.text+0x1dc): undefined reference to `dns_add_answer_AAAA'
dnslogger.c:(.text+0x214): undefined reference to `dns_to_packet'
dnslogger.c:(.text+0x236): undefined reference to `udp_send'
dnslogger.c:(.text+0x260): undefined reference to `dns_create_error_string'
dnslogger.c:(.text+0x282): undefined reference to `udp_send'
dnslogger.c:(.text+0x28e): undefined reference to `safe_free'
dnslogger.c:(.text+0x29a): undefined reference to `dns_destroy'
dnslogger.c:(.text+0x2a6): undefined reference to `dns_destroy'
/tmp/ccLRFQbp.o: In function `dns_poll':
dnslogger.c:(.text+0x2d7): undefined reference to `select_group_create'
dnslogger.c:(.text+0x304): undefined reference to `select_group_add_socket'
dnslogger.c:(.text+0x321): undefined reference to `select_set_recv'
dnslogger.c:(.text+0x336): undefined reference to `select_group_do_select'
/tmp/ccLRFQbp.o: In function `cleanup':
dnslogger.c:(.text+0x36b): undefined reference to `select_group_destroy'
dnslogger.c:(.text+0x37a): undefined reference to `safe_free'
dnslogger.c:(.text+0x384): undefined reference to `print_memory'
/tmp/ccLRFQbp.o: In function `main':
dnslogger.c:(.text+0x6ed): undefined reference to `safe_malloc_internal'
dnslogger.c:(.text+0x718): undefined reference to `winsock_initialize'
dnslogger.c:(.text+0x934): undefined reference to `dns_do_test'
dnslogger.c:(.text+0xaab): undefined reference to `udp_create_socket'
dnslogger.c:(.text+0xb5f): undefined reference to `drop_privileges'
collect2: error: ld returned 1 exit status

the repository has a Makefile file which i suspect is used to compile the programs, but i am not sure of the exact commands to use on ubuntu, i have tried some of the commands but i receive errors when using the supplied commands from the file. 该存储库中有一个Makefile文件,我怀疑它是用来编译程序的,但是我不确定要在ubuntu上使用的确切命令,我尝试了一些命令,但是在使用文件中提供的命令时收到错误。 the makefile is located here: makefile位于:

https://github.com/iagox86/nbtool/blob/master/Makefile https://github.com/iagox86/nbtool/blob/master/Makefile

How can i compile these programs from ubuntu command line? 如何从ubuntu命令行编译这些程序?

Just run make . 只需运行make

git clone https://github.com/iagox86/nbtool
cd nbtool
make

You need some programs to compile everything (samples) though. 但是,您需要一些程序来编译所有内容(样本)。 (make will complain if they're missing on your system) (如果您的系统缺少它们,make将会进行投诉)

If you're more interested in the Makefile itself, use the links in the comments or read specific documentation for example Gnu Make (I chose Gnu Make, as tags specify ubuntu explicitly) 如果您对Makefile本身更感兴趣,请使用注释中的链接或阅读特定的文档,例如Gnu Make (我选择了Gnu Make,因为标记明确指定了ubuntu)

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

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