writing C++ dll for blitz

BlitzPlus Forums/BlitzPlus Beginners Area/writing C++ dll for blitz

CyborgPrime(Posted 2014) [#1]
Hello-

I Crated a new C++ project in Eclipse, set it for shared library, wrote a simple function, built the dll and copied it to the userlib folder.

I created a decls file but I keep getting an "illegal type conversion" not sure what the problem is.

Would somebody be kind enough to demonstrate a simple function that add 2 integers and returns the result with a c++ dll?

Thanks!


CyborgPrime(Posted 2014) [#2]
lets say I have a function called "join" that joins 2 strings:
.lib "mydll3.dll"

join(a$,b$) gets me illegal type conversion

join$(a$,b$) gets me user lib not found

?


CyborgPrime(Posted 2014) [#3]
here's the cpp source:

#include <math.h>

#include <stdlib.h>

// #define BBDECL extern "C" __declspec (dllexport)

#ifdef __cplusplus
#define BBDECL extern "C" __declspec (dllexport)
#else
#define BBDECL __declspec (dllexport)
#endif

#define BBCALL _stdcall


BBDECL int BBCALL myfunc( int a, int b ){
int c = a+b;
return c;
}


here's the decls:

.lib "mydll4.dll"
myfunc%( a%, b% ):"_myfunc@8"


Compiled both 32 and 64 bit both give the error "user lib function not found".


Kryzon(Posted 2014) [#4]
Have you tried placing that DLL in the same folder as the blitz source code or compiled executable, or at least in your System32 folder?


CyborgPrime(Posted 2014) [#5]
I put the dll and the decls in the userlibs folder in blitzplus


CyborgPrime(Posted 2014) [#6]
if I put it in the same folder as teh test.bb program that I call it from c=myfunc(1,5) i get an "illegal type conversion" error


CyborgPrime(Posted 2014) [#7]
maybe eclipse is mangling it somehow? maybe i should use vc++? has anybody had any luck with either of these?


Floyd(Posted 2014) [#8]
Try the example from the Specifications. Does that work?


CyborgPrime(Posted 2014) [#9]
nope - wont compile

the sample wont compile in either eclipse or vc++


CyborgPrime(Posted 2014) [#10]
got it working with dev-c++