Build Python package with C bindings in Windows (VC90) causes LNK1181 fatal error
Asked Answered
A

1

1

I'm trying to build a Python package (pyspotify) with bindings to a C library (libspotify).

I'm using Python 2.7.5 and have installed VS2008 Express for some required commandline tools.

When I call python setup.py build from the Command Prompt (with Admin rights) I get the following output:

running build
running build_py
running build_ext
building 'spotify._spotify' extension

And then ~18 of these, one for each .c file in the package:

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Isrc -Ic:\Python\Python27\include -Ic:\Python\Python27\PC
/Tcsrc\module.c /Fobuild\temp.win32-2.7\Release\src\module.obj
module.c

And then the showstopper:

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo
/INCREMENTAL:NO /LIBPATH:c:\Python\Python27\libs /LIBPATH:c:\Python\Python27\PCb
uild spotify.lib /EXPORT:init_spotify build\temp.win32-2.7\Release\src\module.ob
j build\temp.win32-2.7\Release\src\session.obj build\temp.win32-2.7\Release\src\
link.obj build\temp.win32-2.7\Release\src\track.obj build\temp.win32-2.7\Release
\src\album.obj build\temp.win32-2.7\Release\src\albumbrowser.obj build\temp.win3
2-2.7\Release\src\artist.obj build\temp.win32-2.7\Release\src\artistbrowser.obj
build\temp.win32-2.7\Release\src\search.obj build\temp.win32-2.7\Release\src\pla
ylist.obj build\temp.win32-2.7\Release\src\playlistcontainer.obj build\temp.win3
2-2.7\Release\src\playlistfolder.obj build\temp.win32-2.7\Release\src\image.obj
build\temp.win32-2.7\Release\src\user.obj build\temp.win32-2.7\Release\src\pyspo
tify.obj build\temp.win32-2.7\Release\src\toplistbrowser.obj /OUT:build\lib.win3
2-2.7\spotify\_spotify.pyd /IMPLIB:build\temp.win32-2.7\Release\src\_spotify.lib
 /MANIFESTFILE:build\temp.win32-2.7\Release\src\_spotify.pyd.manifest
LINK : fatal error LNK1181: cannot open input file 'spotify.lib'
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.
exe"' failed with exit status 1181

And I have tried to search for this LNK1181 error, but all answers seems to be about remembering quotes around string, or some settings in VS which I in this case has no control over.

Anarthria answered 18/8, 2013 at 6:56 Comment(3)
"LINK : fatal error LNK1181: cannot open input file 'spotify.lib'"Touchline
Is spotify.lib on your LIB path?Dupre
I don't know where spotify.lib is supposed to be, so no, I don't think so. Is it a VS generated file?Anarthria
I
3

You need to download the appropriate version of libspotify from here unzip it and put it in the same directory that you are trying to build in, (easiest place), or tell VS where to find it.

Isidor answered 18/8, 2013 at 7:13 Comment(1)
This looks like a solution. I already had the libspotify.lib file there, but had to rename it to spotify.lib before it worked. Thanks :)Anarthria

© 2022 - 2024 — McMap. All rights reserved.