我是LDNS的新手。我按照他们在README文件中显示的方法安装了ldns。我尝试使用他们的sample code,但每当我使用g ++ file.cpp编译它时,我都会收到以下错误。
在MACOS上使用带有Ubuntu的虚拟盒。
/tmp/ccxvsMSZ.o: In function `main':
dns.cpp:(.text+0x1e): undefined reference to `ldns_dname_new_frm_str'
dns.cpp:(.text+0x33): undefined reference to `ldns_resolver_new_frm_file'
dns.cpp:(.text+0x56): undefined reference to `ldns_resolver_query'
dns.cpp:(.text+0x70): undefined reference to `ldns_pkt_rr_list_by_type'
dns.cpp:(.text+0x80): undefined reference to `ldns_rr_list_sort'
dns.cpp:(.text+0x96): undefined reference to `ldns_rr_list_print'
dns.cpp:(.text+0xa2): undefined reference to `ldns_rr_list_deep_free'
dns.cpp:(.text+0xae): undefined reference to `ldns_pkt_free'
dns.cpp:(.text+0xba): undefined reference to `ldns_resolver_deep_free'
collect2: error: ld returned 1 exit status
知道我可能做错了吗?
P.S。:尝试在MAC上运行代码但出现以下错误。
Undefined symbols for architecture x86_64:
"_ldns_dname_new_frm_str", referenced from:
_main in dns-9f53eb.o
"_ldns_pkt_free", referenced from:
_main in dns-9f53eb.o
"_ldns_pkt_rr_list_by_type", referenced from:
_main in dns-9f53eb.o
"_ldns_resolver_deep_free", referenced from:
_main in dns-9f53eb.o
"_ldns_resolver_new_frm_file", referenced from:
_main in dns-9f53eb.o
"_ldns_resolver_query", referenced from:
_main in dns-9f53eb.o
"_ldns_rr_list_deep_free", referenced from:
_main in dns-9f53eb.o
"_ldns_rr_list_print", referenced from:
_main in dns-9f53eb.o
"_ldns_rr_list_sort", referenced from:
_main in dns-9f53eb.o
ld: symbol(s) not found for architecture x86_64
答案 0 :(得分:0)
编译时指定ldns(-lldns
)库。