MinGW+OpenGL+GLUTで毎回ハマること

$ gcc -lfreeglut -lglu32 -lopengl32 main.c
main.o:main.c:(.text+0x1c): undefined reference to `_imp____glutInitWithExit@12'
main.o:main.c:(.text+0x3e): undefined reference to `_imp____glutCreateWindowWithExit@8'
main.o:main.c:(.text+0x60): undefined reference to `_imp____glutCreateMenuWithExit@8'
main.o:main.c:(.text+0xa0): undefined reference to `_imp__glutInitDisplayMode@4'
main.o:main.c:(.text+0xb9): undefined reference to `_imp__glutInitWindowSize@8'
main.o:main.c:(.text+0xd2): undefined reference to `_imp__glutInitWindowPosition@8'
main.o:main.c:(.text+0xf8): undefined reference to `_imp__glutDisplayFunc@4'
main.o:main.c:(.text+0x109): undefined reference to `_imp__glutReshapeFunc@4'
main.o:main.c:(.text+0x113): undefined reference to `_imp__glutMainLoop@0'
main.o:main.c:(.text+0x13e): undefined reference to `glClear@4'
(以下略)

大量のリンクエラーが出て(・3・)あるぇ~?となる。

解決方法・・・というか正しくは↓のように、コンパイル対象のソースを-lオプションより前に持ってくるである。

$ gcc main.c -lfreeglut -lglu32 -lopengl32

どういうわけか、この罠だけは毎度ハマっては、ライブラリを入れ替えてみたり小手先のマクロを定義してみたりして時間を無駄にしてしまうorz

ありがとうございます。 ちょうど(・3・)あるぇ~?となっていたところでした。

1 |
ごみち
| 2015-12-01 17:07 | reply

@ごみち: お役に立てて良かったです。

2 | | 2015-12-09 10:03 | reply

ありがとうございます!助かりました!!!!

3 |
ゲーム作製おじさん
| 2020-04-15 01:09 | reply



  • blog/2011/2011-02-16.txt
  • 最終更新: 2015-01-06 11:51
  • (外部編集)