Coder Social home page Coder Social logo

Comments (5)

MonicaLiu0311 avatar MonicaLiu0311 commented on June 6, 2024

I haven't reproduced your problem, could you please provide a reproduction code?

from vcpkg.

medcelerate avatar medcelerate commented on June 6, 2024

Yes See Below. This is not the full program code but only what pertains to RtMidi. I'm using vcpkg.json and via cli and they both produce the linking error.


#include <gl/glew.h>
#include <GLFW/glfw3.h>

#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL

#define NOMINMAX

#include <GLFW/glfw3native.h>
#include <spdlog/spdlog.h>
#include <zmq.hpp>
#include <rtmidi/RtMidi.h>

 std::unique_ptr<RtMidiIn> midiin;

    //Setup RtMidi
    try {
        midiin.reset(new RtMidiIn());
    }
    catch (RtMidiError& error) {
        // Handle the exception here
        log("error", error.what());

    }

    // Check available ports.
    unsigned int nPorts = midiin->getPortCount();
    if (nPorts == 0) {
		log("error", "No MIDI ports found, operating in freerun");
        midiin.reset();
    }
    else {


        // Open first available port.
        midiin->openPort(0);

        // Don't ignore sysex, timing, or
        // active sensing messages.
        midiin->ignoreTypes(true, false, true);

    }


from vcpkg.

MonicaLiu0311 avatar MonicaLiu0311 commented on June 6, 2024

I haven't reproduced your issue as follows:

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "C:\Windows\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 17 2022" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\monica\source\repos\CMakeUsage\out\install\x64-Debug" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows-static"  -DCMAKE_TOOLCHAIN_FILE=G:/vcpkg/scripts/buildsystems/vcpkg.cmake "C:\Users\monica\source\repos\CMakeUsage" 2>&1"
1> Working directory: C:\Users\monica\source\repos\CMakeUsage\out\build\x64-Debug
1> [CMake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
1> [CMake] -- The C compiler identification is MSVC 19.38.33135.0
1> [CMake] -- The CXX compiler identification is MSVC 19.38.33135.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
1> [CMake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
1> [CMake] -- Looking for pthread_create in pthreads
1> [CMake] -- Looking for pthread_create in pthreads - not found
1> [CMake] -- Looking for pthread_create in pthread
1> [CMake] -- Looking for pthread_create in pthread - not found
1> [CMake] -- Found Threads: TRUE  
1> [CMake] -- Configuring done (11.7s)
1> [CMake] -- Generating done (0.1s)
1> [CMake] -- Build files have been written to: C:/Users/monica/source/repos/CMakeUsage/out/build/x64-Debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.
>------ Build All started: Project: CMakeUsage, Configuration: x64-Debug ------
  MSBuild version 17.8.5+b5265ef37 for .NET Framework
  
    1>Checking Build System
    Building Custom Rule C:/Users/monica/source/repos/CMakeUsage/CMakeUsage/CMakeLists.txt
    CMakeUsage.cpp
    main.vcxproj -> C:\Users\monica\source\repos\CMakeUsage\out\build\x64-Debug\CMakeUsage\Debug\main.lib
    Building Custom Rule C:/Users/monica/source/repos/CMakeUsage/CMakeLists.txt

Build All succeeded.
test.cpp
#include <gl/glew.h>
#include <GLFW/glfw3.h>

#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL

#define NOMINMAX

#include <GLFW/glfw3native.h>
#include <spdlog/spdlog.h>
#include <zmq.hpp>
#include <rtmidi/RtMidi.h>

void log(const std::string& level, const std::string& message) {
// Implement logging logic
// For example, use spdlog for logging
spdlog::info("{}: {}", level, message);
}

int main() {
std::unique_ptr midiin;

// Setup RtMidi
try {
    midiin.reset(new RtMidiIn());
}
catch (RtMidiError& error) {
    // Handle the exception here
    log("error", error.what());
}

// Check available ports.
unsigned int nPorts = midiin->getPortCount();
if (nPorts == 0) {
    log("error", "No MIDI ports found, operating in freerun");
    midiin.reset();
}
else {
    // Open first available port.
    midiin->openPort(0);

    // Don't ignore sysex, timing, or
    // active sensing messages.
    midiin->ignoreTypes(true, false, true);
}

return 0;

}

CMakeLists.txt
cmake_minimum_required (VERSION 3.8)

set(CMAKE_CXX_FLAGS " /std:c++17 /Zc:__cplusplus /EHsc ")

add_library (main "test.cpp")

find_package(rtmidi CONFIG REQUIRED)
target_link_libraries(main PRIVATE RtMidi::rtmidi)

find_package(GLEW REQUIRED)
target_link_libraries(main PRIVATE GLEW::GLEW)

find_package(cppzmq CONFIG REQUIRED)
target_link_libraries(main PRIVATE cppzmq cppzmq-static)

find_package(spdlog CONFIG REQUIRED)
target_link_libraries(main PRIVATE spdlog::spdlog)

find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(main PRIVATE glfw)

CMakeSettings.json
{
  "configurations": [
    {
      "name": "x64-Debug",
      "generator": "Visual Studio 17 2022 Win64",
      "configurationType": "Debug",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "-DCMAKE_TOOLCHAIN_FILE=G:/vcpkg/scripts/buildsystems/vcpkg.cmake",
      "buildCommandArgs": "",
      "ctestCommandArgs": "",
      "variables": [
        {
          "name": "VCPKG_TARGET_TRIPLET",
          "value": "x64-windows-static"
        }
      ]
    }
  ]
}

from vcpkg.

medcelerate avatar medcelerate commented on June 6, 2024

Strange, it still exhibits the odd linking behavior for me. Let me try another project.

from vcpkg.

JackBoosY avatar JackBoosY commented on June 6, 2024

Ref https://learn.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-midioutgetnumdevs

Winmm.lib should be linked in the cmake export files, @MonicaLiu0311 please check this.

from vcpkg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.