2014-03-03 44 views
8

我正在努力編譯OSX 10.8上的PyGLPK。我已經通過自制軟件安裝了glpk和gmp 。我已驗證下列文件都存在於 在/ usr /本地/包括無法編譯OSX 10.8/Ubuntu 14.x上的pyglpk

gmp.h 
gmpxx.h 
glpk.h 

但我仍然得到以下錯誤。

python setup.py build 
running build 
running build_ext 
building 'glpk' extension 
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -Isrc -I/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/glpk.c -o build/temp.macosx-10.9-x86_64-2.7/src/glpk.o -m32 
clang -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -Isrc -I/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lp.c -o build/temp.macosx-10.9-x86_64-2.7/src/lp.o -m32 
In file included from src/lp.c:24: 
src/kkt.h:30:3: error: unknown type name 'LPXKKT' 
    LPXKKT kkt; 
^
src/lp.c:182:18: warning: implicit declaration of function 'lpx_read_model' is invalid in C99 [-Wimplicit-function-declaration] 
     self->lp = lpx_read_model(model[0], model[1], model[2]); 
       ^
src/lp.c:182:16: warning: incompatible integer to pointer conversion assigning to 'glp_prob *' (aka 'struct glp_prob *') from 'int' [-Wint-conversion] 
     self->lp = lpx_read_model(model[0], model[1], model[2]); 
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
src/lp.c:338:7: warning: implicit declaration of function 'lpx_read_bas' is invalid in C99 [-Wimplicit-function-declaration] 
    if (lpx_read_bas(LP, bas_filename)) { 
    ^
src/lp.c:349:8: error: use of undeclared identifier 'LPX_E_OK' 
    case LPX_E_OK:  Py_RETURN_NONE; 
    ^
src/lp.c:350:8: error: use of undeclared identifier 'LPX_E_FAULT' 
    case LPX_E_FAULT:  return PyString_FromString("fault"); 
    ^
src/lp.c:351:8: error: use of undeclared identifier 'LPX_E_OBJLL' 
    case LPX_E_OBJLL:  return PyString_FromString("objll"); 
    ^
src/lp.c:352:8: error: use of undeclared identifier 'LPX_E_OBJUL' 
    case LPX_E_OBJUL:  return PyString_FromString("objul"); 
    ^
src/lp.c:353:8: error: use of undeclared identifier 'LPX_E_ITLIM' 
    case LPX_E_ITLIM:  return PyString_FromString("itlim"); 
    ^
src/lp.c:354:8: error: use of undeclared identifier 'LPX_E_TMLIM' 
    case LPX_E_TMLIM:  return PyString_FromString("tmlim"); 
    ^
src/lp.c:355:8: error: use of undeclared identifier 'LPX_E_SING' 
    case LPX_E_SING:  return PyString_FromString("sing"); 
    ^
src/lp.c:357:8: error: use of undeclared identifier 'LPX_E_NOPFS' 
    case LPX_E_NOPFS:  return PyString_FromString("nopfs"); 
    ^
src/lp.c:358:8: error: use of undeclared identifier 'LPX_E_NODFS' 
    case LPX_E_NODFS:  return PyString_FromString("nodfs"); 
    ^
src/lp.c:360:8: error: use of undeclared identifier 'LPX_E_NOFEAS' 
    case LPX_E_NOFEAS: return PyString_FromString("nofeas"); 
    ^
src/lp.c:361:8: error: use of undeclared identifier 'LPX_E_NOCONV' 
    case LPX_E_NOCONV: return PyString_FromString("noconv"); 
    ^
src/lp.c:362:8: error: use of undeclared identifier 'LPX_E_INSTAB' 
    case LPX_E_INSTAB: return PyString_FromString("instab"); 
    ^
src/lp.c:492:16: warning: implicit declaration of function 'lpx_exact' is invalid in C99 [-Wimplicit-function-declaration] 
    int retval = lpx_exact(LP); 
      ^
src/lp.c:493:15: error: use of undeclared identifier 'LPX_E_FAULT' 
    if (retval!=LPX_E_FAULT) self->last_solver = 0; 
      ^
src/lp.c:498:16: warning: implicit declaration of function 'lpx_interior' is invalid in C99 [-Wimplicit-function-declaration] 
    int retval = lpx_interior(LP); 
      ^
src/lp.c:499:15: error: use of undeclared identifier 'LPX_E_FAULT' 
    if (retval!=LPX_E_FAULT) self->last_solver = 1; 
      ^
src/lp.c:708:16: warning: implicit declaration of function 'lpx_intopt' is invalid in C99 [-Wimplicit-function-declaration] 
    int retval = lpx_intopt(LP); 
      ^
src/lp.c:709:15: error: use of undeclared identifier 'LPX_E_FAULT' 
    if (retval!=LPX_E_FAULT) self->last_solver = 2; 
      ^
src/lp.c:730:3: warning: implicit declaration of function 'lpx_check_kkt' is invalid in C99 [-Wimplicit-function-declaration] 
    lpx_check_kkt(LP, scaling, &(kkt->kkt)); 
^
src/lp.c:737:3: warning: implicit declaration of function 'lpx_check_int' is invalid in C99 [-Wimplicit-function-declaration] 
    lpx_check_int(LP, &(kkt->kkt)); 
^
src/lp.c:744:26: error: unknown type name 'LPX' 
    static int(*writers[])(LPX*,const char*) = { 
         ^
src/lp.c:745:5: error: use of undeclared identifier 'lpx_write_mps'; did you mean 'glp_write_mps'? 
    lpx_write_mps, lpx_write_bas, 
    ^~~~~~~~~~~~~ 
    glp_write_mps 
/usr/local/include/glpk.h:723:5: note: 'glp_write_mps' declared here 
int glp_write_mps(glp_prob *P, int fmt, const glp_mpscp *parm, 
    ^
src/lp.c:745:20: error: use of undeclared identifier 'lpx_write_bas' 
    lpx_write_mps, lpx_write_bas, 
       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=] 
8 warnings and 20 errors generated. 
error: command 'clang' failed with exit status 1 
make: *** [all] Error 1 

任何人都可以提供一個關於如何解決這個問題的建議嗎?我試圖玩弄路徑和環境變量,但沒有任何影響。

+0

我已經有好幾個星期了同樣的問題,還沒有找到一個解決方案。 –

+1

也許pyglpk現在放棄了? –

回答

10

不確定這是一種常規修復,但它解決了我對GLPK的特殊需求。我剛剛恢復到舊版本,它的工作。

先卸載最新:

brew remove glpk 

然後安裝舊的(4.39)。

cd $(brew --prefix) 
git checkout a82e823 Library/Formula/glpk.rb 
brew install glpk 

那麼這只是正常工作:

pip install glpk 
+0

如果「git checkout a82e823 ...」不適合你,你可以直接從這裏獲取文件: https://raw.githubusercontent.com/Homebrew/legacy-homebrew/a82e823935e9c4092000bab57d1a6f1cae481dca/Library/Formula/glpk .RB – eshirazi

2

不幸的是,pyglpk不適用於更新版本的GLPK。我認爲最後的版本是GLPK 4.47。

3

本來張貼原來的問題評論,但我有足夠的信譽來這樣做。

當我最近升級到與GLPK 4.52一起提供的Ubuntu 14.04時,我遇到了同樣的問題。很多舊的API已被棄用,不再可公開訪問。我有這方面的工作:https://github.com/bradfordboyle/pyglpk