Callback from CINT dll to host executable

I’m developing windows application (VS2005) and would like to add scripting engine there based on CINT dll.

My application loads libcint.dll, it can interpret c++ files, my application can call into functions defined in script. But i can’t find a way how to implement calls from script back to my application.
My application can export functions same as how any dll does - with __declspec(dllexport)

But in script i only can import functions from dlls.

Please any help appreciated

Hi,

So you are asking “I know how to call functions insode DLLs from a script - but how can I call functions inside my EXE”?

You have to generate a dictionary for it. It doesn’t matter where the function is, the procedure is the same: you call makecint on the headers (see demo/makecint). That gives you a source file (+header) containing CINT’s description of the available functions. You link that e.g. into a DLL (or into your binary) and you should be able to call all functions from the headers.

Cheers, Axel.

I made my dll that depends on libcint.dll.
libcint.dll was built with cygwin from CINT 5.16.19.

Everything seem to be working: i call from my application to script code and receiving calls back. But only within short time (<1 minute) after start…
Some sequential call attempt fails with output like “Dictionary position rewind”. The calls i do have look:
G__exec_text( “MyFunc(25);” );

After days of debugging i loaded last version from SVN repository.

I have built libcint.dll (cint 5.16.24), made my dll using makecint.
But attempt to load it in my application with LoadLibrary gives error R6034
"An application has made an attempt to load the C runtime library incorrectly"
Then i tried to load directly libcint.dll - same error.

I repeated all for cint7: same error while trying just LoadLibrary(“libcint.dll”);
The libCint.dll.manifest file mentions correct crt dll version.
dependancy walker shows all ok.

Any help, please?


hm, i got some progress. dll loads fine if both libcint and my dll are same build - both are either release or debug

[quote]hm, i got some progress. dll loads fine if both libcint and my dll are same build - both are either release or debug[/quote]Indeed, MS is imposing that ALL libraries are either debug or release with no mixing allowed ;(

Philippe.

Right.

Unfortunately my dll using CINT7 always crashes with heap corruption somewhere in string destructor in reflex, so i assumed it might be not yet “polished” enough, and i went back to cint5 (latest as of today).
And it still “loosing” function defined in script after 20-60 sec of successful work.

Could you confirm if these steps to create my dll are correct please:
(It was hard to find how to build dll with user functions though)

I started and pointed cygwin to CINT dir:
cd /cygdrive/c/cint

then ran:
configure --arch=msvc8 --coreversion=old --debug

then:
make -j4
everything seem to be ok (with some warnings)

now, i create my dll that would rely on libcint.dll with some new functions introduced to CINT.
In my dll directory I ran (from dos prompt):
makecint -mk makefile -o cfxcintlib.obj -H cfxcintlib.h -cc -D_DEBUG

where cfxcintlib.h contains definitions of objects and functions i need to add to CINT.
Running make (from cygwin and in dll directory) created cfxcintlib.obj. It could not create .lib file (but i don’t need it) - linker did not find functions declared but defined in other files of my dll. It is ok, i used created cfxcintlib.obj to build dll in vc2005.

Some doubts regarding DllMain (created by vc wizard and modified afer):

BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
G__set_p2fsetup(G__cpp_setup);
G__init_cint(“cint”);
return TRUE;
}

And This file (where DllMain is) also has my functions bodies (that were “fed” to makecint with -H cfxcintlib.h)

  • SOLVED *
    Update for somebody else who’d use CINT library similar way.

In Windows you should not use any advanced initializations in DllMain -
It will be called many times by OS even if it belongs only to your process every time windows searches for other functions of other dlls!

Create Initialization function in your dll instead like:

__declspec(dllexport)
void Init_My_CINT_API()
{
G__set_p2fsetup(G__cpp_setup);
G__init_cint(“cint”);
}

And call it after your LoadLibrary