(newbie) can compile with gcc but not with g++
Kamaraju Kusumanchi
kk288@cornell.edu
Fri Apr 9 23:04:00 GMT 2004
Hi all
I am a newbie regarding c/c++ programming. From what I read, If I
write a C program, I can compile with both gcc and g++. I'm not able to
do the later. Here are the details.
I compiled the clapack package (downloaded from netlib) on intel p4 2.8
using gcc (3.3.3). I am using debian testing. Consider the following program
#include <stdio.h>
int main()
{
double a[16] = {11,14,15,16,7,10,13,12,5,6,8,9,1,2,3,4};
/* Actual matrix is 11 7 5 1
* 14 10 6 2
* 15 13 8 3
* 16 12 9 4
*/
double b[4] = {1.2,3.2,6.2,2.4};
int M=4,N=1,lda=4,ldb=4,ipiv[4],info, ret;
int i,j;
for(i=0; i<4; i++) {
for(j=0; j<4; j++) {
printf("%f ", a[i*4+j]);
}
printf("\n");
}
for(i=0; i<4; i++) printf("%f\n", b[i]);
dgesv_(&M, &N, a, &lda, ipiv, b, &ldb, &info);
for(i=0; i<4; i++) printf("%f\n", b[i]);
// Correct answer is -0.76, 1.83, -0.51, -0.70
printf("%d\n",info);
return 0;
}
I am able to run this program with gcc using the following commands.
gcc -c -O2 ludecomp.c
gcc ludecomp.o libtmglib.a liblapack.a libblas.a libF77.a libI77.a -lm -lc
./a.out
But when I use g++, I am getting the following error
mv ludecomp.c ludecomp.cpp
g++ -c ludecomp.cpp
ludecomp.cpp: In function `int main()':
ludecomp.cpp:22: error: `dgesv_' undeclared (first use this function)
ludecomp.cpp:22: error: (Each undeclared identifier is reported only
once for
each function it appears in.)
Obviously, I am doing something stupid. Could anyone please tell me what
I am doing wrong and point the right direction. I searched in google,
this mailing list archives - but they were of no help.
thanks
raju
Home page: http://www.people.cornell.edu/pages/kk288/index.html
Fluid's group: http://groups.yahoo.com/group/flumech/
More information about the Gcc-help
mailing list