Click here to Skip to main content
11,790,904 members (66,073 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ Visual-Studio
I have a program that links to a static library. This library has exported global variable.
This variable is defined in the .def file, but I get the following error:
unresolved external symbol __imp_XXX (where XXX is the variable name).

Does anyone knows the reason for that?
Posted 21-Apr-13 9:10am
RedDK at 21-Apr-13 15:24pm
Add the 8 characters "/VERBOSE" to the linker "Command Line"/"Additional Options". The next time you try to link a list of addresses the program is locating to search for that (assume) mangled variable name should make it clear that the where of the output you've compiled might not be there.
Michael Haephrati at 21-Apr-13 15:26pm
I have done that, and the first time the variable is mentioned, is at the end, with the same error message:
unresolved external symbol __imp_XXX (where XXX is the variable name).

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

In my case, what solved the problem was making sure that I only use $(SolutionDir)$(Platform)\$(Configuration)\ at any place that libraries are imported. Smile | :)
RedDK at 21-Apr-13 16:26pm
Well, the thing is this. The linker is looking for this symbol and it's going through all the .lib that it can find. If you don't have the path explicitly named somewhere then the linker doen't know to look there.

I'd say to you try experimenting with an example that you've knowingly excluded the "look-in" variable. Compare that result from the Output tell to the pattern you got back when this missing library symbol couldn't be found. Any similarities? Etc ...
Michael Haephrati at 21-Apr-13 16:51pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 ppolymorphe 385
2 Richard MacCutchan 118
3 Jochen Arndt 80
4 Maciej Los 70
0 OriginalGriff 1,329
1 Maciej Los 835
2 ppolymorphe 780
3 KrunalRohit 686
4 CPallini 661

Advertise | Privacy | Mobile
Web01 | 2.8.1509028.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100