Using DPI C++ with modelsim

Status
Not open for further replies.

meir

Junior Member level 3
Joined
Jan 16, 2013
Messages
26
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,283
Visit site
Activity points
1,431
I'm trying to call a c++ function from SV code using DPI.
I'm running ModelSim under windows and am using MinGW g++ compiler.
compiling C++ code with:
Code:
 g++ -shared -Bsymbolic -o import.dll import.cpp
(from windows cmd line)
from modelsim running:
Code:
vsim -sv_lib import work.tb
result :
# Loading .\import.dll
# ** Error: (vsim-3193) Load of ".\import.dll" failed: DLL dependent library not found
.​

What am I doing wrong ?
 

windows 7 32 bit, modelsim ALTERA STARTER EDITION 10.1b

I have tried to link to .dll file also for c file with a simple void print_hello() function.
If I compile with :
Code:
vlog tb.sv import.c
and run:
Code:
 vsim work.tb
than "hello" is printed in the transcript window
BUT if import.dll is created and I run:
Code:
vsim work.tb -sv_lib import
then it seems that the simulator "finds" the function in .dll but I don't get any printout in the transcript window.

Appended
If veriuser.h included and (PLI ?) function of io_printf() used insted of printf() the string is printed in the transcript window.
Is this the correct solution ?
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…