C 在zlib函数中找不到符号
从标题开始,在编译时C 在zlib函数中找不到符号,c,symbols,zlib,C,Symbols,Zlib,从标题开始,在编译时 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <dirent.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #include <dirent.h> #
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <assert.h>
#include <zlib.h>
int main(){
char *infilename = "triples.txt.gz";
char *outfilename = "out_test.txt";
gzFile infile = gzopen(infilename, "rb");
FILE *outfile = fopen(outfilename, "wb");
if (!infile || !outfile) return -1;
char buffer[128];
int num_read = 0;
num_read = gzread(infile, buffer, sizeof(buffer));
while (num_read > 0) {
fwrite(buffer, 1, num_read, outfile);
}
gzclose(infile);
fclose(outfile);
return 0;
}
我弄不清它在说什么。zlib似乎是在修改代码时安装的,我在特定的zlib函数方面遇到了一些错误(比如gzopen没有足够的参数)。编译时没有链接zlib。假设zlib位于标准路径中,则需要编译为
gcc -lz -o c_test sometest.c
编译时没有链接zlib。假设zlib位于标准路径中,则需要编译为
gcc -lz -o c_test sometest.c
你是如何编译的?看起来你没有链接到
zlib
库,你是在编译/链接时添加-lz
吗?@FedericoklezCullocagcc-o c_test sometest.c
如何解决链接问题?尽可能地对C相当陌生see@L.Scott看到我之前的评论了吗?你是如何编译的?看起来你没有链接到zlib
library。说到这里,你是在编译/链接时添加-lz
吗?@FedericoklezCullocagcc-o c_test sometest.c
如何解决链接问题?尽可能地对C相当陌生see@L.Scott见我之前的评论