linux下C++将网页存为mht格式
这两天要在linux下将网页存为mht格式,拿到手之后顿时心生纠结,C++被我抛弃好久了,linux更是只捡起了一半,怎么办?硬着头皮上吧。
先在网上搜了一圈,找了好久找到了一个库可以帮助实现(准确说基本完全实现)这个,心中顿时大喜。库名叫Chilkat,http://www.chilkatsoft.com/mht-library.asp,有多重语言和平台的版本,除了mht还有很多其他的实现,不过我暂时还用不到。代码、教程、文档齐全,不错。
接下来就是把库下载下来,传到服务器上,按照教程安装,编译,然后用示例代码写就行了。但是写完后makefile的时候却报错了,报错信息如下:
[root@xxxx samples]# g++ -o mhttest mhttest.o -L/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib -lchilkat-9.3.0
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `pthread_mutexattr_destroy'
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `pthread_create'
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `__res_query'
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `pthread_mutexattr_settype'
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `pthread_mutexattr_init'
collect2: ld returned 1 exit status
纠结了好久,谁让咱的linux这么水呢?又在网上找了好久,然后咨询了大牛,发现是pthread的问题,要在头文件中包含pthread.h,makefile后面加-lpthread。本以为这样就完事了,结果还有
[root@xxxx samples]# g++ -o mhttest mhttest.o -L/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib -lchilkat-9.3.0 -lpthread
/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib/libchilkat-9.3.0.so: undefined reference to `__res_query'
collect2: ld returned 1 exit status
再次上网找了一下,后面加上-lresolv就好了。完整的makefile是:
g++ -o mhttest mhttest.o -L/home/nidongde/mht/chilkat-9.3.0-x86-linux-gcc/lib -lchilkat-9.3.0 -lpthread -lresolv
先记一下,以后有时间再深入研究。
posted on 2012-02-08 15:13 rhinoceros 阅读(443) 评论(0) 编辑 收藏 举报