2015-11-04 34 views
3

我試圖編譯在C MathGL庫的第一個例子:編譯mathgl C-例

http://mathgl.sourceforge.net/doc_en/Examples.html

#include <mgl2/mgl_cf.h> 

int main() 
{ 
    HMGL gr = mgl_create_graph(600,400); 
    mgl_fplot(gr,"sin(pi*x)","",""); 
    mgl_write_frame(gr,"test.png",""); 
    mgl_delete_graph(gr); 
} 

我安裝使用aptitude libmgl-dev的,並拒絕提供的第一個選項,因爲aptitude想要刪除一些不同的程序並接受第二個選項,它只升級了一些。

如果我嘗試編譯:

gcc test.c -o test -lmgl 
In file included from /usr/include/mgl2/mgl_cf.h:29:0, 
       from test.c:1: 
/usr/include/mgl2/data_cf.h:318:78: error: unknown type name ‘bool’ 
EXPORT mgl_fft(double *x, long s, long n, const void *wt, void *ws, bool inv); 

於是,我就添加#include <stdbool.h>並試圖像-std=gnu11-std=c11-std=c99標誌。沒有一個工作。我試着添加國旗-lmgl(我甚至讀過,我應該把它放在最後)。

我該如何編譯這個例子?

回答

1

您似乎有舊版本的庫,其中這是一個錯誤。

請參閱此bug report 從2013年5月起。確認錯誤的Alexey Balakin是MathGL的首席開發人員。

見該錯誤是固定在MathGL 2.3.3版本的data_ch.h, 其中聲明:

void MGL_EXPORT mgl_fft(double *x, long s, long n, const void *wt, void *ws, int inv); 

bool取代int

+0

好吧我重新從源代碼,它工作正常。我會把它報告給薄荷作爲一個錯誤。 – Stein