g++ server.cpp -Wall

g++ server.cpp -Wall

我有一个在 Linux 中用 C++ 编写的程序,我刚刚下载了 Vim 编辑器,我给出了这个命令来编译:

g++ server.cpp -Wall 

当我来运行它时我使用./a但是

它不起作用可以给我正确的命令来运行该文件。

谢谢。

答案1

a.out根据联机帮助页,默认的可执行文件名称是g++

-o file

    Place output in file file.  This applies to whatever sort
    of output is being produced, whether it be an executable file,
    an object file, an assembler file or preprocessed C code.

    If -o is not specified, the default is to put an executable file
    in a.out, the object file for source.suffix in source.o, its
    assembler file in source.s, a precompiled header file in
    source.suffix.gch, and all preprocessed C source on standard output.

因此,您可以使用./a.out运行已编译的可执行文件或将-o参数添加到g++命令行:

$ g++ -o server server.cpp -Wall
$ ./server

相关内容