Hi,
I am trying to get Gambit playing well with SDL, and am running into some strange problems when trying to set up the scheme environment.
This is the main() function that starts up a SDL window:
int main(int argc, char *argv[]) { /* //SETUP */ ___setup_params_struct setup_params; ___setup_params_reset (&setup_params); setup_params.version = ___VERSION; setup_params.linker = SCHEME_LIBRARY_LINKER; ___setup (&setup_params);
x = 0; run_stuff(); //Starts a simple SDL animation
/* //CLEANUP */ ___cleanup (); }
Currently everything is still in C, so there are *no* calls to any scheme functions yet.
I found that the animation runs for about 3 seconds before the whole program hangs. If I comment out __setup(&setup_params), then the program executes normally.
Are there some subtleties when setting up the Gambit environment that I have to watch out for? Is Gambit spawning another thread and causing some deadlock problems? I am fairly certain that SDL is single-threaded, and the whole animation runs in an infinite loop.
I would appreciate any insight people would have on this. Thanks a lot. -Patrick
On Wed, Feb 15, 2012 at 1:11 PM, Marc Feeley feeley@iro.umontreal.cawrote:
On 2012-02-15, at 1:36 PM, Patrick Li wrote:
Hello everyone,
I am just getting started using gsc to compile files, and I'm wondering
how to go about debugging some error messages I'm seeing.
This is what I am doing:
== inside misha-sdl.scm == (println "hello world")
== inside terminal == gsc -link misha-sdl gcc misha-sdl.c misha-sdl_.c -I/Library/Gambit-C/v4.6.2/include
-L/Library/Gambit-C/v4.6.2/lib -lgambc
== error message == ld: warning: ignoring file /Library/Gambit-C/v4.6.2/lib/libgambc.a, file
was built for archive which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64: "____gstate", referenced from: ____H__20_misha_2d_sdl in cci2oaPA.o "____G_println", referenced from: ____H__20_misha_2d_sdl in cci2oaPA.o "_____20___gambc", referenced from: ____linker_tbl in ccR9LONi.o "____main_char", referenced from: _main in ccR9LONi.o
The notice about skipping libgambc.a is especially worrying.
However, using the command: gsc -o hello -exe misha-sdl.scm works perfectly. Is there any way to query to see what flags gsc is
passing to gcc?
You can use the -verbose option to gsc :
gsc -verbose -o hello -exe misha-sdl.scm
Marc
Afficher les réponses par date
On 2012-02-15, at 9:17 PM, Patrick Li wrote:
Hi,
I am trying to get Gambit playing well with SDL, and am running into some strange problems when trying to set up the scheme environment.
This is the main() function that starts up a SDL window:
int main(int argc, char *argv[]) { /* //SETUP */ ___setup_params_struct setup_params; ___setup_params_reset (&setup_params); setup_params.version = ___VERSION; setup_params.linker = SCHEME_LIBRARY_LINKER; ___setup (&setup_params);
x = 0; run_stuff(); //Starts a simple SDL animation
/* //CLEANUP */ ___cleanup (); }
Currently everything is still in C, so there are *no* calls to any scheme functions yet.
That's not necessarily the case. When ___setup() is called, your Scheme program will be run and it might contain Scheme calls (in your previous example you were calling println for instance). Usually this "execution" of your Scheme program takes care of the initializations your program requires. After ___setup() returns, but before you call ___cleanup(), you can call Scheme functions declared using c-define in your Scheme code.
I found that the animation runs for about 3 seconds before the whole program hangs. If I comment out __setup(&setup_params), then the program executes normally.
Are there some subtleties when setting up the Gambit environment that I have to watch out for? Is Gambit spawning another thread and causing some deadlock problems? I am fairly certain that SDL is single-threaded, and the whole animation runs in an infinite loop.
The Gambit runtime is also single threaded (it does not create any OS threads, except on Windows to simulate interval timers, but that's not relevant here).
The problem could be an interference between the OS resources used by SDL and those used by the Gambit runtime, in particular the Gambit runtime sets up some signal handlers, for example to implement the heartbeat interrupt. Perhaps the SDL library is doing the same?
I know that David St-Hilaire wrote an interface to SDL which is on the Gambit Dumping Grounds (the space invaders demo). Maybe you should check that out to see how he did it?
Marc
Thanks for your reply Marc,
The reference to David's interface is very helpful. It works perfectly, and I think I can get to the root of the problem with a little digging.
-Patrick
On Wed, Feb 15, 2012 at 6:38 PM, Marc Feeley feeley@iro.umontreal.cawrote:
On 2012-02-15, at 9:17 PM, Patrick Li wrote:
Hi,
I am trying to get Gambit playing well with SDL, and am running into
some strange problems when trying to set up the scheme environment.
This is the main() function that starts up a SDL window:
int main(int argc, char *argv[]) { /* //SETUP */ ___setup_params_struct setup_params; ___setup_params_reset (&setup_params); setup_params.version = ___VERSION; setup_params.linker = SCHEME_LIBRARY_LINKER; ___setup (&setup_params);
x = 0; run_stuff(); //Starts a simple SDL animation
/* //CLEANUP */ ___cleanup (); }
Currently everything is still in C, so there are *no* calls to any
scheme functions yet.
That's not necessarily the case. When ___setup() is called, your Scheme program will be run and it might contain Scheme calls (in your previous example you were calling println for instance). Usually this "execution" of your Scheme program takes care of the initializations your program requires. After ___setup() returns, but before you call ___cleanup(), you can call Scheme functions declared using c-define in your Scheme code.
I found that the animation runs for about 3 seconds before the whole
program hangs. If I comment out __setup(&setup_params), then the program executes normally.
Are there some subtleties when setting up the Gambit environment that I
have to watch out for? Is Gambit spawning another thread and causing some deadlock problems? I am fairly certain that SDL is single-threaded, and the whole animation runs in an infinite loop.
The Gambit runtime is also single threaded (it does not create any OS threads, except on Windows to simulate interval timers, but that's not relevant here).
The problem could be an interference between the OS resources used by SDL and those used by the Gambit runtime, in particular the Gambit runtime sets up some signal handlers, for example to implement the heartbeat interrupt. Perhaps the SDL library is doing the same?
I know that David St-Hilaire wrote an interface to SDL which is on the Gambit Dumping Grounds (the space invaders demo). Maybe you should check that out to see how he did it?
Marc