I am trying to learn chicken scheme by writing a simple game using sdl. I am trying to create a foreign function to initialize SDL:
(use foreigners lolevel)
(foreign-declare "#include <SDL2/SDL.h>")
(define (sdl-init)
(foreign-lambda* int ((int val))
"if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, \"Couldn't initialize SDL: %s\",
SDL_GetError());
exit(1);
}
"))
I get the errors:
undefined reference to `SDL_Init'
undefined reference to `SDL_GetError'
undefined reference to `SDL_LogError'
So it can't find SDL. Normally in C you would do something like this (from the sdl page):
gcc -o test test.c sdl-config --cflags --libs
is there a way to add these flags when compiling .scm files.
I would recommend using the sdl2 egg. If you still prefer to build your own bindings to sdl2, you can use something like this:
csc test.scm -C "`sdl-config --cflags`" -L "`sdl-config --libs`"
Also I note that you're still on CHICKEN 4, which is no longer maintained; you might want to consider updating to CHICKEN 5.