c++ tidy linker error

713 views Asked by At

I am new to c++ and I have the following problem:

files: - main.cpp - utils.h - utils.cpp

When I am doing:

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

when I try to link:

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

In utils.cpp I have a function clean_html. When I remove this function the code is linked with success.

I am using gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) .

Tidy is installed via fedora repos using: Package libtidy-devel-0.99.0-28.20091203.fc19.i686 already installed and latest version Package libtidy-0.99.0-28.20091203.fc19.i686 already installed and latest version

Edit:

Forgot to mention: - I include tidy.h using #include

tidy.h is at /usr/include/tidy.h

1

There are 1 answers

0
geert3 On BEST ANSWER

You need to add -ltidy to your link command.