8

I have a C++ application that has embedded Python. I'm building with Visual Studio 2005. When I try to link to python26.lib, I get a number of unresolved symbols, all of which begin with "__imp":

error LNK2019: unresolved external symbol __imp__Py_Initialize referenced in function _main

python26.lib is an import library (installed by the Python 2.6 installer). What do I have to do to resolve these symbols? They do exist in the import library (dumpbin /all shows them). Thanks.

user76293
  • 559
  • 2
  • 5
  • 14

2 Answers2

13

Looks like I was trying to link a 64-bit Python library to a 32-bit application. I wish the linker would tell me something other than "unresolved symbol." Linking to the 32-bit library fixes the problem.

user76293
  • 559
  • 2
  • 5
  • 14
2

Try to include C:\WINDOWS\system32\python26.dll in your references. python26.lib contains the symbol names for the main DLL.

gimel
  • 83,368
  • 10
  • 76
  • 104
  • 1
    I thought you weren't supposed to link directly to dll's, but rather to the corresponding .lib. When I try to link directly to python26.dll, I get a linker error (LNK1107: invalid or corrupt file). According to MSDN, this error can occur if you pass a dll to the linker instead of a .obj. – user76293 Mar 18 '09 at 17:05