Visual Studio as IDE

Hi,

it seems that a few developers here uses Visual Studio on Windows. So, I was wondering if you have any tips on getting Visual Studio setup and compile correctly?

Thanks.

I use Visual Studio Community 2017 but use msys2 to compile. It is was a major headache trying to set up msys2 in Visual Studio. I also use the Visual Assist extension in VS. Haven’t tried to figure out how to compile with in community, was not worth the hassle first time I tried to set it up, compiling with msys2 works grand, just alt tab out of visual studio.

Not too experienced with Visual Studio to know every in and out but there is a thread that discusses getting it to work in VS

You may find some more info with a search also: https://community.vcvrack.com/search?q=Visual%20Studio%20communi%20category%3A8

1 Like

Same for me, I build in msys2. However most of my code is also in a unit test suite that is built and debugged in VS. but there is no rack code or rack/deps code in there.

1 Like

I thought you use VS Code?

I use both. Code more and more for editing code. VS for debugging and light coding while debugging. After 30 or more years in VS it’s sort of natural, but code is quickly edging it out. Finding files and searching in files is just so much easier and faster in code

3 Likes

Thank you guys. I will give this a shot!

I just miss some of Visual studio’s nice features.

Yup, is a great IDE!

well - good IDE? my main complaints - it takes too long to start up, it’s slow in general, finding a particular file is way too hard, searching isn’t great the code intelligence isn’t great. Other than the integrated debugger, I’d say VS Code has it completely beat. But back in the real world, yes, VS is a good IDE, and better than some, for sure.

Takes about 6 seconds for me and that is loading a solution that has a lot of files, is on an SSD so fairly sharp on the loading time! Finding a file in the entire solution is lightening quick also.

And as I said Visual Assist makes things a lot easier auto complete words already typed etc…

I use visual assist at work, and it does make finding a file possible. Maybe you don’t remember that without it there is no “fuzzy filename match” so you need to type the entire file name correctly in the explorer to open one? I used to have my VCV stuff on an old HD. Seemed to take a long time to load. project at work is huge, seems to take way too long. Esp since xcode and vs code are perhaps an order of magnitude faster. VS Code in particular loads instantly and everything is lightning fast.

Could type x in the solution explorer and it will instantly show results for me along with class names functions etc. There can be some issues with Visual Assist though I recall this breaking searches when I used it first.

Yeah, I don’t find that feature of the solution explore works for me to open a file. both xcode and vs code let you type in any fragment of a filename, or just the caps from camel case names and it will open them (and, or course, visual assist will do that). It’s not just me, there are hundreds of devs in my office and they all got visual assist just for the ability to open a file. Then of course they all switched to a different editor :wink:

Maybe this could be useful? But I never tried this.

Hi,

as I put the info about Using MinGW and Cygwin with Visual C++ here I was curious myself about how this works, so I tried this. It works pretty much great if you setup things correct and I will share the setup here.

Visual Studio will then compile with the MinGW compiler and you have the full blown IntelliSense support as well.

To get this to work you need:

Create CMakeLists.txt for your plugin and put it in your plugin source directory

This is a generic CMakeLists.txt to compile a Rack plugin under Windows:

cmake_minimum_required(VERSION 3.5)

if ("${RACK_SDK}" STREQUAL "")
  message(FATAL_ERROR "Path to Rack SDK missing! Add -DRACK_SDK=<path to Rack SDK> to the cmake call.")
endif ()

message(STATUS "Use Rack SDK: ${RACK_SDK}")

# set this to the plugin slug!
set(PLUGIN_NAME myFancyPluginName)

project(VCVRack${PLUGIN_NAME}Plugin)

set(CMAKE_CXX_STANDARD 14)

# Do not change the LIB_NAME!
set(LIB_NAME plugin)

include_directories("${RACK_SDK}/include" "${RACK_SDK}/dep/include")
link_directories(${RACK_SDK})

file(GLOB_RECURSE SOURCES *.cpp)
file(GLOB_RECURSE SRC_SOURCES src/*.cpp)

add_library(${LIB_NAME} MODULE ${SOURCES} ${SRC_SOURCES})

add_definitions(-DARCH_WIN)
target_include_directories(${LIB_NAME} PRIVATE include)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
target_link_libraries(${LIB_NAME} "Rack")

set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")

file(GLOB LICENSE LICENSE*)
file(INSTALL plugin.json res ${LICENSE} DESTINATION dist/${PLUGIN_NAME})
install(DIRECTORY ${PROJECT_BINARY_DIR}/lib/ DESTINATION ${PROJECT_BINARY_DIR}/dist/${PLUGIN_NAME} OPTIONAL)
install(DIRECTORY ${PROJECT_BINARY_DIR}/dist/${PLUGIN_NAME}/ DESTINATION ${PLUGIN_NAME})

Adapt the PLUGIN_NAME variable, so it matches your plugin name.

Double check if all your source files will be collected by the file(GLOB_RECURSE ... statements, if not adapt it to your needs.

Create CMakeSettings.json for your Environment and put it in your plugin source directory

{
  "configurations": [
    {
      "name": "Mingw64-Release",
      "generator": "Ninja",
      "configurationType": "Release",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v",
      "ctestCommandArgs": "",
      "inheritEnvironments": [ "mingw_64" ],
      "environments": [
        {
          "MINGW64_ROOT": "C:\\msys64\\mingw64",
          "BIN_ROOT": "${env.MINGW64_ROOT}\\bin",
          "FLAVOR": "x86_64-w64-mingw32",
          "TOOLSET_VERSION": "8.1.0",
          "PATH": "${env.MINGW64_ROOT}\\bin;${env.MINGW64_ROOT}\\..\\usr\\local\\bin;${env.MINGW64_ROOT}\\..\\usr\\bin;${env.MINGW64_ROOT}\\..\\bin;${env.PATH}",
          "INCLUDE": "${env.INCLUDE};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}",
          "environment": "mingw_64"
        }
      ],
      "variables": [
        {
          "name": "CMAKE_C_COMPILER",
          "value": "${env.BIN_ROOT}\\gcc.exe",
          "type": "STRING"
        },
        {
          "name": "CMAKE_CXX_COMPILER",
          "value": "${env.BIN_ROOT}\\g++.exe",
          "type": "STRING"
        },
        {
          "name": "RACK_SDK",
          "value": "ADD HERE THE PATH TO YOUR UNPACKED RACK SDK FOLDER!",
          "type": "STRING"
        }
      ],
      "intelliSenseMode": "linux-gcc-x64"
    }
  ]
}

Adapt in the environments section the variables so it matches with your MSYS2 installation:

  • MINGW64_ROOT
  • FLAVOR
  • TOOLSET_VERSION

Adapt in the variables section the value for RACK_SDK so it points to the directory containing the libRack.a and include.

Now start Visual Studio IDE and open project by Open Folder and navigate to your plugin sources (https://docs.microsoft.com/en-us/visualstudio/ide/develop-code-in-visual-studio-without-projects-or-solutions?view=vs-2019).

Thats it.

If you need another build configuration, e.g. for Debug, just copy the part under configuration and append it after the existing configuration and change the adapt the configurationType to Debug.

I hope this helps someone, let me know.

1 Like