🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL Game, Windows, Makefile Find Parameter not corret, undefined reference to `SDL_main'

Started by
1 comment, last by a light breeze 3 years, 8 months ago

Any clues? I'm having trouble getting this SDL game skeleton to work.

I made some quick changes to the make file to link the libraries. Not entirely sure what I'm doing here. The flags may be wrong now.

errors: Find Parameter format not correct. Followed by: undefined reference to 'SDL main'

Console:

FIND: Parameter format not correct
FIND: Parameter format not correct
gcc -o CitiesAndRockets  -lmingw32  -lSDL2main -lSDL2 -lSDL2_image -IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w -Wl,-subsystem,windows
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\mingw_dev_lib\lib/libSDL2main.a(SDL_windows_main.o): in function `main_getcmdline':
/Users/valve/release/SDL/SDL2-2.0.12-source/foo-x64/../src/main/windows/SDL_windows_main.c:71: undefined reference to `SDL_main'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:8: all] Error 1

Original Makefile :

CC=g++
CFLAGS=-I.
LDFLAGS = -lSDL2 -lSDL2_image
SRC = $(shell find . -name "*cpp")
DEPS = $(patsubst %.cpp, %.o, $(SRC))

all: $(DEPS)
	$(CC) -o CitiesAndRockets $(DEPS) $(LDFLAGS) $(CFLAGS)
clean:
	rm *.o

New Makefile:

CC=gcc
CFLAGS=-IC:\mingw_dev_lib\include\SDL2 -LC:\mingw_dev_lib\lib -w -Wl,-subsystem,windows
LDFLAGS = -lmingw32  -lSDL2main -lSDL2 -lSDL2_image
SRC = $(shell find . -name "*.cpp")
DEPS = $(patsubst %.cpp, %.o, $(SRC))

all: $(DEPS)
	$(CC) -o CitiesAndRockets $(DEPS) $(CFLAGS) $(LDFLAGS) 
clean:
	rm *.o

Main.cpp:

#include <SDL.h>
#include <SDL_image.h>
#include <stdexcept>

#include "Game.h"
#include "State_Gameplay.h"

int main(int argv, char** args[])
{
	Game g;

	while (g.Init(new State_Gameplay()))
	{
		g.Thread();
	}
	
	return 0;
}

Repo:

https://github.com/kchrome01/Cities-And-Rockets


Advertisement

You declared args incorrectly. It should be either “char** args” or “char* args[]”, not “char** args[]”.

This topic is closed to new replies.

Advertisement