1

In my project I have the following structure :

.
├── Makefile
├── include
│   ├── Game.h
│   ├── Game.h.gch
│   └── Letter.h.gch
├── letra_A_.png
├── main.cpp
├── modules
│   └── Game.cpp
└── resources
    └── space.bmp

3 directories, 8 files

And my Makefile contains :

#Makefile for SDL universe

SOURCES := $(shell find . -name \*.cpp -o -name \*.h)
build:
    echo "Building.."
    g++  -L/usr/include -lSDL2 $(SOURCES) -o blocks
    echo "Done"

The problem I am seeing is that it only works in one machine among the two I have. The one which is working fine has Kali Linux while the one where it fails has Ubuntu 18.10.

I can see SDL2 is installed in the same exact location in both distros :

(0) matias #> ls -ldh /usr/include/SDL2/
drwxr-xr-x 2 root root 4.0K Oct 28 11:27 /usr/include/SDL2/

Why is my project not building in Ubuntu? Im getting the below error :

./main.cpp: In function ‘int main()’:
./main.cpp:11:51: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
     my_game -> init(10,10,800,600,false,"Mi juego");
                                                   ^
/tmp/ccerEhlq.o: In function `Game::init(int, int, int, int, bool, char*)':
Game.cpp:(.text+0x9d): undefined reference to `SDL_Init'
Game.cpp:(.text+0xbd): undefined reference to `SDL_CreateWindow'
Game.cpp:(.text+0xdf): undefined reference to `SDL_GetError'
Game.cpp:(.text+0x117): undefined reference to `SDL_CreateRenderer'
Game.cpp:(.text+0x135): undefined reference to `SDL_RWFromFile'
Game.cpp:(.text+0x142): undefined reference to `SDL_LoadBMP_RW'
Game.cpp:(.text+0x168): undefined reference to `SDL_CreateTextureFromSurface'
Game.cpp:(.text+0x183): undefined reference to `SDL_FreeSurface'
/tmp/ccerEhlq.o: In function `Game::draw()':
Game.cpp:(.text+0x1b8): undefined reference to `SDL_RenderClear'
Game.cpp:(.text+0x1da): undefined reference to `SDL_RenderCopy'
Game.cpp:(.text+0x1ea): undefined reference to `SDL_RenderPresent'
/tmp/ccerEhlq.o: In function `Game::running()':
Game.cpp:(.text+0x215): undefined reference to `SDL_PollEvent'
/tmp/ccerEhlq.o: In function `Game::quit()':
Game.cpp:(.text+0x25e): undefined reference to `SDL_DestroyWindow'
Game.cpp:(.text+0x263): undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status
Matias Barrios
  • 4,674
  • 3
  • 22
  • 49

0 Answers0