1

I am planning on using ImGUI for a side-project on visual studio code. I have C++ properly installed such that I can run simple programs on a terminal/command prompt. Thus, I have the correct compiler path for the C/C++ configurations.

I was following this tutorial- https://www.youtube.com/watch?v=VRwhNKoxUtk - until 0:50, where properties was being accessed by clicking on a project. I could not find properties because my C++ and other files are under one file.

I have looked into the documentation from Microsoft Visual Studio Code and several other resources on creating workspace, but that alters my files and the compilation process does not work.

Is there a way of getting the files from https://github.com/ocornut/imgui - with the necessary header and .cpp files- and being able to program in ImGUI without working under a project, but instead a file?

I have tried putting the header files in the include path, but I am not sure if this will work. In that case, why do I need the .cpp files from the github repo? I assume the compiler path does not need to change

The new imports used are as follows

#include <glad/glad.h>
#include <GLFW/glfw3.h>

I am a beginner to visual studio code and C++, so any advice or help would please me.

Leonardo
  • 272
  • 3
  • 16
  • 1
    if you add a link make sure it works: https://github.com/ocornut/imgui, why append `-` after any link – rioV8 Jun 04 '22 at 19:41
  • use a build tool like `Make` or `CMake`, VSC is not an IDE, use Visual Studio if your uncertain, make the IMGui folder a lib project in VS – rioV8 Jun 04 '22 at 19:44

1 Answers1

1

what is the title of the section at 0:50 of the video:

Importing into Visual Studio

The screen on the video does not look like Visual Studio Code.

VSC does not have a toolbar or a Solution Explorer

rioV8
  • 24,506
  • 3
  • 32
  • 49
  • My mistake for overlooking that, thank you for pointing it out! I'm still looking at the second comment. Then I would just call cmake --build ? – Leonardo Jun 06 '22 at 14:11
  • @Leonardo if not using VS you have to use a build tool to incorporate the ImGUI cpp files in the build, copy/paste the files mentioned in the video to your project folder, maybe you can build ImGUI to a lib that you use in all your projects, saves build time (ImGUI will not change a lot) – rioV8 Jun 06 '22 at 14:17
  • I have looked into several resources... When I type "cmake", one option in the terminal is cmake -S -B , which I used. Would simply be my CMake build file? and would be the ImGui folder with all the github files? I tried this and it almost worked, but generated a CMake error. Sorry if this is a bit much, but I am really trying. – Leonardo Jun 07 '22 at 16:26
  • @Leonardo the build directory is where all the generated stuff is placed, make files and object files, path-to-source is directory with Cmakelists.txt file – rioV8 Jun 07 '22 at 20:36
  • After looking at the CMake Reference Doc, I made two separate folders: imgui (containing the files I downloaded AND the Cmakelists.txt; this is the source dir) and Project (which only has my main.cpp file). After running the command cmake -S imgui -B Project, "all the generated stuff" went to Project (as intended). But my main goal is to compile and run my main.cpp file. Would I have to have a build file because main.exe is not generated after running the cmake commands? Is there anything I mentioned above that is bad to do? Sorry yet again if this is a lot. – Leonardo Jun 08 '22 at 15:57
  • read a good book/tutorial on CMake, you have to call the `cmake` command in a `projectfir/build` subdir and have a `CMakelists.txt` file in the project root – rioV8 Jun 08 '22 at 16:42
  • First, I learned cmake helloworld (as opposed to terminal), which eventually worked. I have looked at my former problem for a long time, trying to connect my main.cpp to imgui, but have failed at the last step, the cmake --build, yields 'unresolved external symbol error'. I have tried making 'imgui' a directory, file, build file, and many other attempts, but all in vain. I am but one step away from victory, as cmake works (thank you for advising me to have CMakeLists.txt there). How am I suppose to get ImGui files to operate with main.cpp (ImGui files are in 'imgui' folder)? – Leonardo Jun 10 '22 at 19:54
  • I still cannot find the solution to this. Should I use vcpkg or put add_custom_target in the CMakeLists.txt; or opt for visual studio? – Leonardo Jun 12 '22 at 19:46