链接:致命错误LNK1181:无法打开输入文件'libclamav.lib' [英] LINK : fatal error LNK1181: cannot open input file 'libclamav.lib'

查看:322
本文介绍了链接:致命错误LNK1181:无法打开输入文件'libclamav.lib'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Visual Studio 2010,并且正在使用开源Clamav,下面给出了我的代码,这会产生错误

I am using Microsoft Visual Studio 2010, and i am working on open source Clamav, my code is given below which is generating an error

#include <stdio.h>
#include <stdlib.h>  
#include <string.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <clamav.h>


int main(int argc, char **argv)
{
int fd, ret;
unsigned long int size = 0;
unsigned int sigs = 0;
long double mb;
const char *virname;
struct cl_engine *engine;


if(argc != 2) {
printf("Usage: %s file\n", argv[0]);
return 2;
}

if((fd = open(argv[1], O_RDONLY)) == -1) {
printf("Can't open file %s\n", argv[1]);
return 2;
}

if((ret = cl_init(CL_INIT_DEFAULT)) != CL_SUCCESS) {
printf("Can't initialize libclamav: %s\n", cl_strerror(ret));
return 2;
}

if(!(engine = cl_engine_new())) {
printf("Can't create new engine\n");
return 2;
}

/* load all available databases from default directory */
if((ret = cl_load(cl_retdbdir(), engine, &sigs, CL_DB_STDOPT)) != CL_SUCCESS) {
printf("cl_load: %s\n", cl_strerror(ret));
close(fd);
    cl_engine_free(engine);
return 2;
}

printf("Loaded %u signatures.\n", sigs);

/* build engine */
if((ret = cl_engine_compile(engine)) != CL_SUCCESS) {
printf("Database initialization error: %s\n", cl_strerror(ret));;
    cl_engine_free(engine);
close(fd);
return 2;
}

/* scan file descriptor */
if((ret = cl_scandesc(fd, &virname, &size, engine, CL_SCAN_STDOPT)) == CL_VIRUS) {
printf("Virus detected: %s\n", virname);
} else {
if(ret == CL_CLEAN) {
    printf("No virus detected.\n");
} else {
    printf("Error: %s\n", cl_strerror(ret));
    cl_engine_free(engine);
    close(fd);
    return 2;
}
}
close(fd);

/* free memory */
cl_engine_free(engine);

/* calculate size of scanned data */
mb = size * (CL_COUNT_PRECISION / 1024) / 1024.0;
printf("Data scanned: %2.2Lf MB\n", mb);

return ret == CL_VIRUS ? 1 : 0;
}

会生成以下错误
LINK:致命错误LNK1181:不能打开输入文件'libclamav.lib'

the following error is generated LINK : fatal error LNK1181: cannot open input file 'libclamav.lib'

请引导我

推荐答案

当在当前目录(由 LIBPATH 链接器选项,或 LIB 环境变量中指定的任何目录。

You get an LNK1181 error in Visual Studio when the .lib or .obj files that are specified during linking are not found in the current directory, any of the directories that are specified by the LIBPATH linker option, or any of the directories that are specified in the LIB environment variable.

您可以将包含 libclamav.lib 库文件的目录添加到 LIBPATH 即可解决此问题(此说明可能会有所不同取决于您的Visual Studio版本):

You may add the directory that contains libclamav.lib library file to the LIBPATH to resolve the problem (this instructions may vary a bit depending on your Visual Studio version):


  1. 在解决方案资源管理器中,右键单击该项目,然后单击属性 >。

  2. 属性页对话框中,展开链接器,然后单击clic k 常规

  3. 其他库目录字段中,指定 libclamav.lib 驻留。

  1. In Solution Explorer, right-click the project, and then click Properties.
  2. In the Property Pages dialog box, expand Linker, and then click General.
  3. In the Additional Library Directories field, specify the path where libclamav.lib resides.

LIBPATH 包含空格。如果是这种情况,请将库移到没有空格的路径或在路径周围加上引号。

The error can also happen when the LIBPATH contains spaces. If that's the case, move the library to a path without spaces or put quotation marks around the path.

这篇关于链接:致命错误LNK1181:无法打开输入文件'libclamav.lib'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆