C和C ++在Ubuntu 11.10编程 [英] C and C++ programming on Ubuntu 11.10

查看:118
本文介绍了C和C ++在Ubuntu 11.10编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了Ubuntu 11.10,并与它一起在$ C $个cblocks IDE,我知道我有gcc和默认情况下,STD库。

I've recently installed Ubuntu 11.10 and along with it the CodeBlocks IDE and I am aware that I have gcc and the std libraries by default.

我的问题是:


  • 请你,你有在Ubuntu上一个新的C ++程序员任何提示?

  • 的库,我应该从一开始就得到什么?

  • 一个真正的好IDE我失踪? (因人而异,但我preFER在IDE的工作)

  • 所有程序恩赐或陷阱,我应该知道从一开始的?

推荐答案

您不需要在C或C ++在Ubuntu的IDE到code。您可以使用一个好的编辑器(如的Emacs ,它可以配置,以满足您的需求。)

You don't need an IDE to code in C or C++ on Ubuntu. You can use a good editor (like emacs, which you can configure to suit your needs.).

对于一些新手一些提示:

Some few tips for a newbie:


  1. -Wall -Wextra ,也许永远编译甚至与 -Werror -pedantic-错误

  2. 的参数,以便将编译器( GCC G ++ )是非常重要的;我建议:

  1. Always compile with -Wall -Wextra and perhaps even with -Werror -pedantic-errors
  2. Order of arguments to the compiler (gcc or g++) are really important; I recommend:


  • 一般性警告和优化参数(如 -Wall -g 来获取调试信息, -O -flto 等,或 -c 来避免链接。 ..)

  • preprocessor选项,如 -I 包括-DIR -D 定义符号的(或 -H 来了解哪些头得到包括)等。

  • 源文件[S]编译像的hello.c world.cc

  • 如果你想 else.o 链接现有目标文件,源文件后,将它们添加

  • 连接选项(如果相关),特别是 -L 库目录的(也可能是 -rdynamic 如果你的程序使用的插件与的dlopen(3) .... )

  • 库(比如 -lfoo -lbar 从像 libfoo.so 更高级别的库下级库

  • 输出文件(即生产的可执行文件),例如 -o yourexec

  • general warnings and optimization flags (e.g. -Wall, -g to get debug info, -O, -flto etc, or -c to avoid linking , ...)
  • preprocessor options like -I include-dir and -D defined-symbol (or -H to understand which headers get included) etc..
  • source file[s] to compile like hello.c or world.cc
  • if you want to link existing object files else.o, add them after the source files
  • linker options (if relevant), notably -L library-dir (and probably -rdynamic if your program uses plugins with dlopen(3) ....)
  • libraries (like -lfoo -lbar from higher-level libraries like libfoo.so to lower-level libraries.
  • output file (i.e. produced executable), e.g. -o yourexec.

总是正确的源$ C ​​$ C,直到你得到任何警告的。相信编译器的警告和错误消息。

Always correct your source code till you got no warning at all. Trust the compiler's warnings and error messages.

了解如何使用制作并编写简单的的Makefile -s;看到这个例子

Learn how to use make and to write simple Makefile-s; see this example.

还有其他一些助洗剂,如 http://omake.metaprl.org/ 等功能

there are other builders, e.g. http://omake.metaprl.org/ etc

以上建议不具体到Ubuntu 11.10,他们可以适用于其他Linux发行版和其他版本的Ubuntu

NB

The advices above are not specific to Ubuntu 11.10, they could apply to other Linux distributions and other Ubuntu versions.

这篇关于C和C ++在Ubuntu 11.10编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆