haxiomic / haxe-c-bridge

Easily interact with haxe classes from C with an automatically generated C header
MIT License
51 stars 5 forks source link

dynamic linking #47

Closed Ilir-Liburn closed 2 years ago

Ilir-Liburn commented 2 years ago

Hello,

I use dynamic linking (-D dll_link) to link haxe-c-bridge dynamic library to my dynamic library.

Linking works, haxe-c-bridge extern C functions are called successfully in my dynamic library, but app is crashing at exit (detected using post-mortem debugger feature).

I tried using exit(0) at the end, hoping system gets another route for cleanup, but that doesn't solve the issue. Any idea?

Ilir-Liburn commented 2 years ago

Never mind. If I compile haxe-c-bridge dynamic library using cl, and then link such library against gcc, it is working fine. Maybe is -fPIC, or some other gcc switch needed.

haxiomic commented 2 years ago

Are you using Main_stopHaxeThreadIfRunning(false); before exiting? Otherwise, the haxe thread might be still busy. Pass true if you want to wait for haxe to execute any events it has scheduled

Ilir-Liburn commented 2 years ago

Hello,

no, I'm using haxe-c-bridge differently because I don't want threads in my app, and I don't want callbacks/locks.

Basically, first I initialize main thread (using __hxcpp_lib_main()) and then call external haxe-c-bridge functions. This is working perfectly if app is statically linked, while dynamic linking have some issue which is not important now. I can debug and I can make release if dll is built using cl.