This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Link problems in g++ but not in gcc!!
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: suresh at comodogroup dot com, gcc-help at gcc dot gnu dot org
- Date: Tue, 31 Aug 2004 07:08:38 -0500
- Subject: Re: Link problems in g++ but not in gcc!!
- References: <1093952856.5304.18.camel@Ironwing>
Hi L.Suresh,
It appears that the libipq.a is a C ABI library, but the header file(s) for
libipq.a are not specified as using the C ABI when compiled with C++.
For example, if you look at one of the those header files (I'm guessing
"ipq.h") does it have this near the top (AFTER any included header files in
the ipq.h):
#ifdef __cplusplus
extern "C" {
#endif
...and this near the bottom...
#ifdef __cplusplus
}
#endif
If it doesn't have those C++ guards, then to include the C++-ignorant C
header file, you should do this in your iptables.cpp file (I'm just making
them up off the top of my head):
#include "iptable.h"
extern "C" {
#include "ipq.h"
}
#include <iostream>
#include <cstddef>
#include <cassert>
Or what I've seen developers do is make a ipq.hpp file that only contains this:
extern "C" {
#include "ipq.h"
}
Then your C++ code doesn't look so polluted, and just contains this:
#include "iptable.h"
#include "ipq.hpp"
#include <iostream>
#include <cstddef>
#include <cassert>
HTH,
--Eljay