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

  先记一下,以后有时间再深入研究。

 

转载于:https://www.cnblogs.com/rhinoceros/archive/2012/02/08/2342752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值