标签: g++

我是否需要安装 g++ 才能在 Ubuntu 14.04.1 中编译 c++ 文件?

我正在使用 Ubuntu 14.04.1
我想知道,

我是否需要g++从 Ubuntu 软件中心安装才能编译 C++ 文件?是GCC(GNU编译器集合)能够代替做到这一点?

如果我的第一个问题的答案是,是的...

那么,为什么 Ubuntu 14.04 没有 C++ 编译器呢?毕竟它也同样重要GCC吗?为什么 c++ 编译器不附带默认的 Ubuntu 安装?

gcc c++ g++ 14.04

1
推荐指数
1
解决办法
4356
查看次数

为什么每次尝试执行 C++ 程序时都会收到“权限被拒绝”错误?

每次尝试执行程序时,无论是什么程序,都会收到以下消息:

bash: ./filename.cpp: Permission denied
Run Code Online (Sandbox Code Playgroud)

当我编译时我没有问题,它工作正常。但是当我想执行时,我收到了这条消息。

和权限有关系吗?因为我也有很多问题。我无法访问我的共享文件夹,除非我使用

sudo nautilus
Run Code Online (Sandbox Code Playgroud)

请看我的另一个问题

permissions c++ g++ execute-command

1
推荐指数
1
解决办法
3757
查看次数

不能使用 g++ 编译器

我试图这样做:

$ g++
The program 'g++' is currently not installed. You can install it by typing:
sudo apt-get install g++
$ sudo apt-get install g++
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Run Code Online (Sandbox Code Playgroud)

c++ g++

0
推荐指数
1
解决办法
317
查看次数

为什么 g++ 找不到我的源代码?

我刚开始在 Ubuntu 上使用 C++,但我已经陷入困境。

我制作了我的第一个 .cc 程序并尝试用 g++ 编译它。

我将它命名为 variabili.cc 并将其保存在我桌面上一个名为 Esercizi 的文件夹中。

当我尝试

g++ variabili.cc
Run Code Online (Sandbox Code Playgroud)

我得到:

g++: error: variabili.cc No such file or directory
g++: fatal error: no input files compilation terminated
Run Code Online (Sandbox Code Playgroud)

我检查了该文件是否在那里ls ~/Desktop并且它在那里。名字也是对的。

无论我做什么,它似乎都不起作用。

command-line compiling directory c++ g++

0
推荐指数
1
解决办法
1704
查看次数

C++ 未定义的函数引用

我正在使用 ubuntu 16.04 当我尝试使用以下命令编译程序时

g++ -g main.cpp -o main
Run Code Online (Sandbox Code Playgroud)

这是我的 g++ 版本

g++ --version
Run Code Online (Sandbox Code Playgroud)
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 for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)

我收到这个编译错误

main.cpp:8: undefined reference to `Helper::IsStringNumeric(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

主要.cpp:

#include "Helper.h"
#include <iostream>
#include <vector>


int main()
{
    std::cout << Helper::IsStringNumeric("200");
} …
Run Code Online (Sandbox Code Playgroud)

compiling c++ g++

0
推荐指数
1
解决办法
1万
查看次数

为什么在编译后尝试运行 C++ 程序时会出现语法错误?

我正在尝试学习 C++,但我什至无法使 cplusplus.org 中的第一个(hello world)示例与g++命令或c++. 我像示例一样创建了一个文件并运行g++ myfile,然后./myfile.

我遇到权限问题,然后我使用chmod +x myfile,权限问题消失了,但发生了这个问题:

gzuspower@gzuspower:~/Desktop$ ./4
./4: line 1: //myfirst: No such file or directory
./4: line 4: syntax error near unexpected token `('
./4: line 4: `int main ()'
Run Code Online (Sandbox Code Playgroud)

我打电话给我的文件,4因为这是我的第四次尝试。这是在Xubuntu 16.04上。重复的问题答案不起作用我试过.c,.cpp,作为文件扩展名并尝试了firstc++(我的第一次尝试文件)而不是4(我的第四次尝试文件),但没有任何效果。我将尝试不同形式的 hello-world 代码。

command-line c++ g++

-1
推荐指数
1
解决办法
8200
查看次数

你怎么称呼g++?

我想用g++. 但是,当我在g++终端中输入时,它说“没有输入文件的致命错误”。我之前也问过类似的问题,但为了避免在评论中扩展讨论,我仅针对g++. 我还想知道编译的文件类型。即文件的性质。

command-line g++

-4
推荐指数
1
解决办法
3265
查看次数