Skip to content

Instantly share code, notes, and snippets.

@lalamax3d
Created January 26, 2024 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lalamax3d/509658f7f11b2cb1f9d9e279df48af53 to your computer and use it in GitHub Desktop.
Save lalamax3d/509658f7f11b2cb1f9d9e279df48af53 to your computer and use it in GitHub Desktop.
VTK and ImGui ( Setup / Build ) vs 2022 community

NOTES

Build VTK from src (cmake n Vs 2022)

i followed mostly this guide

  • install cmake (latest)
  • install visual studio 2022 community
  • download vtk (latest), extract in src (like)
    • c:\vtk\src
    • c:\vtk\build (create empty dir)
  • run cmake gui from start, give 2 above dirs
  • run configure / generate
  • run open solution (project) in visual studio
  • set to Release and ALL_BUILD. build project

NOW TO INSTALL THE BUILD

  • open cmake gui again, same settings
  • config / generate again ( make sure, vtk install path is good)
  • open solution(project)
  • make INSTALL project(solution default)
  • make sure, run as admin, so it can install
  • don't forget to add vtk\bin dir to path.

to run example download any

  • even after path, i got error
  • so i have added that path in my project configuration (debugging)
  • Deebugging >> Environment >> PATH=$(PATH);C:\Program Files (x86)\VTK\bin

ImGui in visual studio 2022 community

based on guide from here

0- copy imgui source to vendor subdir, in a new c++ windows empty project (template) 1- decide/pick between ( dx9,10,12,opengl etc) i.e i picked dx9 2- put imgui src in a subdir under 'vendor' and in project settings, add that path in vc++ directories >> likee >> $(ProjectDir)vendor\ImGui 3- connect directx 9 static lib (project linker settings ) 4- then in project, show all files, and select related .h and .cpp files, RMB and add to project. 5- write my cpp code in main file and run and it worked...

c++ , using msys2 (g++) in vscode (failed)

  • Get MSYS2 from here
  • install it, run it via msys2.exe
    • it opens it bash shell, run cmd
    • pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain
    • add this to user env
      • C:\msys64\ucrt64\bin
  • run cpp file from code (run without debug)
    • pick g++ (g++.exe) as compiler
      • pick mingw64 as platform
      • pick g++ (g++.exe) as linker
    • run it
  • notice tasks.json being added
    • edit tasks.json like
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-std=c++23",
                "-g",
                "${fileDirname}\\imgui\\*.h",
                "${fileDirname}\\imgui\\*.cpp",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-ld3d9",
                "-ldwmapi",
                "-lgdi32",
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment