2

I have an extconf.rb with the following lines:

have_header("cblas.h")                 # checking for cblas.h... yes
have_func("cblas_dgemm", ["cblas.h"])  # checking for cblas_dgemm() in cblas.h... no
create_header("nmatrix_config.h")      # creating nmatrix_config.h

So, cblas_dgemm is definitely in cblas.h. When I look at mkmf.log, I see that this check actually looks for two things:

  1. a _cblas_dgemm symbol somewhere (?)
  2. a callable cblas_dgemm in cblas.h.

Both tests are failing. I assume the former is failing because I need a dir_config line for cblas, and maybe a have_library('cblas').

But I can't figure out how to make the latter test pass (see line 24 of the gist). Is it possible to pass a block to have_func so it actually calls it with reasonable arguments? Or is there some other way to run this test? Or do I have to have the dir_config stuff setup properly?

Here's line 24, by the way:

conftest.c:7:1: error: too few arguments to function ‘cblas_dgemm’

And yes, of course, cblas_dgemm needs many arguments -- some of them matrices.

It's frustrating how little documentation there is on any of these mkmf functions.

user1614572
  • 153
  • 1
  • 7
Translunar
  • 3,739
  • 33
  • 55
  • Have you tried just `have_func('cblas_dgemm')`? That might just try to link something that references the `cblas_dgemm` function without involving the header at all. You'll need to figure out the appropriate `-l` switches first though. – mu is too short Mar 31 '13 at 04:36
  • I have, and it works in some cases, but the lack of documentation makes it almost impossible to predict *when* it will happen. – Translunar Apr 01 '13 at 16:05
  • How come no one has bothered to rewrite `mkmf`? It seems like a good candidate for a rewrite. – Translunar Apr 03 '13 at 18:18

2 Answers2

3

Unfortunately it looks like have_func is pretty poorly documented, but upon some digging I found something that might help:

[25] pry(main)> have_func("clapack_dgetrf", "/usr/local/atlas/include/clapack.h")
checking for clapack_dgetrf() in /usr/local/atlas/include/clapack.h... no
=> false
[26] pry(main)> have_func("int clapack_dgetrf", "/usr/local/atlas/include/clapack.h")
checking for int clapack_dgetrf() in /usr/local/atlas/include/clapack.h... yes
=> true

So, essentially it looks like you need to include at least the return type to get have_func to work properly. Can you verify that this works on your machine?

acsmith
  • 1,466
  • 11
  • 16
0

In mkmf.rb of ruby 1.9.3p392, The latter test is executed only if the former fails. When the former passes, have_func successes. So you don't have to make the latter pass. Refer to try_func in mkmf.rb for more details.

Just for information, in mkmf.rb on 2013-04-13 11:00:25, it seems you can give arguments like this: have_func("some_func(some_arg, another_arg)", ["foo.h"]).

user1614572
  • 153
  • 1
  • 7