www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can dmd compile a favicon.ico to exe file ?

reply John Xu <728308756 qq.com> writes:

together, which can be dragged to desktop.

Can dmd compile an icon image to an exe also?
May 11 2023
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Friday, 12 May 2023 at 01:41:10 UTC, John Xu wrote:

 together, which can be dragged to desktop.

 Can dmd compile an icon image to an exe also?
you can, if i remember correctly create a ``ressource.rc`` file and paste: ``` IDI_ICON1 ICON DISCARDABLE "myicon.ico" ``` then put your ``mycon.ico`` file next to it ``` my_project\ app.d ressource.rc myicon.ico ``` ``` dmd app.d ressource.rc ``` it should create an .exe that has the icon
May 11 2023
parent reply John Xu <728308756 qq.com> writes:
On Friday, 12 May 2023 at 02:09:17 UTC, ryuukk_ wrote:
 create a ``ressource.rc`` file

 and paste:

 ```
 IDI_ICON1 ICON DISCARDABLE "myicon.ico"
 ```

 then put your ``mycon.ico`` file next to it

 ```
 my_project\
     app.d
     ressource.rc
     myicon.ico
 ```

 ```
 dmd app.d ressource.rc
Thanks for your quick reply. I'll give a try.
May 14 2023
parent reply John Xu <728308756 qq.com> writes:
Found a related link:
https://forum.dlang.org/thread/wogdypudrmrgwjysfkxg forum.dlang.org

Where Adam D Ruppe informed rcc.exe from 
http://ftp.digitalmars.com/bup.zip

But, I got problem:

     rcc -r .\resource.rc
     IDI_ICON1   ICON  DISCARDABLE  "isp.ico"
     ^
     .\resource.rc(1) : Error: 'isp.ico' doesn't contain a valid 
Windows 3.0 icon resourc

Any help? My isp.ico was converted from a png with gimp, used in 

shouldn't have any problem. Searched bing.com about "Windows 3.0 
icon", bing didn't give
much info.
May 14 2023
parent reply John Xu <728308756 qq.com> writes:
On Monday, 15 May 2023 at 02:45:17 UTC, John Xu wrote:
 Found a related link:
 https://forum.dlang.org/thread/wogdypudrmrgwjysfkxg forum.dlang.org

 Where Adam D Ruppe informed rcc.exe from 
 http://ftp.digitalmars.com/bup.zip
 ...
 Any help? My isp.ico was converted from a png with gimp, used 

 shouldn't have any problem. Searched bing.com about "Windows 
 3.0 icon", bing didn't give
 much info.
I figured out that the rcc on ftp.digitalmars.com only supports 8-bit non-compressed icon format. We'll need a newer rcc.exe which can support 24-bit/32-bit/compressed-contents icon format.
May 14 2023
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
That is only for OMF target.

You need rc that comes with Visual Studio C++ build tools.

Alternatively windres from mingw may work (I haven't tested).
May 14 2023
parent reply John Xu <728308756 qq.com> writes:
On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 That is only for OMF target.

 You need rc that comes with Visual Studio C++ build tools.

 Alternatively windres from mingw may work (I haven't tested).
How can I add this step to dub.sdl ?
May 18 2023
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 19/05/2023 2:19 AM, John Xu wrote:
 On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 That is only for OMF target.

 You need rc that comes with Visual Studio C++ build tools.

 Alternatively windres from mingw may work (I haven't tested).
How can I add this step to dub.sdl ?
You would use one of the build commands and then put the result file name into source files. However you may not want to require it in normal builds (since the file it outputs won't change you can just commit that) just to ensure your build is reproducible.
May 18 2023
parent reply John Xu <728308756 qq.com> writes:
On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 On 19/05/2023 2:19 AM, John Xu wrote:
 On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 That is only for OMF target.

 You need rc that comes with Visual Studio C++ build tools.

 Alternatively windres from mingw may work (I haven't tested).
How can I add this step to dub.sdl ?
You would use one of the build commands and then put the result file name into source files. However you may not want to require it in normal builds (since the file it outputs won't change you can just commit that) just to ensure your build is reproducible.
sourceFiles ? or libFiles ?
May 19 2023
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 19/05/2023 9:39 PM, John Xu wrote:
 On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 On 19/05/2023 2:19 AM, John Xu wrote:
 On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 That is only for OMF target.

 You need rc that comes with Visual Studio C++ build tools.

 Alternatively windres from mingw may work (I haven't tested).
How can I add this step to dub.sdl ?
You would use one of the build commands and then put the result file name into source files. However you may not want to require it in normal builds (since the file it outputs won't change you can just commit that) just to ensure your build is reproducible.
sourceFiles ? or libFiles ?
sourceFiles. libFiles is for shared libraries.
May 19 2023
parent reply John Xu <728308756 qq.com> writes:
On Friday, 19 May 2023 at 21:19:07 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 On 19/05/2023 9:39 PM, John Xu wrote:
 On Thursday, 18 May 2023 at 15:39:05 UTC, Richard (Rikki) 
 Andrew Cattermole wrote:
 On 19/05/2023 2:19 AM, John Xu wrote:
 On Monday, 15 May 2023 at 03:54:03 UTC, Richard (Rikki) 
 Andrew Cattermole wrote:
 That is only for OMF target.

 You need rc that comes with Visual Studio C++ build tools.

 Alternatively windres from mingw may work (I haven't 
 tested).
How can I add this step to dub.sdl ?
You would use one of the build commands and then put the result file name into source files. However you may not want to require it in normal builds (since the file it outputs won't change you can just commit that) just to ensure your build is reproducible.
sourceFiles ? or libFiles ?
sourceFiles. libFiles is for shared libraries.
When I put resource.rc in sourceFiles, dub said, "Error: unrecognized file extension rc"; When I put resource.res in sourceFiles, dub said,"resource.res : fatal error LNK1136: Invalid or damaged file. Error: linker exited with status 1136"
May 22 2023
parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 22/05/2023 11:18 PM, John Xu wrote:
 When I put resource.rc in sourceFiles, dub said, "Error: unrecognized 
 file extension rc"; When I put resource.res in sourceFiles, dub 
 said,"resource.res : fatal error LNK1136: Invalid or damaged file. 
 Error: linker exited with status 1136"
Yes, .res is the correct file extension, that is the output of the rc compiler. That linker error would suggest that you need to use Microsoft's tool to compile the resource.rc file. https://learn.microsoft.com/en-us/windows/win32/menurc/using-rc-the-rc-command-line-
May 22 2023