我正在尝试在我的C应用程序中使用tidylib
库。编译时,我收到以下错误:
$ make
rm -f sbo-export
cc sbo-export.c safarilib.c -L/usr/local/lib -lcurl -L/usr/local/Cellar/libtidy/lib -I/usr/local/Cellar/libtidy/include -o sbo-export
Undefined symbols for architecture x86_64:
"_tidyCreate", referenced from:
_safari_init_session in safarilib-c7ab6a.o
"_tidyParseString", referenced from:
_safari_init_session in safarilib-c7ab6a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [default] Error 1
safarilib.c:
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <tidy/tidy.h>
#include <tidy/buffio.h>
#include <curl/curl.h>
#include "safarilib.h"
void usage( char *username, char *password )
{
TidyDoc tdoc = tidyCreate();
char *input = "<html><body><h1>Hello World!</h1></body></html>";
tidyParseString( tdoc, input );
}
有什么建议吗?
更多信息:
为了安装libtidy,我做了以下事情:
http://tidy.sourceforge.net
下载libtidy,然后tidy/build/readme.txt
我的图书馆安装在这里:
/usr/local/Cellar/libtidy
/usr/local/Cellar/libtidy/bin
/usr/local/Cellar/libtidy/bin/tab2space
/usr/local/Cellar/libtidy/bin/tidy
/usr/local/Cellar/libtidy/include
/usr/local/Cellar/libtidy/include/buffio.h
/usr/local/Cellar/libtidy/include/platform.h
/usr/local/Cellar/libtidy/include/tidy.h
/usr/local/Cellar/libtidy/include/tidyenum.h
/usr/local/Cellar/libtidy/lib
/usr/local/Cellar/libtidy/lib/libtidy-0.99.0.dylib
/usr/local/Cellar/libtidy/lib/libtidy.a
/usr/local/Cellar/libtidy/lib/libtidy.dylib
/usr/local/Cellar/libtidy/lib/libtidy.la
答案 0 :(得分:1)
从编译器选项看,你没有指定tidylib。
cc sbo-export.c safarilib.c -L/usr/local/lib -lcurl -L/usr/local/Cellar/libtidy/lib -I/usr/local/Cellar/libtidy/include -o sbo-export
在这里,您需要添加-ltidy
,可能还需要-L
添加路径。
有关linking的一些其他信息。