LinuxでWindowsバイナリをコンパイルするLinux用のmingw32クロスコンパイラがあります。glutをインストールする必要があるまで、すべてがうまくいきました... Linuxには問題なくインストールできましたが、Windowsで同じプログラムをコンパイルしようとすると、次のように要約できます。
/tmp/ccQhHDhy.o:main.cpp:(.text+0xf):
__imp__glClear' /tmp/ccQhHDhy.o:main.cpp:(.text+0x1e): undefined reference to
_ imp__imp__glVertex3f' /tmp/ccQhHDhy.o:main.cpp:(.text+0x5c): undefined reference to
_glBegin' への未定義の参照 /tmp/ccQhHDhy.o:main.cpp:(.text+0x3d): _ imp _glVertex3f'への未定義の参照/tmp/ccQhHDhy.o:main.cpp:(.text+0x7b):__imp__glVertex3f' /tmp/ccQhHDhy.o:main.cpp:(.text+0x85): undefined reference to
_ imp _glEnd'への未定義の参照
dllと直接リンクすることにより
これらのリンカーエラーが発生した後、opengl32 gdi32 winmm glut lib ファイルと glu32 をリンクしてみました
しかし、それでもこれは同じです
ソースコードは次のとおりです。
#include <stdlib.h>
#include <GL/glut.h>
using namespace std;
void render(void);
int main(int argc, char **argv){
glutInit(&argc, argv);
glutInitWindowPosition(-1,-1);
glutInitWindowSize(500,500);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("My First Glut Application");
glutDisplayFunc(render);
glutMainLoop();
return 0;
}
void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5, -0.5, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.0, .5, 0.0);
glEnd();
}