2013-01-21 79 views
0

我是一个新手C程序员,这是我第一次与图形工作。我得到了一些代码,包括一些OpenGL功能可以正常工作在我的MacBook Pro(运行OS X 10.6.8版本),但它不会是运行Linux(CentOS的版本2.16.0)我的办公室机器上编译。在这两种情况下,我都使用gcc。我在Mac上编译时通过以下选项:OpenGL的C代码在Mac OS X,但不能在Linux上

-lcurses -lX11 -lGL -lm -fast 
-I/usr/X11R6/include/ -I/usr/X11R6/include/GL -L/usr/X11R6/lib 
-L/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries 
-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib 

当试图在Linux上编译以下选项

-lcurses -lX11 -lGL -lm 

我收到以下错误

cem_master.c:159: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 
cem_master.c:160: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 
cem_master.c:161: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token 

这是指下面的代码行:

static WINDOW *mainwnd; 
static WINDOW *screen; 
WINDOW *my_win; 

什么是错的任何想法?如何去理解这个技巧?


在回应的意见,这里是从第一行导致该错误的部分源代码的简化版本。我切出大量的垃圾之间的包括和/ 显示废话 /部分,但是这仍然会产生错误。

#include <stdlib.h>  
#include <stdio.h> 
#include <math.h> 
#include <time.h> 
#include <GL/glx.h> 
#include <GL/gl.h> 
#include <unistd.h> 

/* Display Crap */ 
static WINDOW *mainwnd; 
static WINDOW *screen; 
WINDOW *my_win; 

float xcellwidth; 
float ycellwidth; 
int  current_getch; 
int  xplotoff; 
int  yplotoff; 

Display     *dpy; 
Window     root; 
XVisualInfo    *vi; 
Colormap    cmap; 
XSetWindowAttributes swa; 
Window     win; 
GLXContext    cx; 
XEvent     event; 
+0

邮政整个源文件,或至少所述片段从第一行到引起错误的行。 –

回答

0

WINDOWSCREEN来自ncurses库。您需要#include <ncurses.h>才能使用它。

+0

看起来像我没有ncurses。你知道我如何获得/安装它吗?我需要管理员权限吗? – kde8

+0

使用您的发行版的包管理器。安装软件包的dev(或devel)版本。您确实需要管理员权限才能安装。有办法解决这个问题(从你的$ HOME源代码安装),但我不推荐给初学者。 –

+0

太好了,非常感谢您的帮助! – kde8