0

I've Googled and searched here for answers about how to compile an app with an icon (I've never done it before), but nothing I've tried is working. I'm using VSCode on Windows 10, so when I compile, it consults the tasks.json and uses GCC (which I got from mingw-64w).

I tried following the advice in this thread, but it's 12 years old and didn't work.

In my project's folder, say I have myicon.ico. I put this in an .rc file:

#include <windows.h> 
myicon ICON "myicon.ico"

Then in the terminal, I use windres D:\\Programming\\My_App\\src\\myicon.rc -o myicon.res
That generates "myicon.res". Is there a way to include that step in my tasks.json in case someone in the future needs to compile a version with a new icon? I tried adding the path in front of "myicon.ico" in the .rc file instead, like in the example at the link, but GCC wouldn't find it if I did it that way.

I don't know what to do with the res file. I tried putting "myicon.res" within "args": in the tasks.json file, but whether or not I include the directory, the ld.exe says that there's "no such file or directory". I tried searching a list of GCC arguments, but didn't find anything that looked related to resources. The tasks.json would look like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-IC:/MyLibs/lua-5.1/include",
                "-IC:/MyLibs/iup/include",
                "-LC:/MyLibs/lua-5.1",
                "-LC:/MyLibs/iup",
                "-LC:/MyLibs/iup/Lua51",
                "-llua5.1",
                "-liup",
                "-liuplua51",
                "myicon.res"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\\msys64\\mingw64\\bin\\gcc.exe"
        }
    ]
}

How do I fix my tasks.json (or the c_cpp_properties.json that I generated it from)?

Tailcoat
  • 13
  • 5

0 Answers0