Played around with make file so i got to new error message. I get the feeling, that makeing the .cpp files into .o there is somekind of problem, or maybe where i make it into libary the SDL doesent get included.
Code:
C:\Users\MarkoPC\Desktop\C++\Projekt>make app
g++ -o bin/MapEditor.exe obj/mapEditor.o -Wall -std=c++11 -lmingw32 -lSDL2main -
lSDL2 -Llib -lmapeditor
lib/libmapeditor.a(window.o):window.cpp:(.text+0x7d): undefined reference to SD L_CreateWindow' lib/libmapeditor.a(window.o):window.cpp:(.text+0xf6): undefined reference to
SD
L_CreateRenderer’
lib/libmapeditor.a(window.o):window.cpp:(.text+0x117): undefined reference to S DL_DestroyWindow' lib/libmapeditor.a(window.o):window.cpp:(.text+0x1a9): undefined reference to
S
DL_RenderPresent’
lib/libmapeditor.a(window.o):window.cpp:(.text+0x1b6): undefined reference to S DL_RenderPresent' lib/libmapeditor.a(window.o):window.cpp:(.text+0x2f5): undefined reference to
S
DL_SetWindowTitle’
lib/libmapeditor.a(window.o):window.cpp:(.text+0x356): undefined reference to S DL_SetWindowFullscreen' lib/libmapeditor.a(window.o):window.cpp:(.text+0x37a): undefined reference to
S
DL_SetWindowFullscreen’
c:/mingw/bin/…/lib/gcc/mingw32/4.8.1/…/…/…/…/mingw32/bin/ld.exe: lib/libmap
editor.a(window.o): bad reloc address 0x70 in section `.rdata’
c:/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: *** [bin/MapEditor.exe] Error 1
Current makefile:
Code:
CXX = g++
CXXFLAGS = -Wall -std=c++11
#CXXFLAGS = -w -Wl, -subsystem,windows
LIBDIR = src/
OBJDIR = obj
LIBSRC = $(wildcard $(LIBDIR)*.cpp)
LIBOBJS = $(LIBSRC:$(LIBDIR)%.cpp=$(OBJDIR)/%.o)
LIB_CXXFLAGS = $(CXXFLAGS) -Iinclude
APP_CXXFLAGS = $(CXXFLAGS) -Iinclude
LIBARY = lib/libmapeditor.a
INCLUDE_PATHS = -IC:\MinGW\include\SDL2
LIBRARY_PATHS = -LC:\MinGW\lib
LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2
LFLAGS = -Llib -lmapeditor
APPOBJS = obj/mapEditor.o
APP = bin/MapEditor.exe
build: $(LIBARY)
#Make libary
$(LIBARY):$(LIBOBJS)
ar cr $(LIBARY) $(LIBOBJS)
#Compile libary .cpp files
$(OBJDIR)/%.o: $(LIBDIR)%.cpp
$(CXX) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(LIB_CXXFLAGS) -c $(LIBDIR)$.cpp -o $(OBJDIR)/$.o
#COmpile app.exe and link
$(APP): $(APPOBJS) $(LIBRARY)
$(CXX) -o $(APP) $(APPOBJS) $(CXXFLAGS) $(LINKER_FLAGS) $(LFLAGS)
#Compile app-s .cpp file
obj/mapEditor.o: application/mapEditor.cpp
$(CXX) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(APP_CXXFLAGS) -c application/mapEditor.cpp -o obj/mapEditor.o
app: $(APP)
doc:
doxygen
clean:
rm -rf docs/html
rm -f $(LIBOBJS)
rm -f $(TESTOBJS)
rm -f $(LIBRARY)
rm -f $(APP)
My main file
Code:
//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
#include “window.h”
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
bool init(SDL_Renderer* renderer, Window window);
void close(SDL_Renderer* renderer, Window* window);
int main( int argc, char *args[] )
{
//The window we’ll be rendering to
Window window;
SDL_Renderer* renderer = NULL;
if(!init(renderer, window)){
printf("Failed to initialize! \n");
}else{
bool quit = false;
SDL_Event e;
while(!quit){
while(SDL_PollEvent(&e)!= 0){
if(e.type == SDL_QUIT){
quit = true;
}
window.handleEvents(e, renderer);
}
if(!window.isMinimized()){
//SDL_SetRenderDrawColor(renderer, 0xFF,0xFF,0xFF,0xFF);
//SDL_RenderClear(renderer);
//SDL_RenderPresent(renderer);
}
}
}
close(renderer, &window);
return 0;
}
bool init(SDL_Renderer* renderer, Window window){
bool success = true;
if(SDL_Init(SDL_INIT_VIDEO) < 0){
printf(“SDL could not initialize! SDL Error: %s\n”, SDL_GetError());
success = false;
} else{
if(!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, “1”)){
printf(“Warning: Linear texture filtering not enabled!”);
}
if(!window.init()){
printf("Window could not be created! SDL Error: %s \n", SDL_GetError());
success = false;
} else{
renderer = window.createRenderer();
if(renderer == NULL)
{
printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError());
success = false;
}else{
SDL_SetRenderDrawColor(renderer, 0xFF,0xFF,0XFF,0xFF);
}
}
}
return success;
}
void close(SDL_Renderer* renderer, Window* window){
SDL_DestroyRenderer(renderer);
window->free();
SDL_Quit();
}