Visual D 0.3.43 beta1 available
Rainer Schuetze via Digitalmars-d-ide
digitalmars-d-ide at puremagic.com
Fri Nov 6 05:08:54 PST 2015
On 06.11.2015 08:45, johann wrote:
> On Thursday, 5 November 2015 at 20:27:32 UTC, Rainer Schuetze wrote:
>> I guess you have changed the subsystem to "Windows". main doesn't seem
>> to work then (only for "Console"), you'll have to implement WinMain as
>> in the WindowsApplication template.
>
> thanks for the help pointers.
> i generated the dfl2 lib anew with the current compiler - works fine for
> x64. the lib was seemingly maintained by a gentleman named franklike.
> as for main, i used the following code:
>
> import dfl.all;
> int main()
> {
> Form myForm;
> Label myLabel;
> myForm = new Form;
> myForm.text = "DFL Example";
> myLabel = new Label;
> myLabel.font = new Font("Verdana", 14f);
> myLabel.text = "Hello, DFL World!";
> myLabel.location = Point(15, 15);
> myLabel.autoSize = true;
> myLabel.parent = myForm;
> Application.run(myForm);
> return 0;
> }
>
> i set the subsystem to console (or 'Not Set') and try to link with the
> dfl2 lib. that works for console and it runs as expected - just with
> console window in the background.
>
> if i set it to windows subsystem the link fails with:
> LIBCMT.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol
> WinMain referenced in function "int __cdecl
> __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
> Release\dflTEST.exe : fatal error LNK1120: 1 unresolved externals
> Building Release\dflTEST.exe failed!
>
> do you have any suggestion what happens? how can i get rid of the
> console window after linking?
>
The VC runtime libraries expect a WinMain entry point if you compile for
subsystem windows, so you should replace main() with WinMain:
import core.runtime;
import core.sys.windows.windows;
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
Runtime.initialize();
Form myForm;
...
Runtime.terminate();
return 0;
}
AFAICT this was different in earlier versions of the VC runtime. I'm not
sure if the D runtime can/should try to redirect this to main().
More information about the Digitalmars-d-ide
mailing list