开发者

Unresolved external symbols in compiling 32 bit application in Windows 64

So I am trying to compile legacy app from 32 bit to 64 bit.. I re-compiled all of the libs it used and made it look into WIN SDK6.0A x64 bit for libs..

I am using:

  • Visual Studio Professional Edition 2008
  • Visual C++
  • dotNet Framework 3.5 SP1
  • Win开发者_如何学编程dows Server 2008R2
  • Windows SDK is 6.0A

Everythings finally coming up but I am getting these weird undefined symbol errors:

error LNK2019: unresolved external symbol InterlockedDecrement referenced in function ...
error LNK2019: unresolved external symbol InterlockedIncrement referenced in function ...
error LNK2019: unresolved external symbol GetModuleBaseName referenced in ...
error LNK2019: unresolved external symbol EnumProcessModules referenced in ...
error LNK2019: unresolved external symbol EnumProcesses referenced in ...
error LNK2019: unresolved external symbol GetProcessMemoryInfo referenced 

The problem is these are all win stuff from SDK. InterlockedDec and InterlockedInc are coming from kernel32.lib GetModuleBaseName, EnumProcessModules, EnumProcesses,GetProcessMemoryInfo are in psapi.h but also kernel32.lib or psapi.lib

I checked C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64 and both libs kernel32.lib and psapi.lib are there.

It definitely looks up the libs at right spot. I turned on /VERBOSE:LIB and it points to the correct folder.

So I am really confused why isnt it finding them.

Any ideas???

Thanks


So I finally figured it out, kinda... It wasnt finding psapi.lib

In Project->Linker->Additional dependencies instead of just saying psapi.lib I gave full path to it and it worked... not really sure why it failed to find it before but oh well...


This is very long shot (and I don't really believe this is it) but maybe the headers are not properly guarded with extern "C" for c++ compilation? Are you including system headers or just declaring the functions yourself?


Can you post your compile and link command lines, and any #def's in your code?

Does this happen if you make a simple project from scratch that only calls one of those methods?


For the record: Same problem, different solution; I had an entry for the directory

psapi 

added in the list of

Linker/General/Additional Library Directory 

This resulted in the usage of the old VS2005 platform sdk psapi.lib (it only had x86, no x64 version). After removing the entry the correct lib from the installed WinSDK x64/psapi.lib is used now. So keep an eye out for mixings/ordering of old & new SDKs! Obviously the full path will also work but might be a problem when you use the project on multiple machines.


In my case(migrate from VS2008 to VS2012), issue solved after adding psapi.lib in Linker->input->Additional Dependencies in VS 2012.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜