undefined reference to `SDL_setRenderDrawColor'

Trending 1 year ago

I americium getting

C:\Users\rasmu\AppData\Local\Temp\ccwOn3mM.o:main.c:(.text+0x11f): undefined reference to `SDL_setRenderDrawColor'

C:\Users\rasmu\AppData\Local\Temp\ccwOn3mM.o:main.c:(.text+0x155): undefined reference to `SDL_setRenderDrawColor'

when one effort to compile my basal SDL2 c program. My codification is

#define ASSERT(_e, ...) if (!(_e)) { fprintf(stderr, __VA_ARGS__); exit(1); } #include <SDL.h> #include <stdio.h> #include <stdbool.h> #include <stdint.h> typedef float f32; typedef double f64; typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; const int SCREEN_WIDTH = 1280; const int SCREEN_HEIGHT = 720; const int FPS = 30; typedef struct { SDL_Window* window; SDL_Texture* texture; SDL_Renderer* renderer; u32* pixels; bool quit; } state; u32* init_pixels(); void put_pixel(state state); int main( int argc, char* args[]){ authorities state; ASSERT( !SDL_Init(SDL_INIT_VIDEO), "SDL grounded to init: %s\n", SDL_GetError() ); state.window = SDL_CreateWindow( "Game", SDL_WINDOWPOS_CENTERED_DISPLAY(1), SDL_WINDOWPOS_CENTERED_DISPLAY(1), 1280, 720, SDL_WINDOW_ALLOW_HIGHDPI ); ASSERT(state.window, "failed to create SDL window: %s\n", SDL_GetError()); state.pixels = malloc(SCREEN_WIDTH * SCREEN_HEIGHT * 4); state.renderer = SDL_CreateRenderer( state.window, -1, NULL ); SDL_setRenderDrawColor(state.renderer,0,0,0,255); SDL_RenderClear(state.renderer); SDL_setRenderDrawColor(state.renderer,255,255,255,255); SDL_RenderDrawPoint(state.renderer,SCREEN_WIDTH/2,SCREEN_HEIGHT/2); SDL_RenderPresent(state.renderer); while(!state.quit){ SDL_Event ev; while(SDL_PollEvent(&ev)){ switch(ev.type){ lawsuit SDL_QUIT: state.quit = true; break; } } } SDL_DestroyWindow(state.window); free(state.pixels); SDL_QUIT; return 0; }

And my make record looks for illustration this

OBJS = main.c CC = gcc INCLUDE_PATHS = -IC:\mingw_dev_lib\include\SDL2 LIBRARY_PATHS = -LC:\mingw_dev_lib\lib COMPILER_FLAGS = -w -Wl,-subsystem,windows LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2 OBJ_NAME = game all : $(OBJS) $(CC) $(OBJS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) -o $(OBJ_NAME) $(LINKER_FLAGS)

I do judge it has thing to do pinch nan linking of nan SDL2 room but it seems weird since nan SDL.h useful good but only erstwhile I person tried to usage nan SDL_setRenderDrawColor() function. I americium rather caller to SDL and linking libraries.