我正在尝试使用 Xcode 在 Mac 上编译一个简单的 OpenGL 代码。以前我用过Windows。我遇到了一些我真的不知道的错误。有人可以帮助解决。
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
void display (void)
{
glColor3f ( 1.0, 1.0, 1.0 );
float angles[20] = { 30.0,45.0,60.0,75.0,90.0,105.0,120.0,135.0,150.0,165.0,180.0,195.0,210.0,225.0,240.0,255.0,270.0,285.0,300.0 };
int i; float xOut, yOut, xIn, yIn; const float pi = 3.141592;
for ( i = 0; i == 19; i++ )
{
float angle = angles[i]*pi/180.0;
glBegin ( GL_LINE );
xOut = 12 * sinf(angle);
yOut = 12 * cosf(angle);
xIn = 9 * sinf(angle);
yIn = 9 * cosf(angle);
glVertex3f ( xOut, yOut, 0.0);
glVertex3f ( xIn, yIn, 0.0);
glEnd();
}
glutSwapBuffers();
}
void initializeWindow (void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
glOrtho ( -100.0, 100.0, -100.0, 100.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
glutInitWindowSize ( 500, 500 );
glutInitWindowPosition ( 100, 100 );
glutCreateWindow ( "PrimaryFlightDisplay" );
initializeWindow ();
glutDisplayFunc ( display );
glutMainLoop ();
return 0;
}
当我在终端中使用编译时出现这些错误
gcc -o main main.cpp -framework GLUT -framework OpenGL
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in cczuL03z.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in cczuL03z.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status