2011-07-29 26 views
1

我試圖安裝p4python,這是Perforce版本控制系統的Python擴展。因爲p4python需要P4 C++ API(它實際上只是一個包裝器),而這又需要g ++(更不用說,Python擴展需要C編譯器,因此gcc),所以我使用cygwin來實現此目的。我在Windows 7 64位(不是選擇),微軟VS 2008給了我一些相當頑固的問題;我聽說使用Cygwin/MinGW可能是更好的路線。我也尋找相關的問題,他們似乎沒有一個特別相關的答案。ld在cygwin下無法找到存在的庫

我能想到的最好的事情是,ld正在尋找這些庫的錯誤位置,並且我被告知Cygwin不能很好地處理符號鏈接,但我不確定從哪裏去。見下文端子輸出:

 
API Release 2010.2 
running install 
running build 
running build_py 
running build_ext 
building 'P4API' extension 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c P4API.cpp -o build/temp.cygwin-1.7.9-i686-2.6/P4API.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c PythonClientAPI.cpp -o build/temp.cygwin-1.7.9-i686-2.6/PythonClientAPI.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c PythonClientUser.cpp -o build/temp.cygwin-1.7.9-i686-2.6/PythonClientUser.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
PythonClientUser.cpp: In member function ‘virtual int PythonClientUser::Resolve(ClientMerge*, Error*)’: 
PythonClientUser.cpp:423: warning: deprecated conversion from string constant to ‘char*’ 
PythonClientUser.cpp:423: warning: deprecated conversion from string constant to ‘char*’ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c SpecMgr.cpp -o build/temp.cygwin-1.7.9-i686-2.6/SpecMgr.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
SpecMgr.cpp: In member function ‘PyObject* SpecMgr::NewSpec(StrPtr*)’: 
SpecMgr.cpp:550: warning: deprecated conversion from string constant to ‘char*’ 
SpecMgr.cpp:550: warning: deprecated conversion from string constant to ‘char*’ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c P4Result.cpp -o build/temp.cygwin-1.7.9-i686-2.6/P4Result.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
P4Result.cpp: In destructor ‘P4Result::~P4Result()’: 
P4Result.cpp:49: warning: suggest explicit braces to avoid ambiguous ‘else’ 
P4Result.cpp:52: warning: suggest explicit braces to avoid ambiguous ‘else’ 
P4Result.cpp:55: warning: suggest explicit braces to avoid ambiguous ‘else’ 
P4Result.cpp: In member function ‘void P4Result::Reset()’: 
P4Result.cpp:71: warning: suggest explicit braces to avoid ambiguous ‘else’ 
P4Result.cpp:75: warning: suggest explicit braces to avoid ambiguous ‘else’ 
P4Result.cpp: In member function ‘void P4Result::Fmt(const char*, PyObject*, StrBuf&)’: 
P4Result.cpp:189: warning: deprecated conversion from string constant to ‘char*’ 
P4Result.cpp:189: warning: deprecated conversion from string constant to ‘char*’ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c PythonMergeData.cpp -o build/temp.cygwin-1.7.9-i686-2.6/PythonMergeData.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c P4MapMaker.cpp -o build/temp.cygwin-1.7.9-i686-2.6/P4MapMaker.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DID_OS="CYGWINX86" -DID_REL="2009.2" -DID_PATCH="240822" -DID_API="2010.2" -DID_Y="2010" -DID_M="04" -DID_D="02" -IC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -IC:\Pyt 
hon\p4api\p4api-2010.2.295040-vs2010_static\/include/p4 -I/usr/include/python2.6 -c PythonSpecData.cpp -o build/temp.cygwin-1.7.9-i686-2.6/PythonSpecData.o -DOS_CYGWIN -DOS_CYGWIN -DOS_CYGWINX86 -DOS_CYGWINX86 
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ 
g++ -shared -Wl,--enable-auto-image-base build/temp.cygwin-1.7.9-i686-2.6/P4API.o build/temp.cygwin-1.7.9-i686-2.6/PythonClientAPI.o build/temp.cygwin-1.7.9-i686-2.6/PythonClientUser.o build/temp.cygwin-1.7.9-i686-2.6/SpecMgr.o build/temp.cygwin-1.7. 
9-i686-2.6/P4Result.o build/temp.cygwin-1.7.9-i686-2.6/PythonMergeData.o build/temp.cygwin-1.7.9-i686-2.6/P4MapMaker.o build/temp.cygwin-1.7.9-i686-2.6/PythonSpecData.o -LC:\Python\p4api\p4api-2010.2.295040-vs2010_static\ -LC:\Python\p4api\p4api-2010 
.2.295040-vs2010_static\/lib -L/usr/lib/python2.6/config -lclient -lrpc -lsupp -lpython2.6 -o build/lib.cygwin-1.7.9-i686-2.6/P4API.dll 
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lclient 
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lrpc 
/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lsupp 
collect2: ld returned 1 exit status 
error: command 'g++' failed with exit status 1

下面給出更具體的問題,爲LD找錯了地方或者別的事情不對的,我沒有看到?我沒有想法。任何幫助或指導將非常感激。

+0

聽起來像庫libclient.a,librpc.a和libsipp.a不存在。他們呢?如果是這樣,他們在什麼目錄? –

+0

它們確實存在,但它們是.lib文件。 (關於.lib - > .a,從A點到B點不是100%)它們位於C++ API目錄的/ lib目錄中。 – ambagesia

+0

只是爲了澄清 - 圖書館本身的來源?這是一個包含第三方C++ API的第三方Python擴展。 – ambagesia

回答

3

下面是我用來打開LIB文件到共享libraies使用與海灣合作委員會的方式:

  1. echo EXPORTS > NAME.def
  2. nm NAME.lib | grep ' T _' | sed 's/.* T _//' >> NAME.def
  3. dlltool --input-def NAME.def --dllname NAME --output-lib libNAME.a

上使用Cygwin其它注意事項(但是我在一個較老的32位系統上使用gcc 3,所以YMMV):

安裝gcc-mingw軟件包(用於gcc和g ++ 3的mingw的頭文件和庫)或使用mingw-w64用於gcc 4.5的新軟件包之一。另外,編譯選項-mno-cygwin以防止將Cygwin鏈接到可執行文件/庫中。對於Python擴展您可以永久配置的distutils通過添加distutils.cfg文件到lib \文件夾中的distutils使用MinGW的:

[build] 
compiler = mingw32 #or mingw64 

[build_ext] 
compiler = mingw32 #or mingw64 

我添加C:\cygwin\bin到Windows路徑(在末尾,以儘量減少干擾),並從編譯在Windows cmd中。但是,我必須用實際的可執行文件(即,gcc3.exe - > gcc.exe,g ++ 3.exe - > g ++。exe)替換Cygwin符號鏈接,因爲Windows cmd不理解符號鏈接。它還沒有給我一個編譯Python 3擴展,Cython(甚至是使用pyximport進行按需編譯),swig和嵌入Python的問題。