dlopen error with newly introduced (but still unused) c++ class
Geert Janssens
geert.gnucash at kobaltwit.be
Sun Jan 31 02:09:15 EST 2016
On Saturday 30 January 2016 08:33:56 John Ralls wrote:
> > On Jan 30, 2016, at 6:04 AM, Geert Janssens
> > <geert.gnucash at kobaltwit.be> wrote:
> > When running gnucash in this setup, I get this warning:
> >
> > WARN <gnc.module> Failed to dlopen()
> > '/home/janssege/Lokaal/installs/gnucash/master/lib/gnucash/libgncmo
> >
> I'm a bit puzzled about how exactly the C++ bits are integrated with
> the rest of the importer, but I think your problem is that you're
> including C-linkage headers into C++ without declaring them as such.
> For example in gnc-csv-imp-trans.hpp, you have
>
> #include "config.h"
> #include "Account.h"
> #include "Transaction.h"
> #include <vector>
> #include <memory>
>
> it needs to be
>
> extern "C"
> {
> #include "config.h"
> #include "Account.h"
> #include "Transaction.h"
> }
> #include <vector>
> #include <memory>
>
> to tell the compiler to use unmangled names for the symbols from those
> headers. That lack of mangling is called C linkage. You need to do
> that in both headers and implementations. If a header will be
> included in a C file, wrap the 'extern "C" {' and closing } with
> #ifdef __cplusplus … #endif so that the C compiler doesn't see it.
>
> Any C++ functions called from C need to also have C linkage, and
> obviously must be free functions, not class members. Only the
> declarations need be wrapped in extern "C" {…}. The definitions
> shouldn't be and can be as C++-y as you want. You can look at
> qof/gnc-numeric to see an example.
>
> Regards,
> John Ralls
Thanks for the detailed explanation John.
I can imagine you are puzzled about the integration of the c++ parts with the rest of the
importer - they aren't yet... I just wanted to run gnucash to experiment with how the old
importer works when I ran into the dlopen issue.
The dlopen issue was effectively resolved on IRC by codesmythe. He pointed out I had a virtual
member function GncTokenizer::tokenize that didn't have an implementation. Adding a minimal
implementation made the error go away, even without the extern "C" wrappers (though to be
complete codesmythe did suggest to do that as well).
I'll add the extern "C" wrappers next.
Geert
More information about the gnucash-devel
mailing list