using d dll/lib with msvc program

2012-05-13 Thread crashtua
Is it possible to build dll or lib with dmc to use it in program builded in microsoft c++ compiler?

Re: using d dll/lib with msvc program

2012-05-13 Thread Manu
On 13 May 2012 22:07, crashtua wrote: > Is it possible to build dll or lib with dmc to use it in program builded > in microsoft c++ compiler? > Using GDC you can produce libs that VC will attempt to link, it's not so simple though, the different CRT makes for plenty of incompatibilities, you hav

Re: using d dll/lib with msvc program

2012-05-13 Thread Froglegs
On Sunday, 13 May 2012 at 19:07:41 UTC, crashtua wrote: Is it possible to build dll or lib with dmc to use it in program builded in microsoft c++ compiler? Yes you can download Visual D, build a D DLL with DMD, and call it from a Visual C++ program. Unfortunately you have to use C to commun

Re: using d dll/lib with msvc program

2012-05-13 Thread crashtua
And how to load that dll? I have dll: module dllmain; import std.c.windows.windows; import core.sys.windows.dll; __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { final switch (ulReason) { case DLL_PROCESS_ATTACH:

Re: using d dll/lib with msvc program

2012-05-13 Thread Froglegs
HINSTANCE LoadME; LoadME = LoadLibrary(L"C:\\Users\\CrashTUA\\Documents\\visual studio 2010\\Projects\\DynamicLib1\\DynamicLib1\\Release\\DynamicLib1.dll"); func dllprintt; dllprintt = (func)GetProcAddress(LoadME,"trololo"); int i = dllprintt(); return

Re: using d dll/lib with msvc program

2012-05-13 Thread Rainer Schuetze
On 5/14/2012 5:44 AM, crashtua wrote: And how to load that dll? I have dll: module dllmain; import std.c.windows.windows; import core.sys.windows.dll; __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { final switch (ulReason) { c

Re: using d dll/lib with msvc program

2012-05-14 Thread Manu
On 14 May 2012 09:16, Rainer Schuetze wrote: > Than try to load it: >> HINSTANCE LoadME; >> LoadME = LoadLibrary(L"C:\\Users\\**CrashTUA\\Documents\\visual studio >> 2010\\Projects\\DynamicLib1\\**DynamicLib1\\Release\\**DynamicLib1.dll"); >> func dllprintt; >> dllprintt = (func)GetProcAddress(Lo

Re: using d dll/lib with msvc program

2012-05-14 Thread crashtua
LoadLibrary returns 10(maybe wrong number of zeros,i dont remember exactly:)). And GetProcAddress returns 0, so dllprintt fails:(

Re: using d dll/lib with msvc program

2012-05-14 Thread crashtua
So, thanks to all. It works after adding 'export' keyword and '_' symbol before function name.

Re: using d dll/lib with msvc program

2012-05-14 Thread crashtua
But it is something strange, one function need '_' and another dont:( In D dll i have: extern (C) int function() f; alias typeof(f) myfunc; export extern (C) int retten() { return 10; } export extern (C) void setf(myfunc ff) { f=ff; } export extern (C) int ret() { return

Re: using d dll/lib with msvc program

2012-05-14 Thread Martin DraĊĦar
Dne 14.5.2012 19:59, crashtua napsal(a): But it is something strange, one function need '_' and another dont:( In D dll i have: extern (C) int function() f; alias typeof(f) myfunc; export extern (C) int retten() { return 10; } export extern (C) void setf(myfunc ff) { f=ff; } export extern (C) i

Re: using d dll/lib with msvc program

2012-05-14 Thread Rainer Schuetze
On 5/14/2012 7:59 PM, crashtua wrote: But it is something strange, one function need '_' and another dont:( In D dll i have: extern (C) int function() f; alias typeof(f) myfunc; export extern (C) int retten() { return 10; } export extern (C) void setf(myfunc ff) { f=ff; } export extern (C) in