www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Trouble with LDC2 and definition file to hide console?

reply spikespaz <spikespaz outlook.com> writes:
I am trying to add a *.def file to my program to hide the console 
window on launch, as it doesn't need to display anything to 
function. It is a Windows only application.

I saw at this post 
(https://forum.dlang.org/post/ilj5vn$ef4$1 digitalmars.com) that 
I could either use a linker flag, -L/exet:nt/su:windows, or add a 
module definition file. I decided on the definition file.

EXETYPE NT
SUBSYSTEM WINDOWS

I have this file named deflector.def, and I compile with the 
command as follows.

ldc2 source/* -of="build/SearchDeflector-x86.exe" -O3 -ffast-math 
-release


All of my source code and the *.def file is in the source/ 
directory. I am not using DUB. The issue when compiling says that 
those two definitions(?) aren't supported for my target. That 
doesn't make sense because I am using the MSVC linker with LDC2.

source\deflector.def(1) : warning LNK4017: EXETYPE statement not 
supported for the target platform; ignored
source\deflector.def(2) : warning LNK4017: SUBSYSTEM statement 
not supported for the target platform; ignored

Any help would be appreciated.

I would also like to know how to add a PNG or ICO file to my 
compiled executable. I have icons in the resolutions of 16, 32, 
64, 128, 256. Currently I'm adding them in using GitHub's RCEDIT 
tool (https://github.com/electron/rcedit) but I would like a more 
proper way.
Aug 20 2018
next sibling parent spikespaz <spikespaz outlook.com> writes:
On Monday, 20 August 2018 at 13:42:58 UTC, spikespaz wrote:
 I am trying to add a *.def file to my program to hide the 
 console window on launch, as it doesn't need to display 
 anything to function. It is a Windows only application.

 [...]
Also adding that the linker flag I have stated above also is ignored by the linker. LINK : warning LNK4044: unrecognized option '/exet:nt/su:windows'; ignored
Aug 20 2018
prev sibling next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 21/08/2018 1:42 AM, spikespaz wrote:
 I am trying to add a *.def file to my program to hide the console window 
 on launch, as it doesn't need to display anything to function. It is a 
 Windows only application.
 
 I saw at this post 
 (https://forum.dlang.org/post/ilj5vn$ef4$1 digitalmars.com) that I could 
 either use a linker flag, -L/exet:nt/su:windows, or add a module 
 definition file. I decided on the definition file.
 
 EXETYPE NT
 SUBSYSTEM WINDOWS
That is for Optlink not for MSVC link which ldc uses.
Aug 20 2018
parent reply kinke <noone nowhere.com> writes:
On Monday, 20 August 2018 at 13:49:19 UTC, rikki cattermole wrote:
 That is for Optlink not for MSVC link which ldc uses.
Exactly. For LDC, just rename your main() to WinMain().
Aug 20 2018
parent kinke <noone nowhere.com> writes:
 For LDC, just rename your main() to WinMain().
Or alternatively, `-L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTStartup` in the LDC cmdline.
Aug 20 2018
prev sibling parent reply Kagamin <spam here.lot> writes:
On Monday, 20 August 2018 at 13:42:58 UTC, spikespaz wrote:
 I would also like to know how to add a PNG or ICO file to my 
 compiled executable. I have icons in the resolutions of 16, 32, 
 64, 128, 256. Currently I'm adding them in using GitHub's 
 RCEDIT tool (https://github.com/electron/rcedit) but I would 
 like a more proper way.
Compile resource files with windres utility from mingw https://sourceware.org/binutils/docs/binutils/windres.html Example: --- deflector.rc --- 1 ICON "icon001.ico" 2 ICON "icon002.ico" 3 ICON "icon003.ico" 4 ICON "icon004.ico" 5 ICON "icon005.ico" 6 ICON "icon006.ico" 7 ICON "icon007.ico" 8 ICON "icon008.ico" 9 ICON "icon009.ico" --- windres deflector.rc deflector.o
Aug 21 2018
parent Kagamin <spam here.lot> writes:
MS has resource compiler too: 
https://docs.microsoft.com/en-us/windows/desktop/menurc/resource-compiler
Aug 21 2018