I'm trying to bind a C++ library that comes with a SWIG interface file. However, when I try to compile the wrapper code that is generated by

swig -c++ -perl5 pwiz_swigbindings.i

I get ~ 3k lines of warnings and errors. The first 50 lines are included here:

In file included from pwiz_swigbindings_wrap.cxx:745:0: /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:126:39: error: referen +ce to ‘CV’ is ambiguous #define XSPROTO(name) void name(pTHX_ CV* cv) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:145:44: note: in expan +sion of macro ‘XSPROTO’ # define XS_EXTERNAL(name) extern "C" XSPROTO(name) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:156:18: note: in expan +sion of macro ‘XS_EXTERNAL’ #define XS(name) XS_EXTERNAL(name) ^ pwiz_swigbindings_wrap.cxx:2149:1: note: in expansion of macro ‘XS’ XS(_wrap_new_vectord__SWIG_0) { ^ In file included from pwiz_swigbindings_wrap.cxx:744:0: /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/perl.h:2317:19: note: candida +tes are: typedef struct cv CV typedef struct cv CV; ^ In file included from pwiz_swigbindings_wrap.cxx:1862:0: ../../../data/common/cv.hpp:12996:22: note: struct pwi +z::cv::CV struct PWIZ_API_DECL CV ^ In file included from pwiz_swigbindings_wrap.cxx:745:0: /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:126:39: error: ‘CV’ ha +s not been declared #define XSPROTO(name) void name(pTHX_ CV* cv) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:145:44: note: in expan +sion of macro ‘XSPROTO’ # define XS_EXTERNAL(name) extern "C" XSPROTO(name) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:156:18: note: in expan +sion of macro ‘XS_EXTERNAL’ #define XS(name) XS_EXTERNAL(name) ^ pwiz_swigbindings_wrap.cxx:2149:1: note: in expansion of macro ‘XS’ XS(_wrap_new_vectord__SWIG_0) { ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:126:39: error: referen +ce to ‘CV’ is ambiguous #define XSPROTO(name) void name(pTHX_ CV* cv) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:145:44: note: in expan +sion of macro ‘XSPROTO’ # define XS_EXTERNAL(name) extern "C" XSPROTO(name) ^ /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/XSUB.h:156:18: note: in expan +sion of macro ‘XS_EXTERNAL’ #define XS(name) XS_EXTERNAL(name) ^ pwiz_swigbindings_wrap.cxx:2177:1: note: in expansion of macro ‘XS’ XS(_wrap_new_vectord__SWIG_1) { ^ In file included from pwiz_swigbindings_wrap.cxx:744:0: /usr/lib/x86_64-linux-gnu/perl/5.20/CORE/perl.h:2317:19: note: candida +tes are: typedef struct cv CV typedef struct cv CV;

Please bear with me - I'm not much into C/C++ or the Perl internals - but it seems like CV is a core Perl symbol as well as being defined as a class by the library I'm binding, which is causing problems. The rest of the errors/warnings seems to relate to 'CV' as well. In the external library, 'CV' is defined within the "pwiz::cv::" namespace, but it still seems to be conflicting.

Has anyone dealt with a similar issue or have any guidance on how to get around this?


In reply to SWIG and conflicting definitions by jdv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.