简体   繁体   中英

Using C++ libraries in VS Code (Winsock)

I'm coding on Visual Studio for a simple UDP socket application on windows, for which I need the ws2_32.lib library. Now, in Visual Studio I'm using

#pragma comment (lib, "ws2_32.lib")

to link the needed library.

What about moving on VS Code? How can I use that library then? Aside from the C++ extension, do I need a particular compiler? Since the complete IDE essentially does all by itself, I'm pretty new to the problem.

Thank you in advance

You can add properties in tasks.json in VS Code. This is the test demo DLLProject.lib

{
    "tasks": [
        {
            ...
            ...
            "args": [
                ......
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}",
                "DLLProject.lib"
            ],

.CPP

#include"DLLProject.h"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM