怎么打开g++

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

怎么打开g++

#1

帖子 hekouren » 2008-12-21 12:59

我装好g++后却不知道怎么打开它,还望各位能指点一下。
hekouren@hekouren-laptop:~$ which g++
/usr/bin/g++
hekouren@hekouren-laptop:~$ g++ -v
使用内建 specs。
目标:i486-linux-gnu
配置为:../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
线程模型:posix
gcc 版本 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
hekouren@hekouren-laptop:~$ g++
g++: 没有输入文件
头像
ranfow
帖子: 176
注册时间: 2006-07-10 16:38
联系:

Re: 怎么打开g++

#2

帖子 ranfow » 2008-12-21 13:02

代码: 全选

ranfow@ranfow-laptop:~$ g++ --help
Usage: g++ [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
  --help={target|optimizers|warnings|undocumented|params}[,{[^]joined|[^]separate}]
                           Display specific types of command line options
  (Use '-v --help' to display command line options of sub-processes)
  -dumpspecs               Display all of the built in spec strings
  -dumpversion             Display the version of the compiler
  -dumpmachine             Display the compiler's target processor
  -print-search-dirs       Display the directories in the compiler's search path
  -print-libgcc-file-name  Display the name of the compiler's companion library
  -print-file-name=<lib>   Display the full path to library <lib>
  -print-prog-name=<prog>  Display the full path to compiler component <prog>
  -print-multi-directory   Display the root directory for versions of libgcc
  -print-multi-lib         Display the mapping between command line options and
                           multiple library search directories
  -print-multi-os-directory Display the relative path to OS libraries
  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
  -Wa,<options>            Pass comma-separated <options> on to the assembler
  -Wp,<options>            Pass comma-separated <options> on to the preprocessor
  -Wl,<options>            Pass comma-separated <options> on to the linker
  -Xassembler <arg>        Pass <arg> on to the assembler
  -Xpreprocessor <arg>     Pass <arg> on to the preprocessor
  -Xlinker <arg>           Pass <arg> on to the linker
  -combine                 Pass multiple source files to compiler at once
  -save-temps              Do not delete intermediate files
  -pipe                    Use pipes rather than intermediate files
  -time                    Time the execution of each subprocess
  -specs=<file>            Override built-in specs with the contents of <file>
  -std=<standard>          Assume that the input sources are for <standard>
  --sysroot=<directory>    Use <directory> as the root directory for headers
                           and libraries
  -B <directory>           Add <directory> to the compiler's search paths
  -b <machine>             Run gcc for target <machine>, if installed
  -V <version>             Run gcc version number <version>, if installed
  -v                       Display the programs invoked by the compiler
  -###                     Like -v but options quoted and commands not executed
  -E                       Preprocess only; do not compile, assemble or link
  -S                       Compile only; do not assemble or link
  -c                       Compile and assemble, but do not link
  -o <file>                Place the output into <file>
  -x <language>            Specify the language of the following input files
                           Permissible languages include: c c++ assembler none
                           'none' means revert to the default behavior of
                           guessing the language based on the file's extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
 passed on to the various sub-processes invoked by g++.  In order to pass
 other options on to these processes the -W<letter> options must be used.

For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-4.3/README.Bugs>.
头像
netphi
帖子: 1051
注册时间: 2008-08-29 21:31

Re: 怎么打开g++

#3

帖子 netphi » 2008-12-21 13:09

man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
。。。。。。。。。。。。。
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

Re: 怎么打开g++

#4

帖子 hekouren » 2008-12-21 13:11

这个是帮助文件,可是还是不怎么懂啊。
比如说我用emacs 编辑了代码,怎么调用g++编译呢?
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

Re: 怎么打开g++

#5

帖子 hekouren » 2008-12-21 13:13

netphi 写了:man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
谢谢你啊,解决了我一大疑问,我一直以后g++有gui界面的。
也说是使用它只能在终端里面吧
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

Re: 怎么打开g++

#6

帖子 hekouren » 2008-12-21 13:14

netphi 写了:man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
hekouren@hekouren-laptop:~$ g++ -0 filename filename.cpp
g++: filename:没有该文件或目录
g++: filename.cpp:没有该文件或目录
g++: 无法识别的选项‘-0’
g++: 没有输入文件
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 怎么打开g++

#7

帖子 BigSnake.NET » 2008-12-21 13:22

hekouren 写了:
netphi 写了:man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
hekouren@hekouren-laptop:~$ g++ -0 filename filename.cpp
g++: filename:没有该文件或目录
g++: filename.cpp:没有该文件或目录
g++: 无法识别的选项‘-0’
g++: 没有输入文件
眼镜该换了
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
netphi
帖子: 1051
注册时间: 2008-08-29 21:31

Re: 怎么打开g++

#8

帖子 netphi » 2008-12-21 13:25

:em20 :em20 是 -o(字母o),不是-0(不是数字零),而且filename,一看就知道,指的是你的C++文件的名字。
emacs得调用make,我建议你先用vim,在~/.vimrc中加入:

代码: 全选

map <F7> :call CompileRunGplusplus()<CR>
func! CompileRunGplusplus()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc 
以后在vim中一按F7就直接编译你的C++文件了,这个配置适合初学者。
。。。。。。。。。。。。。
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: 怎么打开g++

#9

帖子 yjcong » 2008-12-21 13:26

BigSnake.NET 写了:
眼镜该换了
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

Re: 怎么打开g++

#10

帖子 hekouren » 2008-12-21 13:27

BigSnake.NET 写了:
hekouren 写了:
netphi 写了:man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
hekouren@hekouren-laptop:~$ g++ -0 filename filename.cpp
g++: filename:没有该文件或目录
g++: filename.cpp:没有该文件或目录
g++: 无法识别的选项‘-0’
g++: 没有输入文件
眼镜该换了
能说得详细点吗?什么是眼镜,怎么换?谢谢
头像
netphi
帖子: 1051
注册时间: 2008-08-29 21:31

Re: 怎么打开g++

#11

帖子 netphi » 2008-12-21 13:28

hekouren 写了: 能说得详细点吗?什么是眼镜,怎么换?谢谢
:em04 兄弟,你是故意逗我们玩的吧? :em05 笑喷了。
。。。。。。。。。。。。。
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 怎么打开g++

#12

帖子 BigSnake.NET » 2008-12-21 13:30

hekouren 写了:
BigSnake.NET 写了:
hekouren 写了:
netphi 写了:man一下g++来看看参数,g++只是一个带参数的gcc编译器,没有GUI界面。
你可以参考一下最简单的g++编译命令:

代码: 全选

g++ -o filename filename.cpp
hekouren@hekouren-laptop:~$ g++ -0 filename filename.cpp
g++: filename:没有该文件或目录
g++: filename.cpp:没有该文件或目录
g++: 无法识别的选项‘-0’
g++: 没有输入文件
眼镜该换了
能说得详细点吗?什么是眼镜,怎么换?谢谢
字面意思 =。=
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
liupingjing
帖子: 451
注册时间: 2007-11-29 17:31

Re: 怎么打开g++

#13

帖子 liupingjing » 2008-12-21 13:40

:em05 :em05 :em05 :em05
楼主太酷了,崇拜……


PS:如果是真不知道的话建议先去找本书看看,或者在google里搜一下g++的用法
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

Re: 怎么打开g++

#14

帖子 yjcong » 2008-12-21 13:42

大家别逗lz了,
是小写字母o, 不是数字0
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
hekouren
帖子: 10
注册时间: 2008-11-20 14:50

Re: 怎么打开g++

#15

帖子 hekouren » 2008-12-21 14:07

哎,你们太搞笑了,原谅一下新手哈。谢谢你们
回复