
static lib mit g++
Re: static lib mit g++
Es nervt.
Das war meine Hauptmotivation. ^^

Re: static lib mit g++
Naja anstatt die Pfade statisch anzugeben kannst du sdl-config verwenden. Das ist nicht weniger Arbeit, verschönert das ganze meiner Meinung nach aber um einiges.
Re: static lib mit g++
Das versteh ich nicht?
Re: static lib mit g++
Naja du hast in deinem Makefile das:
SDL bringt ein kleines Tool namens sdl-config bzw. sdl2-config mit, um die Konfiguration auszulesen. Den Pfad kannst du (wenn du SDL richtig installiert und die sdl-config im Path hast) auch so abfragen:
Das Linken von SDL, SDL_mixer und SDL_ttf könntest du also auch so schreiben:
Code: Alles auswählen
LIBS = C:\Users\Besitzer\Documents\SGL\libs\SDL2\lib\x86\SDL2.lib \
C:\Users\Besitzer\Documents\SGL\libs\SDL2_image\lib\x86\SDL2_image.lib \
C:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\lib\x86\SDL2_mixer.lib \
C:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\lib\x86\SDL2_ttf.lib \
Code: Alles auswählen
$ sdl2-config --libs
-L/usr/lib/x86_64-linux-gnu -lSDL
Code: Alles auswählen
LIBS = `sdl2-config --cflags --libs` -lSDL_ttf -lSDL_mixer
Re: static lib mit g++
Ich hab mich jetzt mal testweise damit abgefunden und will nur meine Dateien zur libSGl.a zusammenfassen und diese dann später zusammen mit meinem Program linken. Dazu habe ich nun das folgende makefile:
(Wobei ich denke das $(LIBS) und $(LIB_FLAGS) überflüssig sind).
Ich erstelle die libSGL.a ohne Probleme und kompiliere dann alles mit:
Trotz alledem meckert der linker noch immer, dass er die SDL und GL Referenzen nicht auflösen kann. Was zur Hölle läuft mit dem Teil nur falsch? :/
Code: Alles auswählen
CC = g++
CFLAGS = -c -std=c++0x -Wall
INCLUDES = -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\include \
-IC:\Users\Besitzer\Documents\SGL\libs\glew\include
LIBS = -L C:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\lib \
-L C:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\lib \
-L C:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\lib \
-L C:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\lib \
-L C:\Users\Besitzer\Documents\SGL\libs\glew\lib\Release\Win32
LIB_FLAGS = -lopengl32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf
all: Graphic Event Math Window Link clean
Graphic:
$(CC) $(LIB_FLAGS) $(LIBS) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Color.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Surface.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Texture.cpp
Event:
$(CC) $(LIB_FLAGS) $(LIBS) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Event\Event.cpp
Math:
$(CC) $(LIB_FLAGS) $(LIBS) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\mat4.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\Vertex.cpp
Window:
$(CC) $(LIB_FLAGS) $(LIBS) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Window\Window.cpp
Link:
ar crv libSGL.a *.o
clean:
del *.o
Ich erstelle die libSGL.a ohne Probleme und kompiliere dann alles mit:
Code: Alles auswählen
g++ -o main.exe main.cpp -O0 -Wall -std=c++0x -lopengl32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lSGL -I C:\Users\Besitzer\Documents\SGL\include -I C:\Users\Besitzer\Documents\SGL\libs\SDL2\include -I C:\Users\Besitzer\Documents\SGL\libs\SDL2_image\include -I C:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\include -I C:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\include -I C:\Users\Besitzer\Documents\SGL\libs\Glew\include -L C:\Users\Besitzer\Documents\SGL\libs\Glew\lib\Release\Win32 -L. -L C:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\lib -L C:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\lib -L C:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\lib -L C:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\lib -L C:\Users\Besitzer\Documents\SGL\libs\glew\lib\Release\Win32
Re: static lib mit g++
Hm hast du schon mal versucht die Reihenfolge von LIBS und LIB_FLAGS in den einzelnen Komponenten zu vertauschen? Also zuerst mit LIBS die Pfade angeben und dann mit LIB_FLAGS die tatsächlichen Bibliotheken?
Re: static lib mit g++
Habe ich schon öfter. Es lag nun tatsächlich daran, dass ich *.lib verwenden muss:
Mein makefile:
Und die Kompilierung:
Das klappt (auch wenn es weit entfernt von dem ist, was ich ursprünglich wollte).
Mein makefile:
Code: Alles auswählen
CC = g++
CFLAGS = -c -std=c++0x -Wall
INCLUDES = -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\include \
-IC:\Users\Besitzer\Documents\SGL\libs\glew\include
all: Graphic Event Math Window Link clean
Graphic:
$(CC) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Color.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Surface.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Texture.cpp
Event:
$(CC) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Event\Event.cpp
Math:
$(CC) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\mat4.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\Vertex.cpp
Window:
$(CC) $(CFLAGS) $(INCLUDES) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Window\Window.cpp
Link:
ar crv SGL.lib *.o
clean:
del *.o
Code: Alles auswählen
g++ -o main.exe main.cpp -O0 -Wall -std=c++0x -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\include -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\include -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\include -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\include -IC:\Users\Besitzer\Documents\SGL\libs\glew\include -IC:\Users\Besitzer\Documents\SGL\include C:\Users\Besitzer\Documents\SGL\SGL.lib C:\Users\Besitzer\Documents\SGL\libs\SDL2\lib\x86\SDL2.lib C:\Users\Besitzer\Documents\SGL\libs\glew\lib\Release\Win32\glew32.lib -lopengl32
Re: static lib mit g++
Ich komme trotzdem nicht damit klar.
Mein makefile zum bauen meiner SGL lib:
Mein makefile zum kompilieren des Test Programmes:
Und dennoch bekomme ich gemecker vom linker, dass Referenzen fehlen:

Mein makefile zum bauen meiner SGL lib:
Code: Alles auswählen
CC = g++
CFLAGS = -c -std=c++0x -Wall
INCLUDE_PATH = -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\include \
-IC:\Users\Besitzer\Documents\SGL\libs\glew\include
TARGET = x86
LIB_PATH = -LC:\Users\Besitzer\Documents\SGL\libs\lib
LIB_FLAGS = -lopengl32 -lmingw32 -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lglew32
all: Graphic Event Math Window Link clean
Graphic:
$(CC) $(CFLAGS) $(INCLUDE_PATH) $(LIB_PATH) $(LIB_FLAGS) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Color.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Surface.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Graphic\Texture.cpp
Event:
$(CC) $(CFLAGS) $(INCLUDE_PATH) $(LIB_PATH) $(LIB_FLAGS) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Event\Event.cpp
Math:
$(CC) $(CFLAGS) $(INCLUDE_PATH) $(LIB_PATH) $(LIB_FLAGS) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\mat4.cpp \
C:\Users\Besitzer\Documents\SGL\src\SGL\Math\Vertex.cpp
Window:
$(CC) $(CFLAGS) $(INCLUDE_PATH) $(LIB_PATH) $(LIB_FLAGS) \
C:\Users\Besitzer\Documents\SGL\src\SGL\Window\Window.cpp
Link:
ar crv libSGL.a *.o
clean:
rm *.o
Code: Alles auswählen
CC = g++
CFLAGS = -std=c++0x -Wall
CFILES = -o main.exe main.cpp
INCLUDE_PATH = -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-mingw32\include\SDL2 \
-IC:\Users\Besitzer\Documents\SGL\include \
-IC:\Users\Besitzer\Documents\SGL\libs\glew\include
LIB_PATH = -LC:\Users\Besitzer\Documents\SGL\libs\lib
LIB_FLAGS = -lopengl32 -lmingw32 -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer -lglew32 -lSGL
all: compile clean
compile:
$(CC) $(CFLAGS) $(INCLUDE_PATH) $(CFILES) $(LIB_PATH) $(LIB_FLAGS)
clean:
del *.o
Was zur Hölle versteht das Ding nicht?C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
e): undefined reference to `SDL_WasInit'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
23): undefined reference to `SDL_Init'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
3c): undefined reference to `SDL_Quit'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
50): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
5f): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
6e): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
7d): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
8c): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
9b): undefined reference to `glEnable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
aa): undefined reference to `glEnable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
b9): undefined reference to `glEnable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
c8): undefined reference to `glCullFace@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
d7): undefined reference to `glShadeModel@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
ee): undefined reference to `glPolygonMode@8'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
fd): undefined reference to `glEnableClientState@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
10c): undefined reference to `glEnableClientState@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
123): undefined reference to `glHint@8'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
13a): undefined reference to `SDL_GL_SetAttribute'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
14e): undefined reference to `SDL_GL_SetAttribute'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
153): undefined reference to `_imp__glewInit@0'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
29a): undefined reference to `SDL_CreateWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
2af): undefined reference to `SDL_GetError'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
2fc): undefined reference to `SDL_GL_CreateContext'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
311): undefined reference to `SDL_GetError'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
35c): undefined reference to `glGetString@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
36e): undefined reference to `glGetString@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
380): undefined reference to `glGetString@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
475): undefined reference to `SDL_DestroyWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
483): undefined reference to `SDL_GL_DeleteContext'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
4c5): undefined reference to `glMatrixMode@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
4d6): undefined reference to `glLoadMatrixf@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
519): undefined reference to `glClearColor@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
543): undefined reference to `glClear@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
56b): undefined reference to `SDL_HideWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
57b): undefined reference to `SDL_ShowWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
59a): undefined reference to `SDL_EnableScreenSaver'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
5a1): undefined reference to `SDL_DisableScreenSaver'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
5bd): undefined reference to `SDL_MaximizeWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
5d7): undefined reference to `SDL_MinimizeWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
5f1): undefined reference to `SDL_RestoreWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
60b): undefined reference to `SDL_RaiseWindow'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
644): undefined reference to `SDL_SetWindowFullscreen'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
67a): undefined reference to `SDL_SetWindowPosition'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
6b3): undefined reference to `SDL_SetWindowSize'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
6ea): undefined reference to `SDL_SetWindowPosition'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
714): undefined reference to `SDL_SetWindowSize'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
73d): undefined reference to `SDL_GetWindowPosition'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
793): undefined reference to `SDL_GetWindowPosition'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
7af): undefined reference to `SDL_GetWindowSize'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
81d): undefined reference to `SDL_SetWindowTitle'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
83a): undefined reference to `SDL_GetWindowTitle'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
8fb): undefined reference to `glTexCoordPointer@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
916): undefined reference to `glDisable@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
951): undefined reference to `glColorPointer@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
98b): undefined reference to `glVertexPointer@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
9a9): undefined reference to `glDrawArrays@12'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
9b7): undefined reference to `glLoadMatrixf@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
aa5): undefined reference to `glTexCoordPointer@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
ad6): undefined reference to `glVertexPointer@16'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
af4): undefined reference to `glDrawArrays@12'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
b02): undefined reference to `glLoadMatrixf@4'
C:\Users\Besitzer\Documents\SGL\libs\lib/libSGL.a(Window.o):Window.cpp:(.text+0x
b37): undefined reference to `SDL_GL_SwapWindow'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\B
esitzer\Documents\SGL\libs\lib/libSGL.a(Window.o): bad reloc address 0x1b in sec
tion `.text$printf[_printf]'
collect2.exe: error: ld returned 1 exit status
make: *** [compile] Error 1

Re: static lib mit g++
Ändere ich es um, dass die $(LIB_FLAGS) direkt hinter den $(CFLAGS) stehen und die jeweiligen *.cpp Dateien ganz hinten, dann bekomme ich diese Ausgabe:
Die "multiple main" Fehlermeldung geht weg wenn man -lmingw32 weglässt. Aber ich habe nicht die blasseste Ahnung, warum er (trotz meiner vorhanden SGl.a) die Referenzen darauf nicht findet (undefined
reference to `sgl::Window) ...
edit:$ make -f test
g++ -std=c++0x -Wall -lopengl32 -lmingw32 -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_
mixer -lglew32 -lSGL -IC:\Users\Besitzer\Documents\SGL\libs\SDL2\x86_64-w64-ming
w32\include\SDL2 -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_image\x86_64-w64-mi
ngw32\include\SDL2 -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_mixer\x86_64-w64-
mingw32\include\SDL2 -IC:\Users\Besitzer\Documents\SGL\libs\SDL2_ttf\x86_64-w64-
mingw32\include\SDL2 -IC:\Users\Besitzer\Documents\SGL\include -IC:\Users\Besitz
er\Documents\SGL\libs\glew\include -LC:\Users\Besitzer\Documents\SGL\libs\lib ma
in.cpp
C:\Users\Besitzer\AppData\Local\Temp\ccsxsvbS.o:main.cpp:(.text+0x0): multiple d
efinition of `main'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main.
o):e:\p\giaw\src\pkg\mingwrt-4.0.3-1-mingw32-src\bld/../mingwrt-4.0.3-1-mingw32-
src/src/libcrt/crt/main.c:42: first defined here
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main.
o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
C:\Users\Besitzer\AppData\Local\Temp\ccsxsvbS.o:main.cpp:(.text+0x60): undefined
reference to `sgl::Window::Window(unsigned short, unsigned short, std::string c
onst&, sgl::Window::Flags)'
C:\Users\Besitzer\AppData\Local\Temp\ccsxsvbS.o:main.cpp:(.text+0x86): undefined
reference to `sgl::Window::~Window()'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\B
esitzer\AppData\Local\Temp\ccsxsvbS.o: bad reloc address 0x0 in section `.ctors'
collect2.exe: error: ld returned 1 exit status
make: *** [compile] Error 1
Die "multiple main" Fehlermeldung geht weg wenn man -lmingw32 weglässt. Aber ich habe nicht die blasseste Ahnung, warum er (trotz meiner vorhanden SGl.a) die Referenzen darauf nicht findet (undefined
reference to `sgl::Window) ...
Re: static lib mit g++
Kann mir jemand erklären was dieser Fehler konkret bedeutet?
Also warum findet er die Referenz nicht? Die entsprechende *.a Datei wird mit angegeben, auch der richtige Pfad.C:\Users\Besitzer\AppData\Local\Temp\cco8rk0Q.o:main.cpp:(.text+0x60): undefined
reference to `sgl::Window::Window(unsigned short, unsigned short, std::string c
onst&, sgl::Window::Flags)'
C:\Users\Besitzer\AppData\Local\Temp\cco8rk0Q.o:main.cpp:(.text+0x86): undefined
reference to `sgl::Window::~Window()'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\B
esitzer\AppData\Local\Temp\cco8rk0Q.o: bad reloc address 0x0 in section `.ctors'
d:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
make: *** [compile] Error 1