error loading external function dll

Use this forum to post Vensim related questions.
Post Reply
domwoolf
Junior Member
Posts: 4
Joined: Sat Jan 01, 2011 8:04 pm

error loading external function dll

Post by domwoolf »

Hi
When I try to load an external function dll, I receive the following error message:
"External function version mismatch need version 51050 (got -1)"
I can't understand why this is happening and any help would be very gratefully received.

The external function code is written in c and based closely on the example venext.c code supplied with vensim. It compiles without errors and links with vensim.lib. I am using the GNU GCC compiler within the code::blocks IDE.

I am using vensim DSS for Windows version 5.10e under Windows XP.

the c code contains the following definition for version_info function:

int VEFCC version_info()
{
return(EXTERNAL_VERSION);
}

With ETERNAL_VERSION being defined in the header file VENSIM.H as:

#ifdef DBLPREC
#define EXTERNAL_VERSION 51051
#define COMPILED_VERSION 51051
#else
#define EXTERNAL_VERSION 51050 /* for external function */
#define COMPILED_VERSION 51050 /* for compiled models */
#endif

there's nothing here that I can see that would cause a value of -1 to be returned to vensim.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: error loading external function dll

Post by Administrator »

Are you exporting the following function?

int VEFCC version_info()
{
return(EXTERNAL_VERSION) ;
}

If it is not exported from the DLL, Vensim will be unable to call it (which is why I think you are getting -1).

You don't need to link to vensim.lib either with current versions of Vensim.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
domwoolf
Junior Member
Posts: 4
Joined: Sat Jan 01, 2011 8:04 pm

Re: error loading external function dll

Post by domwoolf »

Hi thanks for your reply.
After much tinkering I've managed to get it to work. Problem was that cobbled function names were being exported as:

_funcversion_info@0
_set_gv@4
_simulation_setup@4
_simulation_shutdown@4
_user_definition@44
_vensim_external@12
_version_info@0

I've managed to change compiler settings to get clean exports of function names without underscores or @'s. Now seems to work.

Thanks again
Post Reply