Visual Studio linking error with .lib files

Recently when I was developing a small python extension code , I faced a linking error. I looked into the functions and other things. Everything was looking good. In the end, I noticed that library I am including is for different architecture.

1>     Creating library D:\kernelcode\Release\kernelcode.lib and object D:\kernelcode\Release\kernelcode.exp
1>Kernelcode.obj : error LNK2001: unresolved external symbol __imp__Py_BuildValue
1>Kernelcode.obj : error LNK2001: unresolved external symbol __imp__PyArg_ParseTuple
1>Kernelcode.obj : error LNK2001: unresolved external symbol __imp__PyErr_NewException
1>Kernelcode.obj : error LNK2001: unresolved external symbol __imp__PyModule_AddObject
1>Kernelcode.obj : error LNK2001: unresolved external symbol __imp__Py_InitModule4
1>D:\kernelcode\Release\kernelcode.dll : fatal error LNK1120: 5 unresolved externals

All you need to do is find the binary type and include the correct .lib file. How can we find the correct .lib file ? Run the .lib file under dumpbin and get the architecture type.

eg,
C:\ActivePython27>DUMPBIN /HEADERS libs/python27.lib

Dump of file libs/python27.lib

File Type: LIBRARY

FILE HEADER VALUES
           8664 machine (x64)
               3 number of sections

Advertisements
This entry was posted in python, Windows, Windows VC++ and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s