繁体   English   中英

链接:致命错误LNK1181:无法打开输入文件'libclamav.lib'

[英]LINK : fatal error LNK1181: cannot open input file 'libclamav.lib'

我正在使用Microsoft Visual Studio 2010,我正在开发Clamav,我的代码在下面给出了生成错误

#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'

请指导我

当在当前目录中找不到链接期间指定的.lib或.obj文件, LIBPATH链接器选项指定的任何目录或指定的任何目录时,Visual Studio中会出现LNK1181错误在LIB环境变量中。

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

  1. 在解决方案资源管理器中,右键单击该项目,然后单击“ 属性”
  2. 在“ 属性页”对话框中,展开“ 链接器” ,然后单击“ 常规”
  3. Additional Library Directories字段中,指定libclamav.lib所在的路径。

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

您也可以通过以DOS“8.3”格式指定库路径来修复它。

要获取8.3表单,请执行(在命令行中):

DIR /AD /X

递归地遍历每个级别的目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM