[solved] Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- From: "H.S." <hs.saDELETEMEmix@xxxxxxxxx>
- Date: Fri, 10 Aug 2007 10:44:11 -0400
Georg Baum wrote:
H.S. wrote:
Okay, that makes sense. I also got similar advice from comp.lang.c++.
(the people there are fanatically picky about talking about *only* about
C++ language ... so I don't think I get further insights from there).
Strictly speaking this is not ontopic here either.
Ah. *That* statement again. I hold the view that if some newbie wanted
to solve a similar problem while working with a numerical library, it
would not be unreasonable for him to look here or ask for advice here. I
would also like to mention that I have also tried c++ and gcc help
newsgroups and even the Taucs author himself from whom I haven't
received any reply yet. Other than the last one, every bit helped in a
specific way.
I tried it again without the extern keyword. Here is my example program
I am trying now:
-----------------------------------------------------------
#define TAUCS_CORE_DOUBLE
#include <taucs.h>
extern taucs_ccs_matrix* taucs_ccs_create(int m,int n,int nnz,int flags);
extern void taucs_ccs_free(taucs_ccs_matrix* matrix);
As I wrote, these two declarations are wrong, because they are already in
one of the taucs header files. You declare here two functions with C++
linkage, but taucs is written in C, and the library contains these function
with C linkage. That is the reason for your linker error.
Agreed.
Your problem is that taucs is written in C, and because it uses C99 complex
numbers (at least in the default configuration) it cannot be used directly
from C++ (the C++ standard does not include the C99 complex keywords).
hmm ... but looks like it is not the problem exactly.
If you can configure it to not use C99 complex types, then it might work if
you specify C linkage for the taucs stuff:
extern "C" {
#include <taucs.h>
}
Terrible, terrible idea. Still, I tried. It failed miserably.
The problem is that the taucs library is not written in a portable
manner. The key is to wrap the function declarations in the relevant
header file of that library with the standard extern "C" wrapper like so:
ifdef __cplusplus
extern "C" {
#endif
taucs_ccs_matrix* taucs_dtl(ccs_create) (int m, int n, int nnz);
taucs_ccs_matrix* taucs_ccs_create (int m, int n, int nnz,
int flags);
void taucs_dtl(ccs_free) (taucs_ccs_matrix* matrix);
void taucs_ccs_free (taucs_ccs_matrix* matrix);
#ifdef __cplusplus
}
#endif
Then, but just including taucs.h in my source file, my example program
compiles.
Next, I am now working to make this modification in the header files so
that the library can be linked from a C++ source code. I will probably
post here on what I eventually settle on.
Thanks a ton to everyone who could help,
->HS
Otherwise, you'll need to create a wrapper. Evgenii Rudnyi told not long ago.
that he has written one: Message-ID:
<1185006162.197752.74000@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Georg
- Follow-Ups:
- References:
- solving Ax=b with sparse A
- From: H.S.
- Re: solving Ax=b with sparse A
- From: Evgenii Rudnyi
- compiling taucs problem (Re: solving Ax=b with sparse A)
- From: H.S.
- Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- From: Georg Baum
- Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- From: H.S.
- Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- From: Georg Baum
- solving Ax=b with sparse A
- Prev by Date: Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- Next by Date: Re: [solved] Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- Previous by thread: Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- Next by thread: Re: [solved] Re: compiling taucs problem (Re: solving Ax=b with sparse A)
- Index(es):