如果我尝试通过以下命令编译我的 C++ 源文件:
g++ a.cpp
Run Code Online (Sandbox Code Playgroud)
它输出:
The program 'g++' can be found in the following packages:
* g++
* pentium builder
try:
sudo apt-get intsall <<a>selected package>
Run Code Online (Sandbox Code Playgroud)
但是,如果我运行建议的命令 ( sudo apt-get install g++),它会显示一切都已安装。
那么,基本上,我如何在 Ubuntu 12.04 中编译一个简单的 C++ 程序?
After downloading the Ubuntu app from the Windows store, I tried to run
gcc --version and it showed command gcc not found same was the case for g++.
I tried to install using sudo apt install gcc and it kept showing me errors like
Err:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils-common amd64 2.30-21ubuntu1~18.04.1 404 Not Found
and at the end it gave me this
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
What I already …
我有一个示例命令,如下所示:
g++ main.cpp -o main -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -I/usr/local/include/opencv4
Run Code Online (Sandbox Code Playgroud)
运行上述整个命令将main根据参数main后的第二个参数创建文件-o。我已在文件.zshrc中将其重置如下:
alias ocv='f(){ g++ "$@" -o built_$@ -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -I/usr/local/include/opencv4; unset -f f; }; f'
Run Code Online (Sandbox Code Playgroud)
现在运行上面的命令如下:
ocv main.cpp
Run Code Online (Sandbox Code Playgroud)
它将创建一个名为built_main.cpp. 但我希望它main通过删除扩展名来生成文件.cpp。怎么做?
所以我试图设置我的计算机进行开发。我安装了 ubuntu 14.04 LTS。我想编写一个 hello-world 程序。但是我无法编译它。经过一番搜索,我尝试了sudo apt-get install build-essential,它抱怨:
>sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies: …Run Code Online (Sandbox Code Playgroud) 我能够安装 gcc 10,但我需要 10.2 而不是 10,它一直告诉我 gcc10.2 不存在,它确实存在,我尝试通过在命令行中编译和构建它来安装它,但是似乎没有安装它或者让我的系统以任何方式识别它的存在。
sudo apt-get install gcc-10 g++-10 作品。
sudo apt-get install gcc-10.2 g++-10.2 才不是
I am trying to build a library (libaiml). I was having problems installing the library using normal methods:
./configure ; make ; make install
Run Code Online (Sandbox Code Playgroud)
In the README, the author says you should use this method to install the libarary, but the standard download does not come with a configure file.
To get around this, I decided to import the source into eclipse and try building the library myself. Now I am having a problem resolving the libxml2 dependency. …
我尝试在我的 Ubuntu 12.04 中安装 gpp,但我无法安装它。
据报道,
sudo apt-get install gpp
[sudo] password for akash:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gpp
Run Code Online (Sandbox Code Playgroud)
我尝试通过以下方式找到文件 gpp
find / -type f -name gpp
Run Code Online (Sandbox Code Playgroud)
但它说在所有过程中都拒绝许可。
在vi 1.cpp
我编写我的 C++ 程序之后。
g++ 1.cpp -o 1.out
Run Code Online (Sandbox Code Playgroud)
工作正常。但
./ 1.out
Run Code Online (Sandbox Code Playgroud)
给出错误:bash:./:是一个目录
如何在 Ubuntu 20.04 中更新或安装 g++ 15?
我使用了这里的信息How to install g++ 10 on Ubuntu 18.04? 在 Ubuntu 20 上安装 gcc/g++ 10 ,当我尝试再次执行此操作时:
sudo apt install g++-10
Reading package lists... Done
Building dependency tree
Reading state information... Done
g++-10 is already the newest version (10.2.0-5ubuntu1~20.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Run Code Online (Sandbox Code Playgroud)
但是当我询问版本时:
g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even …Run Code Online (Sandbox Code Playgroud)