I have changed my IDE's from DEV-C++ to Visual Studio code, but now, I cannot add my opengl addons when compiling the program. DEV-C++ gives you the posibilty to add addons to the compiler call, for example I used -lglu32 -lglut32 -lopengl32
for my opengl programms making the compiler call look something like this: gcc.exe "C:\Users\Main\Downloads\C\OpenGL Base\main.c" -o "C:\Users\Main\Downloads\C\OpenGL Base\main.exe" -lglu32 -lglut32 -lopengl32 -std=c99 -I"C:\MinGW\include" -L"C:\MinGW\lib" -static-libstdc++ -static-libgcc
however I do not know how to recreate this automatically in VS Code without having to rename the address for every different program I compile.

- 10,365
- 5
- 44
- 64

- 115
- 1
- 16
-
It's clear that you did not read and / or follow the official documentation that explains the 3 json files in VSCode and tells you to use msys2 to install MinGW (your compiler path should be C:\msys64\mingw64\bin) Here are the VSCode instructions: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm Jan 06 '23 at 22:13
-
1With msys2 installed you can easily use `pacman` to install most open source libraries. That would eliminate the need to set the include and linker folders manually but still require that you add arguments to your `tasks.json` to link. If that becomes too much work and your projects are more than a few source files you may want to use CMake and the CMakeTools extension with VSCode instead of manually editing your tasks.json. – drescherjm Jan 06 '23 at 23:09
-
1Good change, Dev C++ is horribly dated. Follow the links provided by @drescherjm they spell out exactly what you need. Do install Msys2 and MinGW64 (excellent software). They do provide a complete development environment separate and apart from VSCode. They also work seamlessly together. For small projects, you can simply compile from the command line in the Msys terminal (mintty - which is a good terminal) Whether you use VSCode or CMake from a terminal for your complex projects is up to you. Good to know how to use both as well as the different make facilities, `make`, `nmake` or `ninja`. – David C. Rankin Jan 07 '23 at 00:57
1 Answers
First, visual studio code is just a code editor with some extra features like an embedded command line terminal or extension that can be installed, providing extra functionality. This means that there are many ways to build a C/C++ application, e.g. by writing your own scripts that you run via the terminal, or by using build systems like Make or others via terminal or an installed extension. You probably want to take a look at the C/C++ extensions available for visual studio code. There are already other stack overflow articles already covering this topic: How do I set up Visual Studio Code to compile C++ code?
If you just want to use the same flags for building different applications, you might want to just put the command into a script which uses the current directory (if this is what you meant by address). That way the script would work for different projects/applications located in different directories.

- 26
- 4