Visual studio 2019 cannot correct any open external symbol (VerQueryValueW), (GetFileVersionInfoW), and (GetFileVersionInfoSizeW).

Asked 1 years ago, Updated 1 years ago, 32 views

I tried using the linked source code below to get the version from the resource, but an error similar to the title occurred.

Get version information with C++

I have tried to include various files and looked them up on other similar sites, but it has not been resolved.
Thank you for your assistance.

c++

2022-09-30 20:26

3 Answers

Unresolved external symbol (VerQueryValueW), (GetFileVersionInfoW) and (GetFileVersionInfoSizeW) reference errors

Error messages such as 未Unresolved External Symbols~ 」 indicate link issues, not compile time.

For example, if you look at the GetFileVersionInfoW function specification in the document, you will need Windows.h for header files to be included from the source code, and Version.lib for library files to be added at link.

Header: winver.h(include Windows.h)
Library:Version.lib


2022-09-30 20:26

In this case, please get into the habit of looking at the official page (Microsoft MSDN). Search VerQueryValue to find the Microsoft commentary page.
VerQueryValueW
Then, in the Requirement column, there is a description of Header and Library.

(Not applicable this time) When compiling with the error Unproposed Symbol, the addition of Header on the source code is omitted.Add #include where appropriate.In this example, the description page is difficult to read, but it says #include<windows.h> (although the declaration itself is in winver.h, not directly in #include<winver.h>). # It's hard to know where "appropriate" is when using a precompile header.

(This time, this is the case.) If there is an error with an unresolved symbol on the link, add Library on the description page. There is an explanation to add version.lib.Now, how do I add it? But I will add it from the menu bar project (P) → property (P) on the IDE screen of VS2019.The properties page screen opens, so if you select Linker → Input in the left pane, you will see a lot of additional dependency files in the right pane.There should be no version.lib here, so I will add it to the appropriate location.If you look closely, you can see that the delimiter is ;, so you can add it like version.lib; kernel32.lib;.... to make the link pass (it depends on whether you add it first or at the end, but either is acceptable in this example).

However, if you look closely at this property page, there are "Configuration" and "Platform" at the top.Configuration includes Debug and Release and PlatformsWin32 and x64 (x64 may not appear) We recommend that you make additional changes to all four property pages in two x2.


2022-09-30 20:26

The reasons and actions have already been answered, but there is a simplified way to do so with Visual C++ only.

This article explains how to specify in the source code the libraries linked by instructions to the preprocessor.
comment pragma
lib

Place the library search records in the object file.

Example

# pragma comment (lib, "emapi")

If you apply the above to match your questions, you can build whatever mode you choose, regardless of how many platforms (Win32/x86/x64/other) or configurations (Debug/Release/other) are in the project properties, by following the #include on the source code.

#pragma comment(lib, "version")


2022-09-30 20:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.