DPI import function not found

Hi,

There are two file: test.c and test.sv.

gcc -fPIC -shared -o aaa.so test.c svdpi.h

I compiled the test.c file useing gcc, and generated a aaa.so file.
then, I simulation test.sv with aaa.so, the result was correct.

However, when I renam the test.c to test.cpp, and recompiled it

gcc -fPIC -shared -o aaa.so test.cpp svdpi.h

Simulation again, runtime repote error: DPI import function not found…

What should I do to compile *.cpp files ?

Best regards,
lipeng yang

In reply to yanglp:

You need to add some thing like

#ifdef __cplusplus
#define DPI_LINK_DECL  extern "C" 
#else
#define DPI_LINK_DECL 
#endif

#include "svdpi.h"

DPI_LINK_DECL DPI_DLLESPEC
int 
  myfunc( int Arg );

Also see How to bind the DPI files and testbench files | Verification Academy

In reply to dave_59:

the problem has been solved according to your method, thank you very much.