I don't understand how Visual Studio (2015 for me) can detect the .lib file name from the header file.
Example 1
I use boost/asio
to write a simple program to connect via HTTP request. The source file includes <boost/asio.hpp>
on top of it. I also config C/C++ / General / Additional Include Directories
to point to boost's folder.
After that, I build the solution and encounter an error:
Error LNK1104 cannot open file 'libboost_system-vc140-mt-gd-1_61.lib'
But I don't know where Visual Studio finds the name libboost_system-vc140-mt-gd-1_61.lib
from.
- Looking in Linker / Input / Additional Dependencies / Edit...
for both Evaluated Value and Inherited values, there is no item named libboost_system-vc140-mt-gd-1_61.lib
- I think that in <boost/asio.hpp>
by somehow it set some information to the compiler that: "If you need lib file, look for libboost_system-vc140-mt-gd-1_61.lib, it is the implementation of mine", but I search in boost folder, there is no source file contain "libboost_system-vc140-mt-gd-1_61.lib"
By generally, if some function declared in a header file, and Visual Studio can't file the implement of it, the LNK2019: unresolved external symbol ...
will be throw.
Then if its implement is in abcxyz.lib
file, the user goes to Linker / Input / Additional Dependencies
and add abcxyz.lib
, without specifying the folder contain the .lib file in Linker / General / Additional Libary Directories
. In this situation, the Error LNK1104 cannot open file 'abcxyz.lib'
will be thrown
So, why the above example encounter the LNK1104 error instead of LNK2019 error?
Example 2
I'm working for a project that use OpenCV 2.4.10 library. In the distribution, they give me the project with source code but without attaching the library to me.
Then, I download the latest OpenCV 2.4.13 and set up for the project, such as additional include folder, additional library folder, Additional Dependencies (opencv_core2413.lib
).
Everything looks like ok, but when I build the project, it gives me the error:
Error LNK1104 cannot open file 'opencv_core2410d.lib'
I have looked at Linker \ Input \ Additional Dependencies
on both Evaluated value (contain opencv_core2413.lib) and Inherited value, but there is no item named 'opencv_core2410d.lib'.
Try looking in another shared Property Sheet that the project apply but there is no entry item named 'opencv_core2410d.lib'
I want to delete this entry but can't find where it is
So, what's happen here? Any one can explain for me? Thanks