编译错误:未定义的引用

Compile error: undefined reference to

本文关键字:引用 未定义 错误 编译      更新时间:2023-10-16

我试图运行本页底部提供的代码:http://www.rolfmuertter.com/code/nw.php(main.cpp,nw.cpp和nw.h)。但是当我尝试编译时,我收到以下错误:

main.o: 在函数main': main.cpp:(.text+0x1b9): undefined reference to nw(std::string, std::string, std::string&

, std::string&, bool)'main.cpp:(.text+0x1e4):未定义对"print_al(std::string&, std::string&)"的引用collect2:错误:ld 返回 1 个退出状态

有什么建议吗?

我可以用下面的行编译它,所以你可能需要将nw.cpp添加到编译器行中。这是叮当声。

clang++ -Wall -o nw main.cpp nw.cpp