I recently moved to linux and i\'m having an issue with compiling SDL C programs using gcc.
The command i\'m using:
gcc `sdl-config --cflags --libs`
gcc
matters a lot.Read about Invoking GCC (and documentation of binutils, which gcc
uses). Then replace
gcc `sdl-config --libs` -o main main.o
with
gcc main.o `sdl-config --libs` -o main
Better yet, learn how to use GNU make (it is often using GNU bash) and use a Makefile
inspired by this answer...
Also, always pass -Wall -g
to gcc
until your program is bug-free (then use -Wall -O2
)
Take inspiration from open source programs on github or gitlab using SDL. Consider also using other open source libraries and frameworks, such as Qt, SFML, GTKmm, etc... And study their example code.