www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error: undefined symbol: _WinMain 16 When try compile no console

reply Marcone <marcone email.com> writes:
Using -L/SUBSYSTEM:windows user32.lib

Error:

lld-link: error: undefined symbol: _WinMain 16
 referenced by 
 msvcrt120.lib(msvcrt_stub2.obj):(_WinMainCRTStartup)
Error: linker exited with status 1
May 19 2022
parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote:
 Using -L/SUBSYSTEM:windows user32.lib
you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. If using ldc instead of dmd, use -L/entry:wmainCRTStartup instead of mainCRTStartup; note the "w". see some deets i wrote here http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions
May 19 2022
parent reply Marcone <marcone email.com> writes:
On Thursday, 19 May 2022 at 19:35:20 UTC, Adam D Ruppe wrote:
 On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote:
 Using -L/SUBSYSTEM:windows user32.lib
you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. If using ldc instead of dmd, use -L/entry:wmainCRTStartup instead of mainCRTStartup; note the "w". see some deets i wrote here http://arsd-official.dpldocs.info/arsd.simpledisplay.html#installation-instructions
I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD.
May 19 2022
next sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:
 I am using a main() function.
 I am compiling on Windows x86 32 bits.
 I am using DMD 2.100.0
 This error is only in version 2.100.0 of DMD.
Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ?
May 19 2022
parent reply Marcone <marcone email.com> writes:
On Thursday, 19 May 2022 at 20:33:34 UTC, Adam D Ruppe wrote:
 On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:
 I am using a main() function.
 I am compiling on Windows x86 32 bits.
 I am using DMD 2.100.0
 This error is only in version 2.100.0 of DMD.
Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ?
-L/entry:mainCRTStartup
May 19 2022
parent reply Adam Ruppe <destructionator gmail.com> writes:
On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote:
 Are you using the `-L/entry:mainCRTStartup` or the 
 `L/entry:wmainCRTStartup` ?
-L/entry:mainCRTStartup
try the w one too. both doing the same result?
May 19 2022
parent Marcone <marcone email.com> writes:
On Thursday, 19 May 2022 at 22:13:06 UTC, Adam Ruppe wrote:
 On Thursday, 19 May 2022 at 21:41:50 UTC, Marcone wrote:
 Are you using the `-L/entry:mainCRTStartup` or the 
 `L/entry:wmainCRTStartup` ?
-L/entry:mainCRTStartup
try the w one too. both doing the same result?
Both is doing the same result.
May 19 2022
prev sibling parent reply frame <frame86 live.com> writes:
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:

 I am using a main() function.
 I am compiling on Windows x86 32 bits.
 I am using DMD 2.100.0
 This error is only in version 2.100.0 of DMD.
Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch.
May 20 2022
next sibling parent Marcone <marcone email.com> writes:
On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote:
 On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:

 I am using a main() function.
 I am compiling on Windows x86 32 bits.
 I am using DMD 2.100.0
 This error is only in version 2.100.0 of DMD.
Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch.
Now work fine! Thank you.
May 20 2022
prev sibling parent reply Marcone <marcone email.com> writes:
On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote:
 On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:

 I am using a main() function.
 I am compiling on Windows x86 32 bits.
 I am using DMD 2.100.0
 This error is only in version 2.100.0 of DMD.
Did you try 2.099 too? Because the default build mode for 32bit was changed to MS-COFF and it smells a litte bit that you have used OMF before. MS-COFF format inserts the reference to the C-runtime library automatically. Try the -m32omf switch.
I tried compiling now on x64 without console using -L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 and it doesn't work. It compiles, but the program does not run afterwards. I also tried to add -m32omf But in this case the compilation error. How to solve this?
May 26 2022
parent frame <frame86 live.com> writes:
On Thursday, 26 May 2022 at 16:56:49 UTC, Marcone wrote:
 On Friday, 20 May 2022 at 13:16:00 UTC, frame wrote:
 On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote:
 I tried compiling now on x64 without console using 
 -L/SUBSYSTEM:windows user32.lib -L/entry:mainCRTStartup -m64 
 and it doesn't work. It compiles, but the program does not run 
 afterwards. I also tried to add -m32omf But in this case the 
 compilation error. How to solve this?
There is no support for OMF for x64, 64bit build is always MS-COFF. If you specify -m64 you will generate x64 MS-COFF files. If you specify -m32mscoff you will generate x86 32bit MS-COFF files. If you specify -m32omf you will generate x86 32bit OMF files. Maybe you need to clear your object files (if any) for a clean build. If you tell the linker to entry on `mainCRTStartup`, it is expected to use that function from a C-runtime linked. As the compiler is free to select a library, this is the possible error source. Try different options for `-mscrtlib=libname` switch. What do you mean by not running? Does it return an error code? (please start it in some debugger)
May 26 2022