[Ecls-list] compiler flags for external libraries
Juan Jose Garcia-Ripoll
worm at arrakis.es
Mon Nov 24 01:01:03 UTC 2003
On Saturday 22 November 2003 03:08, Robert Lehr wrote:
> First, has it been done with ECL? If so, what is the usual method? I
> accomplished this by modifying the exported c:*cc*.
Don't do it this way. I do not remember whether it was introduced in ECL 0.9c,
but the right way would be to use
It works just like BUILD-PROGRAM, but builds a loadable module. Another
possibility would be to just rebind c:*ld-bundle-flags* (in CVS) or
c:*ld-flags* (in previous versions), prepending your flags. As of writing
this message I realized that neither of these options is nice, and I will
probably add another argument to COMPILE-FILE or COMPILE so that users can
supply their own ld- and cc- flags.
> The second matter concerns current scope during compilation. These two
> forms fail...
> (eval-when (:compile-toplevel)
> (in-package :c)
> (setq *cc*
> (format nil "~A ~A" *cc*
> " -I/usr/include/my-lib -Wl,-L/usr/lib/mylib -Wl,-lmylib")))
> That does not seem right to me. Is that correct? If so then then why?
Yes, _ECL_ is right :-) The whole eval-when is read together, because it is a
single list. That means that your (in-package :c) does not take place when
the form is read, but afterwards, at run time, and the symbol *cc* is read in
the cl-user package, not in the C package. The right way to code that:
(format nil "~A ~A" *cc*
" -I/usr/include/my-lib -Wl,-L/usr/lib/mylib -Wl,-lmylib")))
But this is also not "right". If you want to change the compiler or linker
flags, do it around your compilation form:
(let ((c::*cc-flags* (concatenate 'string c::*cc-flags* "..."))
(c::*ld-bundle-flags* (concatenate ...))
or define your own compile-file function which wraps around the original one.
(let ((old-cf #'compile-file))
(si::package-lock "CL" nil) ;; So that ECL does not complain
(defun compile-file (&rest args)
(let ((c::*cc-flags* ...)
(apply old-cf args))))
More information about the ecl-devel