你这个问题里“C++插件”可能有几种不同含义,我先按最常见的几种情况分别说明,你看看哪一种符合你的需求:
这是最基础的情况。
sudo apt update
sudo apt install build-essential
验证:
g++ --version
很多人说的“C++插件”其实是 VS Code 的扩展。
sudo apt install code
打开 VS Code → 扩展(Ctrl+Shift+X)→ 搜索:
test.cpp
#include <iostream>
int main() {
std::cout << "Hello Ubuntu" << std::endl;
}
编译运行:
g++ test.cpp -o test
./test
比如给应用做插件。
plugin.cpp
extern "C" {
void hello() {
printf("This is a C++ plugin\n");
}
}
编译为插件:
g++ -shared -fPIC plugin.cpp -o libplugin.so
主程序用 dlopen 加载即可。
那通常需要:
libxxx-dev)可以告诉我具体是哪个软件(如 Vim、Qt、Clangd、GCC 插件等)。
我可以给你精确到命令的步骤。