G_object_new from a DLL

regarding creating an object via g_object_new (using sample from The GObject base class: GObject Reference Manual)

This code works fine on windows , but when I embed the g_object_new inside a DLL and invoke the DLL exported function (which will internally invoke g_object_new ), it crashes
I cant seem to find anything online related to this.
Its the first time I am using GLib on windows though.

It crashes here:

extern "C" VICONGSWRAPPER_V0_API void GObjectCreation()
	ViewerFile *file = (ViewerFile*)g_object_new(VIEWER_TYPE_FILE, NULL);  //will crash here


I have done same thing on Linux, calling g_object_new from an SO file, I call the function from so file which in turn will call g_object_new , this works fine

Meet the same kind of trouble in Vala, the solution is call type ensure function:
g_type_ensure (GType type);


thanks, but that didnt help
I created the DLL using QT project and the application also in QT. Now everything works
I do the same thing in VS2015, it doesn’t work.
I guess it is something to do with some environment setting that VS is doing different.

So if I build my dll via QT , it works
I am sure if I build it using CL tool, it will work
It must be something VS is setting up during the build

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.