public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Stupid question...
@ 2009-10-11 13:52 Robert G. Brown
  2009-10-11 14:06 ` Robert G. Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Robert G. Brown @ 2009-10-11 13:52 UTC (permalink / raw)
  To: GSL Discussion list

I'm trying to get gsl to be correctly detected in a configure.ac
(something that has never quite worked, for reasons I don't understand).

The following lines are what I've got.  I don't quite understand either
why the gsl check fails or why the gslcblas succeeds.  I've tried lots
of different functions (including [main]) in the gsl check, but they all
return no.  I've tried including an argument such as gsl_sf_gamma(1.0),
no go.  Is there a simple one liner solution to this somebody could
contribute, or is somebody enough of an expert with autoconf that they
can tell me why this works/doesn't work?

#==================================================================
# Checks for libraries, and headers.
#==================================================================
AC_CHECK_HEADER([gsl/gsl_sf_gamma.h],,[AC_MSG_ERROR([Couldn't find GSL headers! Please install gsl-devel.])])
AC_CHECK_LIB([gsl],[gsl_sf_gamma])
# FIXME: Replace `main' with a function in `-lgslcblas':
AC_CHECK_LIB([gslcblas], [main])


checking gsl/gsl_sf_gamma.h usability... yes
checking gsl/gsl_sf_gamma.h presence... yes
checking for gsl/gsl_sf_gamma.h... yes
checking for gsl_sf_gamma in -lgsl... no
checking for main in -lgslcblas... yes


TIA,

    rgb

Robert G. Brown	                       http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb@phy.duke.edu


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Stupid question...
  2009-10-11 13:52 Stupid question Robert G. Brown
@ 2009-10-11 14:06 ` Robert G. Brown
  2009-10-11 16:49 ` John D Lamb
  2009-10-11 17:42 ` Andrew W. Steiner
  2 siblings, 0 replies; 8+ messages in thread
From: Robert G. Brown @ 2009-10-11 14:06 UTC (permalink / raw)
  To: GSL Discussion list

On Sun, 11 Oct 2009, Robert G. Brown wrote:

> I'm trying to get gsl to be correctly detected in a configure.ac
> (something that has never quite worked, for reasons I don't understand).

Sorry to answer my own question, but GIYF and I found a hint, made a
guess, and here it is.  (Apparently) library check order matters, and
one has to put the rightmost library dependencies first.  -lgsl will not
compile unless -lgslcblas is present, but -lgslcblas will compile
without -lgsl, so inverting the order of the two lines to:

#==================================================================
# Checks for libraries, and headers.  Test for cblas FIRST.
#==================================================================
AC_CHECK_HEADER([gsl/gsl_sf_gamma.h],,[AC_MSG_ERROR([Couldn't find GSL headers! Please install gsl-devel.])])
AC_CHECK_LIB([gslcblas], [main])
AC_CHECK_LIB([gsl],[gsl_sf_gamma])

checking gsl/gsl_sf_gamma.h usability... yes
checking gsl/gsl_sf_gamma.h presence... yes
checking for gsl/gsl_sf_gamma.h... yes
checking for main in -lgslcblas... yes
checking for gsl_sf_gamma in -lgsl... yes

works charm-like.  Makes sense, I suppose, but pretty hard to find in
the documentation for autoconf; I could as easily have thought each
library check was independent, but the output in config.log left me
nothing else to try and it worked.

     rgb

Robert G. Brown	                       http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb@phy.duke.edu


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Stupid question...
  2009-10-11 13:52 Stupid question Robert G. Brown
  2009-10-11 14:06 ` Robert G. Brown
@ 2009-10-11 16:49 ` John D Lamb
  2009-10-11 17:42 ` Andrew W. Steiner
  2 siblings, 0 replies; 8+ messages in thread
From: John D Lamb @ 2009-10-11 16:49 UTC (permalink / raw)
  To: GSL Discussion list

On Sun, 2009-10-11 at 09:52 -0400, Robert G. Brown wrote:
> I'm trying to get gsl to be correctly detected in a configure.ac
> (something that has never quite worked, for reasons I don't understand).

Here’s the version I use.

use_atlas=yes
AC_CHECK_LIB([atlas],[main],[],[use_atlas=no])
if test x$use_atlas = xyes; then
AC_CHECK_LIB([f77blas],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xyes; then
AC_CHECK_LIB([cblas],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xyes; then
AC_CHECK_LIB([lapack],[main],[],[use_atlas=no])
fi
if test x$use_atlas = xno; then
AC_CHECK_LIB([gslcblas],[main],[],[
echo \
"------------------------------------------------------------------------
ERROR: Could not find a CBLAS implementation.
Tried both ATLAS cblas and gslcblas.
------------------------------------------------------------------------"
exit
])
fi
AC_CHECK_LIB([gsl],[main],[],[
echo \
"------------------------------------------------------------------------
ERROR: libgsl appears to be missing. You cannot sanely try to build
this code without libgsl, the GNU Scientific Library. It is available
from
http://www.gnu.org/ and compiles readily on most systems.
------------------------------------------------------------------------"
exit
],[-lgslcblas])

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([gsl/gsl_version.h],[],[
echo \
"------------------------------------------------------------------------
ERROR: libgsl is present, but the header files appear not to have been
installed. If the GNU Scientific Library was installed as an RPM or
similar, make sure you also include the -devel package. Otherwise, you
can
obtain the GNU Scientific Library from http://www.gnu.org.
------------------------------------------------------------------------"
exit
])

-- 
JDL

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Stupid question...
  2009-10-11 13:52 Stupid question Robert G. Brown
  2009-10-11 14:06 ` Robert G. Brown
  2009-10-11 16:49 ` John D Lamb
@ 2009-10-11 17:42 ` Andrew W. Steiner
  2 siblings, 0 replies; 8+ messages in thread
From: Andrew W. Steiner @ 2009-10-11 17:42 UTC (permalink / raw)
  To: Robert G. Brown; +Cc: GSL Discussion list

I looked at the configure.ac file I use, and the code below looks
similar, except that I use AC_CHECK_LIB's optional arguments.

http://o2scl.svn.sourceforge.net/viewvc/o2scl/trunk/configure.ac?revision=43&view=markup

Have you looked at the config.log file to see why it fails? Also, which platform
is this for?

Take care,
Andrew

On Sun, Oct 11, 2009 at 9:52 AM, Robert G. Brown <rgb@phy.duke.edu> wrote:
> I'm trying to get gsl to be correctly detected in a configure.ac
> (something that has never quite worked, for reasons I don't understand).
>
> The following lines are what I've got.  I don't quite understand either
> why the gsl check fails or why the gslcblas succeeds.  I've tried lots
> of different functions (including [main]) in the gsl check, but they all
> return no.  I've tried including an argument such as gsl_sf_gamma(1.0),
> no go.  Is there a simple one liner solution to this somebody could
> contribute, or is somebody enough of an expert with autoconf that they
> can tell me why this works/doesn't work?
>
> #==================================================================
> # Checks for libraries, and headers.
> #==================================================================
> AC_CHECK_HEADER([gsl/gsl_sf_gamma.h],,[AC_MSG_ERROR([Couldn't find GSL
> headers! Please install gsl-devel.])])
> AC_CHECK_LIB([gsl],[gsl_sf_gamma])
> # FIXME: Replace `main' with a function in `-lgslcblas':
> AC_CHECK_LIB([gslcblas], [main])
>
>
> checking gsl/gsl_sf_gamma.h usability... yes
> checking gsl/gsl_sf_gamma.h presence... yes
> checking for gsl/gsl_sf_gamma.h... yes
> checking for gsl_sf_gamma in -lgsl... no
> checking for main in -lgslcblas... yes
>
>
> TIA,
>
>   rgb
>
> Robert G. Brown                        http://www.phy.duke.edu/~rgb/
> Duke University Dept. of Physics, Box 90305
> Durham, N.C. 27708-0305
> Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb@phy.duke.edu
>
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: stupid question
  2001-12-19 13:20 stupid question Matthew J. Doller
  2001-11-19 10:26 ` Matthew J. Doller
@ 2001-12-19 13:20 ` Achim Gaedke
  2001-11-20  2:00   ` Achim Gaedke
  1 sibling, 1 reply; 8+ messages in thread
From: Achim Gaedke @ 2001-12-19 13:20 UTC (permalink / raw)
  To: Matthew J. Doller; +Cc: gsl-discuss

Here is the code... It is changed a little bit, in order to reflect a compilable
program. Do not execute it!

#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>

gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
  
  int num_rows, num_cols;
  gsl_matrix * return_matrix;

  num_rows = m->size1;
  num_cols = m->size2;

  return_matrix = gsl_matrix_alloc ( num_rows , num_cols );

  return (gsl_matrix *) return_matrix;
}

int main () {
  (void*)matrix_return_upper((gsl_matrix*)NULL);
  return 0;
}

it does compile without problems under redhat7.2 and under gsl-1.0 with
gcc-3.0.2.
Maybe you come from c++ and are new to c - like me.
Be careful: Declarations have to be done before using the variables.

Yours, Achim


"Matthew J. Doller" schrieb:
> 
> can someone shed a tiny bit of light on why this seemingly simple
> routine is not compiling for me?
> 
> --- BEGIN CODE ---
> 
> #include "matrix-generic.h"
> #include <gsl/gsl_matrix.h>
> #include <gsl/gsl_vector.h>
> 
> gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
> 
>   int num_rows, num_cols, error;
> 
>   num_rows = m->size1;
>   num_cols = m->size2;
> 
>   gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
>   ...
>   ...
> 
>   return (gsl_matrix *) return_matrix;
> }
> 
> --- END CODE ---
> 
> compile command:
> gcc -o mytest matrix-generic.c -lgsl -lgslcblas -lm
> 
> compile errors:
> matrix-generic.c: In function `matrix_return_upper':
> matrix-generic.c:30: parse error before `*'
> 
> the * in question is from the line:
> gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
> for now, i have stripped out all the rest of the code after that line to
> simplify debugging.  please tell me that i'm over looking something
> simple.
> 
> thanks in advance
> matt
> 
> --
> Matthew J. Doller
> mdoller@wpi.edu
> http://www.wpi.edu/~mdoller

^ permalink raw reply	[flat|nested] 8+ messages in thread

* stupid question
@ 2001-12-19 13:20 Matthew J. Doller
  2001-11-19 10:26 ` Matthew J. Doller
  2001-12-19 13:20 ` Achim Gaedke
  0 siblings, 2 replies; 8+ messages in thread
From: Matthew J. Doller @ 2001-12-19 13:20 UTC (permalink / raw)
  To: gsl-discuss

can someone shed a tiny bit of light on why this seemingly simple
routine is not compiling for me?

--- BEGIN CODE ---

#include "matrix-generic.h"
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>

gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
  
  int num_rows, num_cols, error;

  num_rows = m->size1;
  num_cols = m->size2;

  gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );

  ...
  ...
  
  return (gsl_matrix *) return_matrix;
}

--- END CODE ---


compile command: 
gcc -o mytest matrix-generic.c -lgsl -lgslcblas -lm

compile errors:
matrix-generic.c: In function `matrix_return_upper':
matrix-generic.c:30: parse error before `*'

the * in question is from the line:
gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );


for now, i have stripped out all the rest of the code after that line to
simplify debugging.  please tell me that i'm over looking something
simple.

thanks in advance
matt


-- 
Matthew J. Doller 
mdoller@wpi.edu
http://www.wpi.edu/~mdoller

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: stupid question
  2001-12-19 13:20 ` Achim Gaedke
@ 2001-11-20  2:00   ` Achim Gaedke
  0 siblings, 0 replies; 8+ messages in thread
From: Achim Gaedke @ 2001-11-20  2:00 UTC (permalink / raw)
  To: Matthew J. Doller; +Cc: gsl-discuss

Here is the code... It is changed a little bit, in order to reflect a compilable
program. Do not execute it!

#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>

gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
  
  int num_rows, num_cols;
  gsl_matrix * return_matrix;

  num_rows = m->size1;
  num_cols = m->size2;

  return_matrix = gsl_matrix_alloc ( num_rows , num_cols );

  return (gsl_matrix *) return_matrix;
}

int main () {
  (void*)matrix_return_upper((gsl_matrix*)NULL);
  return 0;
}

it does compile without problems under redhat7.2 and under gsl-1.0 with
gcc-3.0.2.
Maybe you come from c++ and are new to c - like me.
Be careful: Declarations have to be done before using the variables.

Yours, Achim


"Matthew J. Doller" schrieb:
> 
> can someone shed a tiny bit of light on why this seemingly simple
> routine is not compiling for me?
> 
> --- BEGIN CODE ---
> 
> #include "matrix-generic.h"
> #include <gsl/gsl_matrix.h>
> #include <gsl/gsl_vector.h>
> 
> gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
> 
>   int num_rows, num_cols, error;
> 
>   num_rows = m->size1;
>   num_cols = m->size2;
> 
>   gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
>   ...
>   ...
> 
>   return (gsl_matrix *) return_matrix;
> }
> 
> --- END CODE ---
> 
> compile command:
> gcc -o mytest matrix-generic.c -lgsl -lgslcblas -lm
> 
> compile errors:
> matrix-generic.c: In function `matrix_return_upper':
> matrix-generic.c:30: parse error before `*'
> 
> the * in question is from the line:
> gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );
> 
> for now, i have stripped out all the rest of the code after that line to
> simplify debugging.  please tell me that i'm over looking something
> simple.
> 
> thanks in advance
> matt
> 
> --
> Matthew J. Doller
> mdoller@wpi.edu
> http://www.wpi.edu/~mdoller

^ permalink raw reply	[flat|nested] 8+ messages in thread

* stupid question
  2001-12-19 13:20 stupid question Matthew J. Doller
@ 2001-11-19 10:26 ` Matthew J. Doller
  2001-12-19 13:20 ` Achim Gaedke
  1 sibling, 0 replies; 8+ messages in thread
From: Matthew J. Doller @ 2001-11-19 10:26 UTC (permalink / raw)
  To: gsl-discuss

can someone shed a tiny bit of light on why this seemingly simple
routine is not compiling for me?

--- BEGIN CODE ---

#include "matrix-generic.h"
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_vector.h>

gsl_matrix * matrix_return_upper ( gsl_matrix *m ){
  
  int num_rows, num_cols, error;

  num_rows = m->size1;
  num_cols = m->size2;

  gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );

  ...
  ...
  
  return (gsl_matrix *) return_matrix;
}

--- END CODE ---


compile command: 
gcc -o mytest matrix-generic.c -lgsl -lgslcblas -lm

compile errors:
matrix-generic.c: In function `matrix_return_upper':
matrix-generic.c:30: parse error before `*'

the * in question is from the line:
gsl_matrix * return_matrix = gsl_matrix_alloc ( num_rows , num_cols );


for now, i have stripped out all the rest of the code after that line to
simplify debugging.  please tell me that i'm over looking something
simple.

thanks in advance
matt


-- 
Matthew J. Doller 
mdoller@wpi.edu
http://www.wpi.edu/~mdoller

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-11 17:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-11 13:52 Stupid question Robert G. Brown
2009-10-11 14:06 ` Robert G. Brown
2009-10-11 16:49 ` John D Lamb
2009-10-11 17:42 ` Andrew W. Steiner
  -- strict thread matches above, loose matches on Subject: below --
2001-12-19 13:20 stupid question Matthew J. Doller
2001-11-19 10:26 ` Matthew J. Doller
2001-12-19 13:20 ` Achim Gaedke
2001-11-20  2:00   ` Achim Gaedke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).