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

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

 



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 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