EDIT to show a difference from this:
This question is specifically about solving the "unresolved external symbol(s)" by making modifications to the project using the interface for Visual Studio 2017. It is aimed towards those who do not have the necessity to write C++ code on a regular basis and therefore are not concerned with the nuances of how C++ compiling works.
TL;DR - This serves to provide a concise solution to the issue of linking libraries with the VS2017 interface without bringing any attention to the nuances of unresolved symbols. The solution is at the bottom.
I'm taking a malware-reverse engineering course and the following function call is giving VS2017 some trouble linking.
handle_t iOpenH = InternetOpen(L"Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) totally not Malware",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);
The errors:
Severity Code Description Project File
Error LNK1120 1 unresolved externals fake-malware C:\Users\darrel\Documents\school\Spring 2018\COMP 220 - Software Rev Eng\Lab4\Lab4_Win32_API\Release\fake-malware.exe line: 1
Error LNK2001 unresolved external symbol __imp__InternetOpenW@20 fake-malware C:\Users\darrel\Documents\school\Spring 2018\COMP 220 - Software Rev Eng\Lab4\Lab4_Win32_API\fake-malware.obj line: 1
I've already cleaned and rebuilt to no avail. What should I do to resolve the two errors above?
EDIT 2: I just realized that the inherent meaning of the answers here are simple but not something that I was previously aware of having little experience with this sort of development, so I'll state it here in case you don't want to follow the link from @Anders below to remedy this problem:
When you use a library such as the Win32 API, you not only have to do the standard #include <headerName.h>
, but the linker may require a .lib
for the respective included library. In the instance we're working with wininet
. Therefore, as mentioned in a table within the link from the comment below, the header include is #include <wininet.h>
and the linker requires you to add wininet.lib
to the Linker's list of Additional Dependencies:
SOLUTION
Project > Proerties > Configuration Properties > Linker > Input > Additional Dependencies > add the necessary .lib
filename to the list.