C File can be compiled with GCC but does not compile with G++

Hi, I'm using this compile's version from GCC
1
2
3
4
5
6
7
8
maiko@maiko-laptop:~$ gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
Este é um software livre; veja as fontes para as condições de cópia. NÃO HÁ
garantias; nem mesmo de COMERCIALIZAÇÃO ou ADEQUAÇÃO A UMA FINALIDADE
ESPECÍFICA.

maiko@maiko-laptop:~$ 


and this compile's version from G++
1
2
3
4
5
6
7
8
maiko@maiko-laptop:~$ g++ --version
g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
Este é um software livre; veja as fontes para as condições de cópia. NÃO HÁ
garantias; nem mesmo de COMERCIALIZAÇÃO ou ADEQUAÇÃO A UMA FINALIDADE
ESPECÍFICA.

maiko@maiko-laptop:~$ 


I'm compiling one simple C file with GCC which use the libmindtct and the libmath.
1
2
maiko@maiko-laptop:~$ gcc -o teste teste.c -lmindtct -lm
maiko@maiko-laptop:~$

now, with the same simple C file but using the G++
1
2
3
4
5
maiko@maiko-laptop:~$ g++ -o teste teste.c -lmindtct -lm
/tmp/ccEvlFTf.o: In function `main':
teste.c:(.text+0xa4): undefined reference to `get_minutiae(minutiae**, int**, int**, int**, int**, int**, int*, int*, unsigned char**, int*, int*, int*, unsigned char*, int, int, int, double, lfsparms const*)'
collect2: ld returned 1 exit status
maiko@maiko-laptop:~$ 

Why I got this error ? The libs mindtct and math are in /usr folder, both compiles are looking there for libs.
You have a name mangling problem.

Your program is mangling the name of the function (get_minutiae) but the library is compiled as C,
so the name isn't mangled there.

The header file where get_minutiae is declared should have an extern "C" block around it to fix
this.
Thanks man, I'm working on this problem for weeks.

Bye !
Topic archived. No new replies allowed.