so I have been trying to run a C++ program which requires Zlib library on compiling the file it gave an error saying "zlib.h no such file or directory exists" upon looking in usr/local/include i found that the file is not there can i just copy the file to that location or should i Install some thing. i am kinda new to ubuntu so please help
因此,我一直在尝试运行一个c++程序,它要求Zlib库编译它给出的错误“Zlib”。“在usr/local/include中查找时,没有这样的文件或目录”,我发现该文件不存在,我可以将文件复制到该位置,还是应该安装一些东西。我刚到ubuntu,所以请帮忙。
2 个解决方案
#1
8
Install zlib
with development support by using
使用开发支持安装zlib。
sudo apt-get install zlib1g-dev
In case you don't want or need to use the full zlib
, it is fairly easy to write wrapper routines which map the zlib
functions 1:1 to ordinary file functions which don't support compression and decompression.
如果您不想或者不需要使用完整的zlib,那么编写包装器例程很容易,它将zlib函数1:1映射到普通的文件函数,这些函数不支持压缩和解压。
//
// dummy zlib.h
//
#pragma once
#include <stdio.h>
typedef FILE *gzFile;
int gzclose(gzFile file);
gzFile gzdopen(int fd, const char *mode);
gzFile gzopen(const char *path, const char *mode);
int gzread(gzFile file, void *buf, unsigned int len);
//
// zlibDummy.cpp
//
#include <zlib.h>
int gzclose(gzFile file)
{
return fclose(file);
}
gzFile gzdopen(int fd, const char *mode)
{
return _fdopen(fd, mode);
}
gzFile gzopen(const char *path, const char *mode)
{
return fopen(path, mode);
}
int gzread(gzFile file, void *buf, unsigned int len)
{
return fread(buf, 1, len, file);
}
#2
1
Well, temporary solution
嗯,临时解决方案
download from : https://github.com/madler/zlib/blob/master/zlib.h
put the file in the same folder as your project file.
下载:https://github.com/madler/zlib/blob/master/zlib.h将文件放在与项目文件相同的文件夹中。
#include "zlib.h"
#1
8
Install zlib
with development support by using
使用开发支持安装zlib。
sudo apt-get install zlib1g-dev
In case you don't want or need to use the full zlib
, it is fairly easy to write wrapper routines which map the zlib
functions 1:1 to ordinary file functions which don't support compression and decompression.
如果您不想或者不需要使用完整的zlib,那么编写包装器例程很容易,它将zlib函数1:1映射到普通的文件函数,这些函数不支持压缩和解压。
//
// dummy zlib.h
//
#pragma once
#include <stdio.h>
typedef FILE *gzFile;
int gzclose(gzFile file);
gzFile gzdopen(int fd, const char *mode);
gzFile gzopen(const char *path, const char *mode);
int gzread(gzFile file, void *buf, unsigned int len);
//
// zlibDummy.cpp
//
#include <zlib.h>
int gzclose(gzFile file)
{
return fclose(file);
}
gzFile gzdopen(int fd, const char *mode)
{
return _fdopen(fd, mode);
}
gzFile gzopen(const char *path, const char *mode)
{
return fopen(path, mode);
}
int gzread(gzFile file, void *buf, unsigned int len)
{
return fread(buf, 1, len, file);
}
#2
1
Well, temporary solution
嗯,临时解决方案
download from : https://github.com/madler/zlib/blob/master/zlib.h
put the file in the same folder as your project file.
下载:https://github.com/madler/zlib/blob/master/zlib.h将文件放在与项目文件相同的文件夹中。
#include "zlib.h"