C++ 整洁链接器错误

标签 c++ tidy

我是 c++ 新手,遇到以下问题:

文件: - main.cpp -utils.h - 实用程序.cpp

当我在做的时候:

g++ -c -std=c++11 utils.cpp(编译) g++ -c -std=c++11 main.cpp(编译)

当我尝试链接时:

g++ -o main.o utils.o

/usr/lib/gcc/i686-redhat-linux/4.8.3/../../../crt1.o: In function _start': (.text+0x18): undefined reference tomain' utils.o: In function clean_html(std::string const&)': utils.cpp:(.text+0xfa): undefined reference totidyCreate' utils.cpp:(.text+0x118): undefined reference to tidyOptSetBool' utils.cpp:(.text+0x13b): undefined reference totidyOptSetBool' utils.cpp:(.text+0x15e): undefined reference to tidyOptSetBool' utils.cpp:(.text+0x181): undefined reference totidyOptSetBool' utils.cpp:(.text+0x1a4): undefined reference to tidyOptSetBool' utils.cpp:(.text+0x1c7): undefined reference totidyOptSetValue' utils.cpp:(.text+0x1ea): undefined reference to tidyOptSetValue' utils.cpp:(.text+0x209): undefined reference totidyOptSetBool' utils.cpp:(.text+0x228): undefined reference to tidyOptSetBool' utils.cpp:(.text+0x247): undefined reference totidyOptSetInt' utils.cpp:(.text+0x281): undefined reference to tidyParseString' utils.cpp:(.text+0x295): undefined reference totidyCleanAndRepair' utils.cpp:(.text+0x2b0): undefined reference to tidySaveBuffer' utils.cpp:(.text+0x322): undefined reference totidyBufFree' utils.cpp:(.text+0x32d): undefined reference to `tidyRelease' collect2: error: ld returned 1 exit status

在 utils.cpp 中我有一个函数 clean_html。当我删除此功能时,代码会成功链接。

我使用的是 gcc 版本 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC)。

Tidy 是通过 fedora repos 安装的,使用: 软件包 libtidy-devel-0.99.0-28.20091203.fc19.i686 已经安装并且是最新版本 软件包 libtidy-0.99.0-28.20091203.fc19.i686 已经安装并且是最新版本

编辑:

忘了说: - 我包括 tidy.h 使用 #包括

tidy.h 位于/usr/include/tidy.h

最佳答案

您需要将 -ltidy 添加到您的链接命令。

关于C++ 整洁链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27136772/

相关文章:

html - xsltproc html 文档

notepad++ - 使用 Tidy2 for Notepad++

c++ - 模板范围问题代码无法编译

c++ - multimap 累积值

c++ - 如果参数采用引用,在函数参数中传递 *this 会导致内存泄漏吗?

Php 找不到 tidy

xml - 整洁的标签后没有换行符

c++ - 接受对话框时如何调用带有参数的插槽?

c++ - ../main : error while loading shared libraries: libopencv_highgui. so.4.0: 无法打开共享对象文件: 没有这样的文件或目录