2012-12-13 31 views
12

在Windows PC上使用MinGW32我試圖編譯pySpotify。第一個錯誤是libspotify/api.h丟失。我固定這通過從libspotify複製適當的文件夾到C:\MinGW\include。但是現在dllwrap現在與ld linking.失敗Spotify分發的二進制文件libspotify.dlllibspotify.lib.無論身在何處我把他們(pySpotify文件夾/子文件夾,臨時build文件夾/子文件夾和MinGW文件夾/子文件夾)還是什麼我他們的名字(.A ,.o & .so) it 仍顯示相同的錯誤消息。在MinGW32中使用libspotify .dll/.lib文件編譯pySpotify

相關的錯誤是:

C:\MinGW\bin\dllwrap.exe -mdll -static --output-lib build\temp.win32-2.7\Release\src\lib_spotify.a --def build\temp.win32-2.7\Release\src\_spotify.def -s build\temp.win32-2.7\Release\src\module.o build\temp.win32-2.7\Release\src\session.o build\temp.win32-2.7\Release\src\link.o build\temp.win32-2.7\Release\src\track.obuild\temp.win32-2.7\Release\src\album.o build\temp.win32-2.7\Release\src\albumbrowser.o build\temp.win32-2.7\Release\src\artist.o build\temp.win32-2.7\Release\src\artistbrowser.o build\temp.win32-2.7\Release\src\search.o build\temp.win32-2.7\Release\src\playlist.o build\temp.win32-2.7\Release\src\playlistcontainer.o build\temp.win32-2.7\Release\src\playlistfolder.o build\temp.win32-2.7\Release\src\image.o build\temp.win32-2.7\Release\src\user.o build\temp.win32-2.7\Release\src\pyspotify.o build\temp.win32-2.7\Release\src\toplistbrowser.o -LC:\Python26\libs -LC:\Python26\PCbuild -lspotify -lpython26 -lmsvcr90 -o build\lib.win32-2.7\spotify\_spotify.pyd 
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -lspotify 
collect2.exe: error: ld returned 1 exit status 
dllwrap: gcc exited with status 1 
error: command 'dllwrap' failed with exit status 1 

bok says on github說:

您需要添加API標題中包含路徑(添加類似-I〜\ libspotify \包括您編譯器選項)和庫路徑中的共享庫(將-L〜\ libspotify \ lib添加到鏈接器選項中)。這將允許編譯器找到必要的包含文件,並使您的鏈接器找到必要的二進制對象。

然而distutils擴展類似乎被棄用,很難找到文檔(我相信這是在自定義的編譯器選項需要去)。欣賞~可能需要更改爲%USERPROFILE%或類似。同樣%PYTHONPATH%\Lib\distutils\distutils.cfg[build]compiler=mingw32節以外幾乎沒有文檔。這使得編譯compile/link命令及其選項無法改變。

如何在Windows上編譯pySpotify?

編輯:

通過使用Python 2.6和複製libspotify.dll/libspotify.lib到C:\ Python26 \ PCbuild和重命名他們spotify.dll/libspotify.lib我現在得到另一個錯誤信息from ld:

C:\MinGW\bin\dllwrap.exe -mdll -static --output-lib build\temp.win32-2.6\Release\src\lib_spotify.a --def build\temp.win32-2.6\Release\src\_spotify.def -s build\temp.win32-2.6\Release\src\module.o build\temp.win32-2.6\Release\src\session.o build\temp.win32-2.6\Release\src\link.o build\temp.win32-2.6\Release\src\track.obuild\temp.win32-2.6\Release\src\album.o build\temp.win32-2.6\Release\src\albumbrowser.o build\temp.win32-2.6\Release\src\artist.o build\temp.win32-2.6\Release\src\artistbrowser.o build\temp.win32-2.6\Release\src\search.o build\temp.win32-2.6\Release\src\playlist.o build\temp.win32-2.6\Release\src\playlistcontainer.o build\temp.win32-2.6\Release\src\playlistfolder.o build\temp.win32-2.6\Release\src\image.o build\temp.win32-2.6\Release\src\user.o build\temp.win32-2.6\Release\src\pyspotify.o build\temp.win32-2.6\Release\src\toplistbrowser.o -LC:\Python26\libs -LC:\Python26\PCbuild -lspotify -lpython26 -lmsvcr90 -o build\lib.win32-2.6\spotify\_spotify.pyd 
_spotify.exp: file not recognized: File format not recognized 
collect2.exe: error: ld returned 1 exit status 
dllwrap: gcc exited with status 1 
error: command 'dllwrap' failed with exit status 1 
+0

也許mingw的ld沒有正確讀取絕對路徑?也就是說,嘗試移動libspotify到一個相對的位置,看看這是否沒有幫助。 –

+0

嗨尼克,感謝您的建議 - 但我已經試過複製到每個文件夾/子文件夾,我可以找到無濟於事:「無論我把它們放在哪裏(pySpotify文件夾/子文件夾,臨時構建文件夾/子文件夾和MinGW文件夾/子文件夾)「。 – Metalshark

回答

1

此刻沒有訪問mingw安裝,我可以推薦幾件事情。

首先,ld被稱爲挑剔的論據順序。奇怪的是,當我搜索「ld argument order」時,我收到了大量的頁面,提示順序無關緊要,但是我被這個問題燒了好幾次。我已經與以下參數秩序的最成功的:

  1. 切換到ld(即-Wall
  2. 庫搜索路徑(即-LPATH
  3. 目標文件
  4. 庫(即-lspotify

我在鏈接器輸出中注意到了一些對amd64的引用。我不確定你是如何編譯其他目標文件的,但是由於libspotify在Windows上是32位的,我猜測在這裏混合32/64位不會太好。

我能想到的最後一件事是,dll擴展名可能會讓您感到困惑ld,您是否嘗試將文件名更改爲libspotify.so?我知道這是黑暗中的一種鏡頭,但除此之外,我不知道如何進一步幫助你。

+0

我嘗試將這兩個文件重命名爲.so,.a和.o。當我嘗試使用MinGW64時,它抱怨它無法編譯,所以現在我正在使用MinGW(在64位Windows上)。使用構建腳本,我無法訪問作爲問題一部分的參數排序。 – Metalshark

1

我想你正試圖鏈接64位版本的pyspotify和32位版本的libspotify。嘗試重建pyspotify添加-m32到CFLAGS和CXXFLAGS

+0

我不知道如何通過setup.py(pySpotify的構建腳本)訪問CFLAG/CXXFLAGS。 – Metalshark

+0

CFLAGS = -m32 python setup.py應該可以做到。還要確保你已經安裝了一個32位的Python。請注意,這個問題可能會被顛倒過來:也許pyspotify是以32位編譯的,libspotify是64位的。 – alexp

+0

''CFLAGS'不被識別爲內部或外部命令,可操作程序或批處理文件.'是在Windows上收到的錯誤(知道這在* nix上有效)。我打算使用環境變量並檢查python是32位的。 – Metalshark

0

我已經添加了一些指示,說明如何在實際故障單上編譯它。讓我知道它是否對你有幫助!

https://github.com/mopidy/pyspotify/issues/63

+0

請注意,[只有鏈接的答案](http://meta.stackoverflow.com/tags/link-only-answers/info)不鼓勵,所以答案應該是搜索解決方案的終點(vs.而另一個引用的中途停留時間往往會隨着時間推移而過時)。請考慮在此添加獨立的摘要,並將鏈接保留爲參考。 – kleopatra

+0

我剛剛創建了一個帳戶,我可以發佈的最大鏈接數量是兩個。我在解決方案中有幾個鏈接,所以我認爲讓所有信息完好無損的最佳方式是發佈鏈接到實際的票證,我發佈了我的解決方案。 – JDurman

+0

重點是在這裏發佈_solution_(與發佈鏈接到其他地方的解決方案:-) – kleopatra