[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Multiple C files required by single C++ block.How
From: |
'Eric Blossom' |
Subject: |
Re: [Discuss-gnuradio] Multiple C files required by single C++ block.How to build? |
Date: |
Wed, 29 Nov 2006 16:25:11 -0800 |
User-agent: |
Mutt/1.5.9i |
> From: Jonas Hodel [mailto:address@hidden
> Sent: Wednesday, November 29, 2006 1:05 PM
> To: Eric Blossom
> Cc: address@hidden
> Subject: Re: [Discuss-gnuradio] Multiple C files required by single C++
> block.How to build?
>
>
> Hello,
>
> Thanks to both Eric and Daniel for your prompt help.
>
> Yes this does make sense and it was the first thing I tried. After it didn't
> work with my files I went right back to basics (I am building a la
> gr-howto-write-a-block). I created very simple .h/.c files as a test.
>
> Then:
> Within "howto_square2_ff.h" I added #include "test.h".
> Within "howto_square2_ff.cc" I added a call to jonas_test(), located in the
> constructor howto_square2_ff ().
> I added test.c to the "_howto_la_SOURCES" entry in "src/lib/Makefile.am".
>
> Finally: "make clean", "make" and "make check".
>
> This results in:
>
> ImportError:
> /home/jonas/gnuradio/gr-howto-write-a-block-3.0.2/src/lib/.libs/_howto.so:
> undefined symbol: _Z10jonas_testv
This is because you included a C .h file into a C++ source file.
The compiler assumed (since you didn't tell it otherwise) that
jonas_test was a C++ function. Thus the name mangling.
The fix is to surround the inclusion of the C include file with:
extern "C" {
#include "jonas_test.h"
}
FWIW, this is standard C++, and has nothing to do with GNU Radio, SWIG
or Python.
Eric