Re: keep getting "undefined reference to" linker error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Dessent wrote:

> 
> I'm guessing that libtaucs is a C library, and there are no 'extern "C"'
> qualifiers on the declarations in the taucs.h header.  Thus, your

You are correct, there are no 'extern "C"' in taucs.h.

> spmat.cc file is compiled as C++ and is trying to call the C++ decorated
> versions of these functions, which do not exist.  (You can tell this
> because in the undefined reference errors the argument signature/types
> are present, which you would not see when failing to link a plain C

Okay, thanks for that pointer.

> function.  You could double check by looking at the generated assembler
> source.)

er .. how? nm?

> 
> The proper fix would be to add the standard boilerplate to the header:
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> 
> ...
> 
> #ifdef __cplusplus
> }
> #endif
> 
> Brian
> 

Yeah, that is what I tried earlier. If I use the header like so:
#ifdef __cplusplus
extern "C" {
#endif
#include <taucs.h>
#ifdef __cplusplus
}
#endif // __cplusplus



with the rest of the example program the same, I get tons of errors.
Here is a sample:
/usr/include/c++/4.1.3/bits/locale_classes.h:480: error: template with C
linkage
/usr/include/c++/4.1.3/bits/locale_classes.h:484: error: template with C
linkage
/usr/include/c++/4.1.3/bits/locale_classes.h:488: error: template with C
linkage
/usr/include/c++/4.1.3/bits/locale_classes.h:556: error: template with C
linkage
/usr/include/c++/4.1.3/bits/locale_classes.h:565: error: template with C
linkage
/usr/include/c++/4.1.3/bits/ios_base.h: In function ‘std::_Ios_Openmode
std::operator&(std::_Ios_Openmode, std::_Ios_Openmode)’:
/usr/include/c++/4.1.3/bits/ios_base.h:119: error: declaration of C
function ‘std::_Ios_Openmode std::operator&(std::_Ios_Openmode,
std::_Ios_Openmode)’ conflicts with
/usr/include/c++/4.1.3/bits/ios_base.h:79: error: previous declaration
‘std::_Ios_Fmtflags std::operator&(std::_Ios_Fmtflags,
std::_Ios_Fmtflags)’ here
/usr/include/c++/4.1.3/bits/ios_base.h: In function ‘std::_Ios_Openmode
std::operator|(std::_Ios_Openmode, std::_Ios_Openmode)’:
/usr/include/c++/4.1.3/bits/ios_base.h:123: error: declaration of C
function ‘std::_Ios_Openmode std::operator|(std::_Ios_Openmode,
std::_Ios_Openmode)’ conflicts with
/usr/include/c++/4.1.3/bits/ios_base.h:83: error: previous declaration
‘std::_Ios_Fmtflags std::operator|(std::_Ios_Fmtflags,
std::_Ios_Fmtflags)’ here
/usr/include/c++/4.1.3/bits/ios_base.h: In function ‘std::_Ios_Openmode
std::operator^(std::_Ios_Openmode, std::_Ios_Openmode)’:
/usr/include/c++/4.1.3/bits/ios_base.h:127: error: declaration of C
function ‘std::_Ios_Openmode std::operator^(std::_Ios_Openmode,
std::_Ios_Openmode)’ conflicts with


Somebody at comp.lang.c++ pointed out that I should not need to enclose
the header as shown above, the library should take care of that by itself.

Do above errors ring any bell?

I am sure this is resulting from calling C library functions from my C++
source file somehow ... but how?

->HS



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux