1

How can I add an external C library in Visual Studio Code?

I read How can I include a needed C library using GCC? and tried:

{
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "build",
        "command": "C:\\MinGW\\bin\\gcc.exe",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "-L \\C:\\MinGW\\lib",
            "-l libws2_32.a"
        ],
        "options": {
            "cwd": "C:\\MinGW\\bin"
        },
        "problemMatcher": [
            "$gcc"
        ]
    }
]

But I got

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -l libws2_32.a
collect2.exe: error: ld returned 1 exit status

And I installed GCC in folder C:\MinGW.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Madeline
  • 83
  • 3
  • 7

0 Answers0