在 Ubuntu 上使用 g++ 编译器运行程序
Running program with g++ compiler on Ubuntu
我需要帮助在 Ubuntu 上运行我的程序。我有两个 cpp 文件和一个头文件。我收到以下错误。有人可以帮我吗?
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -c Sequence.cpp
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -c SequenceTest.cpp
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -o Sequence.o SequenceTest.o test
g++: error: test: No such file or directory
o文件是在我打开helo文件夹时创建的
g++ man
-o <file> Place the output into <file>
均值测试必须紧跟在 -o 标志之后,否则链接器认为测试是输入
gopy@gopy-VPCEB36GM:~/Desktop/helo$ g++ -o test Sequence.o SequenceTest.o
尝试
g++ -o test Sequence.o SequenceTest.o
正如其他人提到的,-o
代表输出文件名。在这种情况下,g++ 假定Sequence.o
作为输出文件名,SequenceTest.o
和test
是要编译或链接的文件。所以
g++ -o test Sequence.o SequenceTest.o
是正确的方法。而且,您可以使用单个命令完成整个编译过程。
g++ Sequence*.cpp -o test
非答案是'sudo apt-get codeblocks'。您可以花更多的时间学习C++,而花更少的时间使用命令行。
相关文章:
- 为C++03编译器编写部分unique_ptr,该编译器与较新的编译器在公共代码库上运行
- 如何使用传递给编译器的相同参数在 cmake 中运行命令?
- 编译器资源管理器(godbolt)如何安全地运行代码?
- 需要有关运行具有输入类型的编译器的帮助
- 为什么我的程序无法在GDB在线编译器/调试器或Visual Studio C++ 2019中运行
- C++程序编译器在使用g++命令编译后自动运行exe文件
- 是否允许编译器在运行时调用立即(consteval)函数
- 我最近更改了编译器路径以运行 c++ 代码,但现在我无法运行任何 python 代码。我该如何解决这个问题?
- 无法构建 quazip。MOC 编译器不会运行。命令行未找到相关类
- 无法在终端中的 Windows 5.10.1 上运行 qt10.1 的编译器'cl'
- 运行时附加编译器标志
- 编译器发射std :: move()运行时调用
- C 编译器输出由于Permisson误差而未运行
- Inno设置编译器未运行我的C/C 代码
- 我的程序在Windows上使用MSVC和G 编译器运行,但在Linux上不运行
- 在 Ubuntu 上使用 g++ 编译器运行程序
- 使用c++编译器运行gcov工具
- 如何使用Visual c++编译器运行Cmake for boost 1.39.0构建库
- 使用不同于系统默认的编译器运行CMake
- 编译器运行时错误报告和错误位置