lapacke.h: template with C linkage error [patch included]

Open discussion regarding features, bugs, issues, vendors, etc.

lapacke.h: template with C linkage error [patch included]

Postby robzumwalt » Fri Jan 11, 2013 4:05 pm

This has been covered before here:

viewtopic.php?f=2&t=2284

But this issue is still present in lapack 3.4.2 with gcc 4.7.2 on Fedora 17.

It would be great if such a fix could make it in the next release (3.4.3?)

Here is the diff that was needed to fix the issue, only lapacke.h needs to be changed.
The issue is that there cannot be #include <complex.h> (which has templates) inside an extern "C" block.

Code: Select all
@@ -41,10 +41,6 @@
 #include "lapacke_config.h"
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 #include <stdlib.h>
 
 #ifndef lapack_int
@@ -106,6 +102,10 @@ lapack_complex_double lapack_make_complex_double( double re, double im );
 
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
 #ifndef LAPACKE_malloc
 #define LAPACKE_malloc( size ) malloc( size )
 #endif
robzumwalt
 
Posts: 4
Joined: Fri Jan 11, 2013 3:52 pm

Re: lapacke.h: template with C linkage error [patch included

Postby admin » Sun Jan 27, 2013 1:49 pm

Thank you rob.

this is the current lapacke.h for the next release. You can access it on our svn.
I believe this address the problem.
Julie
Code: Select all
#ifndef _LAPACKE_CONFIG_H_
#define _LAPACKE_CONFIG_H_

#ifdef __cplusplus
#if defined(LAPACK_COMPLEX_CPP)
#include <complex>
#endif
extern "C" {
#endif /* __cplusplus */

#include <stdlib.h>

#ifndef lapack_int
#if defined(LAPACK_ILP64)
#define lapack_int              long
#else
#define lapack_int              int
#endif
#endif

#ifndef lapack_logical
#define lapack_logical          lapack_int
#endif

#ifndef LAPACK_COMPLEX_CUSTOM

#if defined(LAPACK_COMPLEX_STRUCTURE)

typedef struct { float real, imag; } _lapack_complex_float;
typedef struct { double real, imag; } _lapack_complex_double;
#define lapack_complex_float  _lapack_complex_float
#define lapack_complex_double _lapack_complex_double
#define lapack_complex_float_real(z)  ((z).real)
#define lapack_complex_float_imag(z)  ((z).imag)
#define lapack_complex_double_real(z)  ((z).real)
#define lapack_complex_double_imag(z)  ((z).imag)

#elif defined(LAPACK_COMPLEX_C99)

#include <complex.h>
#define lapack_complex_float    float _Complex
#define lapack_complex_double   double _Complex
#define lapack_complex_float_real(z)       (creal(z))
#define lapack_complex_float_imag(z)       (cimag(z))
#define lapack_complex_double_real(z)       (creal(z))
#define lapack_complex_double_imag(z)       (cimag(z))

#elif defined(LAPACK_COMPLEX_CPP)

#define lapack_complex_float std::complex<float>
#define lapack_complex_double std::complex<double>
#define lapack_complex_float_real(z)       ((z).real())
#define lapack_complex_float_imag(z)       ((z).imag())
#define lapack_complex_double_real(z)       ((z).real())
#define lapack_complex_double_imag(z)       ((z).imag())

#else

#include <complex.h>
#define lapack_complex_float    float _Complex
#define lapack_complex_double   double _Complex
#define lapack_complex_float_real(z)       (creal(z))
#define lapack_complex_float_imag(z)       (cimag(z))
#define lapack_complex_double_real(z)       (creal(z))
#define lapack_complex_double_imag(z)       (cimag(z))

#endif

lapack_complex_float lapack_make_complex_float( float re, float im );
lapack_complex_double lapack_make_complex_double( double re, double im );

#endif

#ifndef LAPACK_malloc
#define LAPACK_malloc( size )   malloc( size )
#endif

#ifndef LAPACK_free
#define LAPACK_free( p )        free( p )
#endif

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _LAPACKE_CONFIG_H_ */
admin
Site Admin
 
Posts: 504
Joined: Wed Dec 08, 2004 7:07 pm

Re: lapacke.h: template with C linkage error [patch included

Postby robzumwalt » Mon Jan 28, 2013 4:31 pm

Hi Julie,

Thank you for your time. I do not see it in the lapack svn as of r1379. Is there another svn that I should use other than the one mentioned on this page? http://www.netlib.org/lapack/#_svn_access
robzumwalt
 
Posts: 4
Joined: Fri Jan 11, 2013 3:52 pm

Re: lapacke.h: template with C linkage error [patch included

Postby arwild01 » Fri Mar 01, 2013 2:49 pm

I think I'm running into the same issue and I'm a bit confused as to the status of the fix. Rob specifically mentions the issue as lapacke.h, but the file you posted is lapacke_config.h which doesn't appear to be any different then the version in 3.4.2. I've looked at SVN (where I can diff the files) and lapacke_config.h has definately not changed on trunk. lapacke.h has changed, but the changes don't appear to have anything to do with this issues (looks mostly like some additional functions have been added).
arwild01
 
Posts: 1
Joined: Fri Mar 01, 2013 2:46 pm

Re: lapacke.h: template with C linkage error [patch included

Postby Matt Phillips » Thu Apr 04, 2013 1:14 am

Just checking in to say that I just got version 1387 off svn and I'm having the same problem (as with 3.4.2), "template with C linkage", associated with both complex and sstream stl files.
Matt Phillips
 
Posts: 5
Joined: Thu Apr 04, 2013 12:37 am

Re: lapacke.h: template with C linkage error [patch included

Postby admin » Thu Apr 04, 2013 1:23 am

Could you please check version 1388 ;-)
Thank you all and sorry for the mess...
admin
Site Admin
 
Posts: 504
Joined: Wed Dec 08, 2004 7:07 pm

Re: lapacke.h: template with C linkage error [patch included

Postby Matt Phillips » Thu Apr 04, 2013 1:30 am

Ha! Just put

Code: Select all
#include <complex.h>
#define lapack_complex_float    float _Complex
#define lapack_complex_double   double _Complex

prior to

Code: Select all
#include <lapacke.h>

in the calling code. This does require the user to make sure that the definitions don't get out of sync as LAPACK continues to be developed, so solving this within the lapacke code itself would be great.
Matt Phillips
 
Posts: 5
Joined: Thu Apr 04, 2013 12:37 am

Re: lapacke.h: template with C linkage error [patch included

Postby robzumwalt » Thu May 30, 2013 5:11 pm

Is there a planned release date that will include this fix? I'd like to use this with Openblas.
robzumwalt
 
Posts: 4
Joined: Fri Jan 11, 2013 3:52 pm


Return to User Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron