This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Link problems in g++ but not in gcc!!


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]