[gambit-list] multiple main functions!

Marc Feeley feeley at iro.umontreal.ca
Thu Jul 20 21:46:31 EDT 2006


Ryan, you need to link to libgambc.a (which does not have a main  
function).  The best way to see how this can be done is to build the  
pthread example (i.e. cd examples/pthread; make examples).  The  
pthread example has a main function in C, and several C threads that  
call into Scheme (one at a time thanks to a POSIX threads mutex).   
You should also look at test #8 (i.e. cd tests; make test8).  It has  
a C main function that calls into Scheme to evaluate some S- 
expressions in strings.

Hope that answers your question.

Marc

On 20-Jul-06, at 6:21 PM, Ryan Prescott wrote:

> Hi,
>
> I've perused the archives of the Gambit-C mailing list looking for  
> info
> on this issue so I apologize if this is a well known issue.
>
> I've got a C application that I want to use a gambit thread
> (actually a termite process). I have a main function defined in C and
> a library defined in scheme that I want to init/call from C.
>
> Unfortunately, I get multiple main functions when building and the  
> msvc
> linker doesn't like that too much. Being brave, I instructed the  
> linker
> to ignore the multiple main error condition and "just use" my C  
> main func.
>
> This does NOT seem to result in a stable situation for the scheme  
> world,
> as when I call __setup() I get an exception. Note that the  
> exception is
> handled by the gambit runtime, but there definitely seems to
> be some init time badness. The termite process does not respond to
> messages, etc.
>
> I also tried defining ___LIBRARY during C builds to no avail. This did
> get rid of the multiple main error, but I still get the exception.
>
> Is there any way to get gambit to not generate a main function? I  
> guess
> I was looking for something like chicken's -embedded option. I had  
> some
> amount of hope when perusing gambit.h at the -flat option, but I think
> this requires me to resolve functions at startup manually.
>
> (chicken doc reference http://galinha.ucpel.tche.br/Embedding)
>
> FYI I'm building the scheme code with:
> 	gsc -f -check myfile.scm
>
> Thanks,
> Ryan
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> http://mailman.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list