[英]Using libspotify .dll/.lib files in MinGW32 compiling pySpotify
在Windows PC上使用MinGW32
我正在嘗試編譯pySpotify 。 第一個錯誤是libspotify/api.h
丟失了。 我通過將相應的文件夾從libspotify復制到C:\\MinGW\\include
修復此問題。 但是現在dllwrap
現在無法使用ld linking.
Spotify
分發的二進制文件是libspotify.dll
和libspotify.lib.
無論我把它們放在哪里(pySpotify文件夾/子文件夾,臨時構建文件夾/子文件夾和MinGW文件夾/子文件夾)或我命名它們(.a,.o和.so)它仍然顯示相同的錯誤消息。
相關的錯誤是:
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
您需要在include路徑中添加API頭(在編譯器選項中添加類似-I~ \\ libspotify \\ include的內容)和庫路徑中的共享庫(將-L~ \\ libspotify \\ lib添加到鏈接器選項中)。 這將允許編譯器找到必要的包含文件,並使鏈接器找到必要的二進制對象。
然而, distutils
Extension類似乎已被棄用且很難找到文檔(我相信這是自定義編譯器選項需要去的地方)。 感謝~
可能需要更改為%USERPROFILE%
或類似。 類似地, %PYTHONPATH%\\Lib\\distutils\\distutils.cfg
除了[build]
compiler=mingw32
節之外幾乎沒有文檔。 這使得編輯編譯/鏈接命令及其選項無法更改。
你如何在Windows上編譯pySpotify?
編輯:
通過使用Python 2.6並將libspotify.dll / libspotify.lib復制到C:\\ Python26 \\ PCbuild並將它們重命名為spotify.dll / libspotify.lib我現在從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
目前無法訪問mingw安裝,我可以提出一些建議。
首先,眾所周知, ld
對於參數的順序是挑剔的。 奇怪的是,當我用Google搜索“ld argument order”時,我得到了一堆頁面,暗示訂單無關緊要,但我已經被燒了好幾次了。 我通過以下參數順序取得了最大的成功:
ld
(即-Wall
) -LPATH
) -lspotify
) 我在鏈接器輸出中注意到對amd64的一些引用。 我不確定你是如何編譯你擁有的其他目標文件的,但是由於libspotify在Windows上是32位的,我猜這里混合使用32/64位並不會很好。
我能想到的最后一件事是,dll擴展可能會讓ld
感到困惑,您是否嘗試將文件名更改為libspotify.so
? 我知道這是在黑暗中的一種射擊,但否則我不知道如何進一步幫助你。
我猜你試圖將64位版本的pyspotify與32位版本的libspotify鏈接起來。 嘗試重建pyspotify,將-m32添加到CFLAGS和CXXFLAGS
我已經添加了一些指令,說明如何在問題的實際票證上編譯它。 讓我知道它是否對你有幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.