Connecting Tech Pros Worldwide Forums | Help | Site Map

g++ with C libraries

Praveen Srinivasan
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi,
I'm trying to link a g++ program against a library called libumf.a compiled
from C code, and am having problems. When I do

gcc -o foo.o foo.c -llibumf.a it works fine. But when I do
g++ -o foo.o foo.c -llibumf.a it complains with:

/tmp/ccg2Xl4u.o(.text+0x17): In function `main':
: undefined reference to `umfpack_di_free_numeric(void**)'
collect2: ld returned 1 exit status

where "umfpack_di_free_numeric(void**)" is the only function that I'm
calling from the library.

Is there something I need to know about linking C++ code with C libraries?

TIA,
Praveen

Pete C.
Guest
 
Posts: n/a
#2: Jul 22 '05

re: g++ with C libraries


Praveen Srinivasan wrote:[color=blue]
> Hi,
> I'm trying to link a g++ program against a library called libumf.a
> compiled from C code, and am having problems. When I do
>
> gcc -o foo.o foo.c -llibumf.a it works fine. But when I do
> g++ -o foo.o foo.c -llibumf.a it complains with:
>
> /tmp/ccg2Xl4u.o(.text+0x17): In function `main':[color=green]
>> undefined reference to `umfpack_di_free_numeric(void**)'[/color]
> collect2: ld returned 1 exit status
>
> where "umfpack_di_free_numeric(void**)" is the only function that I'm
> calling from the library.
>
> Is there something I need to know about linking C++ code with C
> libraries?
>
> TIA,
> Praveen[/color]

Specific implementations and third-party libraries are off-topic here; try a
"G++" newsgroup or a mailing list or forum for your library.

Note: you may need to enclose the header like so:
extern "C"
{
#include "yourlib.h"
}

- Pete


Closed Thread