简体   繁体   中英

C++ Cannot open lib file

I'm using Microsoft Visual studio 2013. Trying to import DevIL library to load image files i'm getting LNK1104 error: Cannot open file "IL/devil.lib"

My Source.h file which include DevIL libs in Project/Sources directory while the DevIL libs in Project/Sources/IL directory. Here is my code

#ifdef _WIN32
#pragma comment(lib, "IL/devil.lib")
#pragma comment(lib, "IL/ilu.lib")
#pragma comment(lib, "IL/ilut.lib")
#endif

You just need to add your path lib file to Additional Library Directories in VS. Right click on your project, select Properties/Linker/General, then aim to your lib file in Additional Library Directories path.

请按照下面的图片。

You either have to remove the directory, and use the linker settings to specify the directory;

#pragma comment(lib, "devil.lib")

or you can use a hackish way using __FILE__ :

#pragma comment(lib, __FILE__"\\..\\IL\\devil.lib")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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