linux下怎么使用zlib库(主要是不会使用库)

haihai05 haihai05 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我下了zlib,解压放在了linux服务器下,自己编了个程序
#include <iostream>
#include <vector>
#include "zlib.h"
using namespace std;
int main()
{
const unsigned char strSrc[] = "jasddsfsfaffafasd";
unsigned char buff[1024] = {0}, strDst[1024] = {0};
unsigned long srcLen = sizeof(strSrc), bufLen = sizeof(buff), dstLen = sizeof(strDst);
//压缩
compress(buff, &bufLen, strSrc, srcLen);
//解压缩
uncompress(strDst, &dstLen, buff, bufLen);
cout << strDst << endl;
return 0;
}
但是程序编译出错
undefined reference to `compress'
undefined reference to `uncompress'

linux下不会使用库,所以出错了,哪位能帮我详细的说下linux下怎么使用库的。
...全文
评论 21
收藏 已收藏
分享
返回顶部
haihai05
Linux/Unix社区 23,224 成员 74,535 内容