Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8475503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:54:41+00:00 2026-06-10T17:54:41+00:00

This is my makefile: CFLAGS = -Wall -pedantic -pedantic-errors -g -lSDL -lSDL_image CC =

  • 0

This is my makefile:

CFLAGS = -Wall -pedantic -pedantic-errors -g -lSDL -lSDL_image
CC = g++
OBJ = Point.o Personaje.o Juego.o EventHandler.o

all: main

#%.o: %.cpp %.h
#   $(CC) -c $(CFLAGS) $<

bin: other $(OBJ)

Point.o: Point.cpp Point.h
    $(CC) -c $(CFLAGS) $<

Personaje.o: Personaje.cpp Personaje.h
    $(CC) -c $(CFLAGS) $<

Juego.o: Juego.cpp Juego.h
    $(CC) -c $(CFLAGS) $<

EventHandler.o: EventHandler.cpp EventHandler.h
    $(CC) -c $(CFLAGS) $<

main: $(OBJ)
    cd ../vista/; make
    cp ../vista/*.o .
    rm ../vista/*.o
    g++ $(CFLAGS) $(OBJ) Pantalla.o Imagen.o main.cpp -o main

clean:
    rm *.o;
    rm main

PHONY: main

When I compile with “make” I get the following errors:

EventHandler.cpp:17: undefined reference to `SDL_PollEvent'
Pantalla.o: In function `Pantalla::initialize(int, int, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
Pantalla.cpp:6: undefined reference to `SDL_Init'
Pantalla.cpp:9: undefined reference to `SDL_SetVideoMode'
Pantalla.cpp:14: undefined reference to `SDL_WM_SetCaption'

and many other errors.

The header of “Pantalla.h” contains this line:

#include "SDL/SDL.h"

And I already installed the SDL packages.

I don’t know what I’m doing wrong… please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:54:43+00:00Added an answer on June 10, 2026 at 5:54 pm
    CFLAGS = -Wall -pedantic -pedantic-errors -g -lSDL -lSDL_image
    

    This isn’t good. You’re mixing compiler flags (warnings and debug) with linker information (which libraries you need to link to). Use two separate variables for that:

    CFLAGS = -Wall -pedantic -pedantic-errors -g
    LIBS = -lSDL -lSDL_image
    

    Then when you compile (but don’t link, i.e. when you generate the .o files), only use $(CFLAGS) (like you have now). But when you do link (to produce the final executable), add the linker directives.

    g++ $(CFLAGS) -o main main.cpp $(OBJ) Pantalla.o Imagen.o $(LIBS)
    

    The order you put your objects and libraries is important.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very basic makefile: CC=gcc CFLAGS=-Wall -g -O -pedantic -Wformat=2 -Wextra -lm
I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
So, this is odd. In my makefile I have CC:=icc ifeq ($(CC),icc) CFLAGS :=
I am in linux. My Makefile file is this main2: main.cpp g++ -c $(LIBS)
Here's the makefile: makefile.win CC=gcc CFLAGS=-Wall -ID:\dev\include -LD:\dev\lib -LD:\dev\bin LIBS=-l mingw32 -l SDLmain -l
I have main.c, snmpy.c, snmpy.o, and a makefile. I running this on a Linux
I have a source directory which uses makefile to compile the code. This makefile/configure
I have this in my makefile test: cat t.txt | sort -t $$'\t' -k
I'm trying to do this in a makefile and it fails horribly: M_ARCH :=
This is my VERY FIRST Makefile and so I have cut and paste junk

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.