visual studio code has been used for some time, and I am deeply impressed by its compactness and beauty.
Recently, I did two computer graphics experiments, one of which must reference an external graphics library, but I kept reporting errors when using vscode to complete such a “simple” work 😢😢。 It even made me give up using it for a time. (of course, the heavyweight vs2017 soon persuaded me back! 😂)
Today, I finally decided to find out and solve this problem. 🤜🤜
Here are some gains (including principles and solutions)
The difference between G + + and GCC
Conclusion: writing C + + and choosing G + + is better!
Tasks.json and c_cpp_properties.json
includepath in the
c_cpp_properties.json file will become the key to the internal IntelliSense of the editor, but it has nothing to do with the compilation process. (tip:
Ctrl + Shift + P Enter
Edit configurations (UI) to automatically configure the relevant parameters of the generated
c_cpp_properties.json file by selecting options in the graphical interface)
The parameters contained in
tasks. JSON file will be used as command line parameters at compile time (i.e. Ctrl + F5).
- I dependency path you can specify the dependency path of the external library to achieve the effect of importing external packages.
Conclusion: to import an external library, you need to configure
includepath in the
c_cpp_properties.json file and
args in the
tasks. JSON file at the same time, so that no error is reported in both the development process and the compilation process.
Compiling and running process of C + + program
Compile the CPP source file through
G + + file name 1.cpp - O file name 2. Exe , and specify the compiled exe program name through the
- O parameter.
Directly enter the EXE file name (including suffix) to run the EXE executable.
Solution – discard plug-ins or as internal Libraries
It is possible that you have installed the
C/C + + compile run plug-in, which can quickly compile and run programs by typing
F6 on windows. In fact, it helps you realize the two steps of the above compilation process. However, the flexibility of command-line parameters is naturally abandoned…
So abandon the plug-in decisively. ￣ □ ￣ ｜ after abandoning the plug-in and configuring the parameters of the two files, directly type
Ctrl + F5 to complete the compilation and operation correctly.
When compiling the default library, you do not need to take the
- I parameter. In other words, the location of the internal library does not need to be specified. At this time, you can manually migrate the location of the external library to the location of the default library to reference the external library. At this time, you can completely do not configure the parameters of the two files.
- AndroidStudio Error: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:proces
- Go to: install C extended compiler environment of Python under windows (solve the problem of “unable to find vcfarsall. Bat”
- Sublime run code – open in browser shortcut key settings
- [How to Solve] React Native SDK location not found
- [How to Solve] gcc-4.7.2 cannot compute suffix of object fil…
- [Solved] Microsoft Visual C++ Runtime library not enough space for thread data
- VSCode Use Code Runner plugin can not compile and run the file filename with spaces [How to Solve]
- Eclipse C/C++ Error: launch failed,binary not found
- [Problems with the use of internal classes] No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclo