0

i have already installed compiler MINGW for c++/c files.. I've set up the json files like the MS website suggests, here is my json file

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "windows-gcc-x86"
        }
    ],
    "version": 4

} and still got the following error :-

cd "d:\codes\C-LANGUAGE\" ; if ($?) { gcc q3.c -o q3 } ; if ($?) { .\q3 }
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'

after installing mingW compiler i get above error

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
  • It looks like you are trying to run stuff but it can't find WinMain.. have you written one? What type of thing are you trying to build? – doctorlove May 21 '21 at 10:00
  • PS D:\codes> cd "d:\codes\C-LANGUAGE\" ; if ($?) { gcc q1.c -o q1 } ; if ($?) { .\q1 } c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16' collect2.exe: error: ld returned 1 exit status actually I'm a beginner so i don't know about WinMain but i have already done every step from the youtube – yashituli11 May 21 '21 at 10:03
  • Have you got a `WinMain` function or a `main` function? – doctorlove May 21 '21 at 10:04
  • yes i have used int main in the code – yashituli11 May 21 '21 at 10:08
  • edit your post and add your code there, cuz it looks like you have no ```main``` function – Deumaudit May 21 '21 at 10:11
  • You are probably not linking to win32 libs. Try adding `-mwindows` in your tasks.json, under *args*. This uses a few common win32 libs but it also suppresses the console, so you may alternative want to just list your needed libs one after another manually, again under *args*. For example, if your code uses the `InitCommonControlsEx()` func, you should link to *Comctl32.lib* by adding: `-lComctl32` in your build command (meaning, under *args* in your tasks.json file) – Harry K. May 21 '21 at 10:30

0 Answers0