chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] static library and link


From: Thomas Chust
Subject: Re: [Chicken-users] static library and link
Date: Mon, 22 May 2006 19:13:05 +0100 (GMT Daylight Time)

On Mon, 22 May 2006, Frederic Peschanski wrote:

[...] My initial plan, in order to be portable across linux and cygwin, was to compile a static library e.g. mylib.a from the .scm (and .c and .o) files.

Hello,

maybe I'm missing something here, but why should it be a problem on either cygwin or linux to build a shared library?

For the library part, the makefile I use produces something like: [...]

I think the actual Makefile and some source snippets would have been much more helpful in order to reproduce your problems than just the compiler output...

It's probably bad but in my .scm files, only the main one, pischeme.scm starts with a "declare unit" (I think this does only apply to shared libraries).

On the contrary the (declare (unit ...)) syntax and the corresponding (declare (uses ...)) is mostly intended for statically linked code.

Maybe I should use csc instead of chicken but I have not yet figured out how I could use it to make a static lib.

For the sake of easier portability and to save a lot of typing and manual configuration I would recommend to always use the csc compiler driver instead of chicken if you can. Using chicken directly is as clever as using cpp, cc1 and ld from the GNU compiler collection and binutils directly instead of using gcc. If you just want to compile to object code for later bundling as a library run commands like csc -c foo.scm -o foo.o. For the basic operations you can assume very close analogy between the command line options for csc and gcc. Have a look at the output of csc -help to learn more about csc's options, though.

Now, in a separate directory, I wrote an example that I compile as follows: [...]

Hmm, maybe you should link in the C library with -lc as well. Only gcc adds that option automagically, ld probably doesn't. And then you should probably link your static application to the static CHICKEN libraries instead of the dynamic ones, because Windows has a -- in my eyes -- braindamaged dynamic linkage system and you would have to apply a fair amount of magic to the CHICKEN include files and maybe also to the generated C sources to use mixed linkage. (For more information on this class of linkage problems see the following thread on this list http://lists.gnu.org/archive/html/chicken-users/2006-05/msg00055.html, but only if you are interested in gory details ;-)

Or maybe it's simply wrong to make a static lib ? [...]

Certainly not for some types of application. But I think it is easier to use dynamic linkage with CHICKEN.

By the way I'm currently experimenting with a little self developed hack in the CHICKEN runtime to make it use libltdl from the GNU libtool package so it doesn't have to care whether it's linked dynamically or statically any more and everything just works exactly the same in both worlds...

cu,
Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]