This repository contains personal Visual Studio Code configuration files for C++ development by zmr233
. The configuration is designed to be used on Linux platforms only and is currently at version 2.0.
- The standout feature of this configuration is that it allows for two different compilation approaches with a single
F5
press, using bothCMake
andMake
.
- Root Directory: Each file in the root directory is treated as an independent project. This means you can have multiple
main()
functions in the root directory, and they will be compiled separately. - Subdirectories: All files in a subdirectory are considered part of the same project, implying that only one
main()
function should exist per subdirectory.
This setup follows common best practices and allows for multiple projects to co-exist without interference.
- Generated executable files will be stored in the
bin
directory with an_out
suffix.
- Use the
make cleanall
command to remove all generated binaries. This must be executed from the root directory.
-
Use
InstallMySQL.sh
to automatically install MySQL development tools.sudo apt update sudo apt install mysql-client sudo apt install libmysqlcppconn-dev sudo apt install libmysql++-dev
-
Configuration files like
config.h.in
and.vscode/c_cpp_properties.json
are pre-configured for MySQL."includePath": [ "${workspaceFolder}/**", "/usr/include/mysql++", "/usr/include/mysql", "/usr/include/cppconn" ]
-
With these settings, you can now seamlessly integrate MySQL libraries in your C++ projects.
git clone https://github.com/zmr-233/VSCode-CPP-DevSetup.git
git fetch
git rebase origin/main
# Resolve conflicts manually if any.
-
Give execution permission to
InstallMySQL.sh
:chmod 777 InstallMySQL.sh
-
Run
./InstallMySQL.sh
. -
Perform a first-time build with
F5
to generateconfig.h
. -
Modify
config.h
to enable/disable MySQL libraries.
- Remove MySQL paths from
.vscode/c_cpp_properties.json
. - No need to modify
config.h
; MySQL options are off by default.
-
To install GCC and GDB, run the following commands:
sudo apt update sudo apt install build-essential sudo apt install gdb
- Make sure to install the
C/C++
extension provided by Microsoft for IntelliSense and debugging features.
- Avoid having files with the same name in the root and subdirectories.
- Remove corresponding
_out
files when moving or renaming files. - If you encounter build issues, try deleting the
bin
andbuild
directories and rebuild the project usingF5
.
For more details, refer to the respective configuration files within this repository. Feel free to contribute and raise issues.
此仓库包含由 zmr233
个人用于 C++ 开发的 Visual Studio Code 配置文件。该配置仅设计用于仅限 Linux 平台,并目前处于2.0 版本。
- 这个配置的最大特点是它允许使用单一的
F5
键进行两种不同的编译方式,既使用了CMake
又使用了Make
。
- 根目录:根目录中的每个文件都被视为一个独立的项目。这意味着你可以在根目录中拥有多个
main()
函数,并且它们将被独立编译。 - 子目录:子目录中的所有文件都被视为同一个项目的一部分,这意味着每个子目录下只能有一个
main()
函数。
这样的设置遵循了常见的最佳实践,并允许多个项目共存而不会相互干扰。
- 生成的可执行文件将以
_out
后缀的形式存放在bin
目录下。
- 使用
make cleanall
命令来删除所有生成的二进制文件。这必须从根目录执行。
-
使用
InstallMySQL.sh
来自动安装 MySQL 开发工具。sudo apt update sudo apt install mysql-client sudo apt install libmysqlcppconn-dev sudo apt install libmysql++-dev
-
像
config.h.in
和.vscode/c_cpp_properties.json
这样的配置文件已预先配置了 MySQL。"includePath": [ "${workspaceFolder}/**", "/usr/include/mysql++", "/usr/include/mysql", "/usr/include/cppconn" ]
-
有了这些设置,你现在可以在你的 C++ 项目中无缝集成 MySQL 库。
git clone https://github.com/zmr-233/VSCode-CPP-DevSetup.git
git fetch
git rebase origin/main
# 如有任何冲突,需手动解决。
-
给
InstallMySQL.sh
设置执行权限:chmod 777 InstallMySQL.sh
-
运行
./InstallMySQL.sh
。 -
使用
F5
执行首次构建以生成config.h
。 -
修改
config.h
以启用/禁用 MySQL 库。
- 从
.vscode/c_cpp_properties.json
中删除 MySQL 路径。 - 无需修改
config.h
;MySQL 选项默认是关闭的。
-
要安装 GCC 和 GDB,请运行以下命令:
sudo apt update sudo apt install build-essential sudo apt install gdb
- 确保安装了由 Microsoft 提供的
C/C++
扩展,以获取 IntelliSense 和调试功能。
- 避免在根目录和子目录中有相同名称的文件。
- 在移动或重命名文件时,最好删除相应的
_out
文件。 - 当遇到各种构建问题时,尝试删除
bin
和build
目录,然后使用F5
重新构建项目。
更多详细信息,请参阅本仓库内的相关配置文件。欢迎贡献和提出问题。