calling clapack routines from c++

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

calling clapack routines from c++

Postby djones » Mon Jun 12, 2006 3:32 pm

First let me apologize for my ignorance; I'm quite new to all this. I'm trying to call clapack routine(s) (specifically, dggev) from a main program written in c++. Before I did this, I wrote a test program in C to make sure I could get the routine to work, and was able to do this successfully. This C program included as headers the following:
Code: Select all
#include "../CLAPACK/F2CLIBS/f2c.h"
#include "../CLAPACK/SRC/blaswrap.h"
#include "../CLAPACK/clapack.h"

and i compiled it using gcc version 3.4.3 with the following command:
Code: Select all
gcc -o test test.c ../CLAPACK/lapack_LINUX.a ../CLAPACK/blas_LINUX.a ../CLAPACK/F2CLIBS/libF77.a -lm

This compiles without a problem. Now, when i try to do this from c++, i was under the impression that enclosing the header files in extern "C" { } would be enough to get it to work, i.e.,
Code: Select all
extern "C"{
#include "CLAPACK/F2CLIBS/f2c.h"
#include "CLAPACK/SRC/blaswrap.h"
#include "CLAPACK/clapack.h"

I tried to compile using (freq.cpp is the main program, the other .cpp programs contain other functions called by it)
Code: Select all
g++ -o freq freq.cpp derivs.cpp equation.cpp CLAPACK/lapack_LINUX.a CLAPACK/blas_LINUX.a CLAPACK/F2CLIBS/libF77.a

but i immediately get a bunch of errors from f2c.h, for instance:
Code: Select all
In file included from freq.cpp:7:
CLAPACK/F2CLIBS/f2c.h:16: error: `real' does not name a type
CLAPACK/F2CLIBS/f2c.h:132: error: `real' does not name a type
CLAPACK/F2CLIBS/f2c.h:134: error: `complex' does not name a type
CLAPACK/F2CLIBS/f2c.h:174: error: ISO C++ forbids declaration of `real' with no
CLAPACK/F2CLIBS/f2c.h:174: error: typedef `real' is initialized (use __typeof__

and so on...Also, clapack.h generates a million errors because somehow apparently all the types defined in f2c.h (real, integer, and so on) aren't recognized when the compiler goes through clapack.h. for instance,
Code: Select all
In file included from freqFinder.cpp:9:
CLAPACK/clapack.h:5: error: `real' has not been declared

So if anyone has any ideas about what i'm doing wrong, or why gcc has no problems with f2c.h while g++ generates many many errors, I'd appreciate any help. Perhaps i am mistaken about the extern "C" part? I should also note that i'm not using ATLAS BLAS but merely the one available with clapack at I'll probably change that at some point, but for now i'm just trying to get it to work without worrying about optimization or any of that. Thanks!
Posts: 1
Joined: Mon Jun 12, 2006 2:20 pm
Location: Ithaca, NY

Return to User Discussion

Who is online

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