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

I am using Microsoft Visual Studio 2010 and I am working with open source Clamav, below is the code that generates the 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; } 

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

kindly guide me

+7
c ++ c
source share
2 answers

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

You can add the directory containing the libclamav.lib library file to LIBPATH to solve the problem (this instruction may vary slightly depending on the version of Visual Studio):

  • In Solution Explorer, right-click the project and select Properties .
  • In the Page Properties dialog box, expand Linker , and then click General .
  • In the Additional directory libraries field, specify the path where libclamav.lib is located.

An error can also occur when LIBPATH contains spaces. If this happens, move the library to the path without spaces or place quotation marks around the path.

+14
source share

You can also fix this by specifying the library path in DOS format "8.3".

To get form 8.3, execute (at the command line):

 DIR /AD /X 

recursively through each directory level.

+1
source share

All Articles