Windows.h

时间:2019-07-09 11:51:07

标签: c++ g++ vscode-settings midi lib

我正在尝试使用Windows.h中的midi函数,但g ++编译器无法引用它们。我正在使用Microsoft提供的c ++扩展和扩展代码运行器来处理Visual Studio代码。

以前,我在Visual Studio 2019上使用自己的编译器遇到了相同的问题。

// main.cpp
#include <iostream>
#include <Windows.h>

int main()
    {    
    // Get the number of midi input devices 
    // Everyone "should" be able to execute this line without problems
    UINT inDevCount = midiInGetNumDevs();

    // Print the result
    std::cout << "Found " << inDevCount << " devices in input.";

    // Exit
    std::cin.get();
    return 0;
}

// c_cpp_properties.json
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

// tasks.json
{
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build active file",
            "command": "C:\\MinGW\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\bin"
            }
        }
    ],
    "version": "2.0.0"
}

// launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++.exe build active file"
        }
    ]
}
  

执行任务:C:\ MinGW \ bin \ g ++。exe -g c:\ Users \ lucid \ Desktop \ RemoteMIDIReceiver \ main.cpp -o c:\ Users \ lucid \ Desktop \ RemoteMIDIReceiver \ main.exe   C:\ Users \ lucid \ AppData \ Local \ Temp \ ccytfDOD.o:在函数main': c:/Users/lucid/Desktop/mymidiproject/main.cpp:7: undefined reference to midiInGetNumDevs @ 0'
中   collect2.exe:错误:ld返回1退出状态   终端进程终止于退出代码:1 << / p>

0 个答案:

没有答案