gpt4 book ai didi

c - 我如何在 ubuntu 上用 Makefile 编译 C 程序?

转载 作者:太空宇宙 更新时间:2023-11-04 07:54:05 24 4
gpt4 key购买 nike

我正在尝试编译我在 github 上找到的一些程序。存储库位于以下 URL:[在此处输入链接描述][1]

https://github.com/iagox86/nbtool

我对 C 程序知之甚少,但是当我尝试通过以下命令使用 GCC 时,我收到错误消息。我试过的命令是:

gcc -o dnslogger dnslogger.c

我收到以下错误:

/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

存储库有一个 Makefile 文件,我怀疑它用于编译程序,但我不确定在 ubuntu 上使用的确切命令,我已经尝试了一些命令,但在使用提供的命令时收到错误文件。生成文件位于此处:

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

如何从 ubuntu 命令行编译这些程序?

最佳答案

只需运行make

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

不过,您需要一些程序来编译所有内容(样本)。(如果它们在您的系统中丢失,make 会提示)

如果您对 Makefile 本身更感兴趣,请使用评论中的链接或阅读特定文档,例如 Gnu Make(我选择了 Gnu Make,因为标签明确指定了 ubuntu)

关于c - 我如何在 ubuntu 上用 Makefile 编译 C 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51687972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com