Mail Archives: geda-user/2014/07/03/19:22:58
Dave,
I had a similar problem just the other day. After a lot of
head-scratching and quite a bit of Googling, I uncovered some useful
bits that solved the problem. It all had to do with the way "C" handles
symbol names as opposed to "C++" Keep in mind that C++ allows overloaded
function names. From the source level, you just write something like:
int SomeVariable=SomeFunction( int I, Float J)
Then somewhere else you write
short SomeOtherVariable=SomeFunction(long I, Double * J)
It looks to you like these are the same function, but they are actually
2 functions and the compiler needs to know which to call. So the
compiler decorates symbol names with codes that specify the types and
number of the args and return values. So, internally, there are 2
entries. Lets make up a fake decoration to illustrate the point:
I_SomeFunction_I_F
S_SomeFunction_l_pD
So, when you think you are calling "SomeFunction(), C++ is really
calling I_SomeFunction_I_F() or S_SomeFunction_l_pD(). The point is that
"C" doesn't do this. It's export list actually has a function reference
simply named SomeFunction. Thus, when the linker tries to find the
expected entry point - it's not there.
I know of a few solutions. First, and this is really hard and I would
not recommend it, rewrite the library so it will compile in c++ rather
than C. Second, write a wrapper library in C++ that calls all the
functions in C format, or third, tell the C++ compiler that you are
calling a "C" function so that it won't decorate the names.
Alas, I am not sure exactly how to do this. I know that it involves
either the use of Extern "C" and/or Cdecl, but the exact details for
your case you will have to look up.
Hope this at least shortens your search for a solution
Steve Besch
On 07/03/2014 03:19 PM, Dave Williams wrote:
> Having some problems with VPI in Icarus 0.9.6
>
> I'm trying to link a C++ app to the 'libvpi.a' library.
> The VPI functions are not linking. I can get the hello VPI sample
> to execute when using 'iverilog-vpi hello.c'.
>
> I successfully built a static library containing C function calls that link
> in my C++ app. But when I replace this library and use 'libvpi.a'
> and try to call any of the VPI C functions they are not found in linking.
> At this stage - I'm not focused on running these VPI C functions - I'm just
> trying to build them.
>
> Doing a quick read of the Icarus Makefile - I did not find a specific
> target for
> building the library - 'libvpi.a'. I wondering if anyone knows of a way
> to
> re-build the 'libvpi.a' library without a complete new make/install of
> Icarus
> Verilog?
>
> Dave W.
>
--
fictio cedit veritati
- Raw text -