Make Autotools project with SDL2

  Kiến thức lập trình

I am spinning up a new project. I want to use autotools for my build system, and the project will link to SDL2. However, I’m stuck writing the configure.ac file.

The documented way to link to SDL2 when it is installed on the system uses an installed command that outputs linker flags:

gcc -o myprogram myprogram.c `sdl2-config --cflags --libs`

I find it reasonable to assume that the output of sdl2-config may change depending on the system, and that it should be run in configure, then passed to make (this may be wrong!). I’m having a dog of a time trying to set this up, though. Maybe it’s because my knowledge of M4sh is very limited, but I can’t figure out how to do command substitution on the target computer.

How do I properly integrate linking SDL2 and autotools into a project, and why is it done that way so I can apply those principles to future libraries I have this issue with?

LEAVE A COMMENT