私はここで問題を理解しようとして少し夢中になっています。私のプロジェクトは、ネイティブの gcc および pkg-config フラグを使用して Fedora で正常にビルドされますが、Windows でクロスコンパイルまたは MingW を使用すると、未定義の参照が表示されます。最も奇妙なことは、Windows で 1 回か 2 回コンパイルしたことを覚えていますが、その方法がわかりません。私の知る限り、すべてのライブラリにアクセスできるため、何が問題なのかわかりません。
この入力で:
mingw32-gcc -std=c99 -g -LC:/MinGW/lib -mwindows -lSDL -lSDLmain -lfreetype -lmingw32 -lglu32 -lopengl32 -o bin/gltris.exe gltris.o graphics.o input.o game.o block.o timer.o text.o
私はこの出力を取得します:(奇妙なフォーマットで申し訳ありません)
C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
gltris.o: In function `gltris_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:24: undefined reference to `SDL_Init'
gltris.o: In function `SDL_main':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:110: undefined reference to `SDL_Quit'
graphics.o: In function `graphics_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:31: undefined reference to `SDL_SetVideoMode'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:34: undefined reference to `glClearColor@16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:35: undefined reference to `glClear@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:36: undefined reference to `glViewport@16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:38: undefined reference to `glMatrixMode@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:39: undefined reference to `glLoadIdentity@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:40: undefined reference to `glDisable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:41: undefined reference to `glBlendFunc@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:42: undefined reference to `glPixelStorei@8'
graphics.o: In function `graphics_begin_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:50: undefined reference to `glMatrixMode@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:51: undefined reference to `glLoadIdentity@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:52: undefined reference to `glClear@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:54: undefined reference to `gluOrtho2D@32'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:56: undefined reference to `glMatrixMode@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:57: undefined reference to `glLoadIdentity@0'
graphics.o: In function `graphics_end_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:62: undefined reference to `SDL_GL_SwapBuffers'
graphics.o: In function `graphics_render_block':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:68: undefined reference to `glPushMatrix@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:70: undefined reference to `glTranslatef@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:71: undefined reference to `glScalef@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:74: undefined reference to `glColor4ub@16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:76: undefined reference to `glColor3ubv@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:78: undefined reference to `glEnable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:81: undefined reference to `glBegin@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:82: undefined reference to `glVertex2i@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:83: undefined reference to `glVertex2i@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:84: undefined reference to `glVertex2i@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:85: undefined reference to `glVertex2i@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:86: undefined reference to `glEnd@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:88: undefined reference to `glDisable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:90: undefined reference to `glPopMatrix@0'
graphics.o: In function `render_textured_quad':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:165: undefined reference to `glPushMatrix@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:167: undefined reference to `glEnable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:168: undefined reference to `glEnable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:169: undefined reference to `glBindTexture@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:171: undefined reference to `glTranslatef@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:173: undefined reference to `glBegin@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:175: undefined reference to `glTexCoord2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:176: undefined reference to `glVertex2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:178: undefined reference to `glTexCoord2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:179: undefined reference to `glVertex2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:181: undefined reference to `glTexCoord2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:182: undefined reference to `glVertex2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:184: undefined reference to `glTexCoord2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:185: undefined reference to `glVertex2f@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:187: undefined reference to `glEnd@0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:189: undefined reference to `glDisable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:190: undefined reference to `glDisable@4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:192: undefined reference to `glPopMatrix@0'
graphics.o: In function `surface_to_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:212: undefined reference to `glGenTextures@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:213: undefined reference to `glBindTexture@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:214: undefined reference to `glTexParameteri@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:215: undefined reference to `glTexParameteri@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:216: undefined reference to `glTexImage2D@36'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:221: undefined reference to `SDL_FreeSurface'
input.o: In function `handle_input':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/input.c:13: undefined reference to `SDL_PollEvent'
timer.o: In function `add_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:20: undefined reference to `SDL_GetTicks'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:36: undefined reference to `SDL_GetTicks'
timer.o: In function `do_timers':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:65: undefined reference to `SDL_GetTicks'
timer.o: In function `pause_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:84: undefined reference to `SDL_GetTicks'
timer.o: In function `resume_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:90: undefined reference to `SDL_GetTicks'
timer.o:C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:98: more undefined references to `SDL_GetTicks' follow
text.o: In function `text_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:24: undefined reference to `_imp__FT_Init_FreeType'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:28: undefined reference to `_imp__FT_New_Face'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:32: undefined reference to `_imp__FT_Set_Char_Size'
text.o: In function `text_gen_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:70: undefined reference to `glGenTextures@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:71: undefined reference to `glBindTexture@8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:72: undefined reference to `glTexParameteri@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:73: undefined reference to `glTexParameteri@12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:77: undefined reference to `glTexImage2D@36'
text.o: In function `text_print':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:92: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:97: undefined reference to `_imp__FT_Load_Char'
text.o: In function `get_text_size':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:115: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:119: undefined reference to `_imp__FT_Load_Char'
text.o: In function `print_game_info':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:138: undefined reference to `glColor3f@12'
collect2.exe: error: ld returned 1 exit status
編集:リンカーフラグ「-lmingw32 -lopengl32 -lSDLmain -lSDL -lfreetype -mwindows」を使用して、コンパイルとリンクを一度に行うことでビルドできました