[gambit-list] Linking
Marc Feeley
feeley at iro.umontreal.ca
Thu Nov 4 16:31:32 EDT 2010
On 2010-11-04, at 4:19 PM, Brady McCary wrote:
> gambit-list,
>
> I had composed a long-winded email about some trouble I was having
> linking against ATLAS
>
> http://math-atlas.sourceforge.net/
>
> but I figured it out. Because I am using external C++ dependencies I
> compiled gambit using C++. It turns out that I want to use
>
> (c-declare #<<c-declare-end
>
> extern "C"
> {
> #include <cblas.h>
> };
>
> c-declare-end
> )
>
> and not
>
> (c-declare "#include <cblas.h>")
>
> This is obvious in retrospect. However I wasted about 90 minutes on
> this. Hopefully someone will search for
>
> gambit, linker, link, linking, atlas, blas, lapack, undefined reference
>
> and find this message here.
>
> Brady
Thanks for keeping a record of your errors for others to learn from. Let me add that your code could be improved by having instead:
(c-declare #<<c-declare-end
___BEGIN_C_LINKAGE
#include <cblas.h>
___END_C_LINKAGE
c-declare-end
)
The ___BEGIN_C_LINKAGE and ___END_C_LINKAGE macros, defined in gambit.h, will expand to extern "C" { ... } when compiling with a C++ compiler, and to nothing when compiling with a C compiler. So your code will be more portable because it will work regardless of the kind of C compiler you are using.
Marc
More information about the Gambit-list
mailing list