如何开始在* nix上进行开发 [英] How to get started developing on *nix

查看:72
本文介绍了如何开始在* nix上进行开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有关于使用g ++和gdb的良好的使用方法"或入门"指南?

Is there a good 'how-to' or 'getting started' guide for getting started using g++ and gdb?

一些背景.体面的程序员,但是到目前为止,我已经在Windows中的Visual Studio中完成了所有工作.

Some background. Decent programmer, but so far I have done everything on Windows in Visual Studio.

我对使用终端来编译文件有一点经验(除了.h和1或2 .cpp以外).但是除此之外没有什么.

I have a little experience using terminal to compile files (not much beyond a .h and 1 or 2 .cpp). But nothing beyond that.

任何人都知道如何开始在Linux上进行编码的好入门?

Anyone know of a good primer on on how to get started coding on Linux?

推荐答案

阅读一些好书,特别是高级Linux编程高级Unix编程.另请参阅高级bash脚本指南和其他文档. //www.tldp.org/"rel =" nofollow> Linux文档项目

Read some good books, notably Advanced Linux Programming and Advanced Unix Programming. Read also the advanced bash scripting guide and other documentation from Linux Documentation Project

很显然,请在笔记本电脑上安装一些Linux发行版(不是在某些VM中,而是在实际磁盘分区上).如果您有类似debian的发行版,请在其上运行aptitude build-dep gcc-4.6 gedit以获得许多有趣的开发人员软件包.

Obviously, install some Linux distribution on your laptop (not in some VM, but on real disk partitions). If you have a debian like distribution, run aptitude build-dep gcc-4.6 gedit on it to get a lot of interesting developers packages.

了解一些命令行技能.学习使用man命令;安装manpagesmanpages-dev软件包后,键入man man(使用空格键滚动文本",使用q键退出).另请阅读 intro(2)手册页.当您忘记如何使用cp之类的命令时,请尝试cp --help.

Learn some command line skills. Learn to use the man command; after installing manpages and manpages-dev packages, type man man (use the space bar to "scroll text", the q key to quit). Read also the intro(2) man page. When you forgot how to use a command like cp try cp --help.

即使对于一个人的小型项目,也要使用类似 git 的版本控制系统.

Use a version control system like git, even for one person tiny projects.

备份文件.

Linux syscalls 免费软件 Posix Unix

尝试使用命令行.例如,尝试在命令行上进行一周或更长时间的所有操作.避免使用台式机,也不要使用鼠标.学习使用emacs.

Try hard to use the command line. For instance, try to do everything on the command line for a week or more. Avoid using your desktop, and possibly your mouse. Learn to use emacs.

了解诸如 GNU make

从其源代码中检索一些免费软件(例如,从 sourceforge github ),并练习构建和编译它们.研究他们的源代码

Retrieve several free software from their source code (e.g. from sourceforge or freecode or github) and practice building and compiling them. Study their source code

在命令行(在终端中)中启动的基本技巧(如果未找到命令,则需要安装提供该命令的软件包).

Basic tips to start (if a command is not found, you need to install the package providing it) in command line (in a terminal).

  • 运行emacs;有一个教程菜单;练习半个小时.

  • run emacs ; there is a tutorial menu; practice it for half an hour.

编辑helloworld.c程序(使用main调用某些hello函数)

edit a helloworld.c program (with a main calling some hello function)

gcc -g -Wall helloworld.c -o helloworld编译;改进您的代码,直到没有警告.始终将-Wall传递给gccg++以获得几乎所有警告.

compile it with gcc -g -Wall helloworld.c -o helloworld; improve your code till no warnings are given. Always pass -Wall to gcc or g++ to get almost all warnings.

使用./helloworld

gdb ./helloworld对其进行调试,然后

  1. 使用help命令
  2. 使用b main命令在main中添加断点,并为hello函数添加断点.
  3. 使用r
  4. gdb下运行它
  5. 使用bt进行追溯
  6. 使用p打印一些变量
  7. 使用c继续执行已调试的程序.
  1. use the help command
  2. use the b main command to add a breakpoint in main and likewise for your hello function.
  3. run it under gdb using r
  4. use bt to get a backtrace
  5. use p to print some variable
  6. use c to continue the execution of the debugged program.

  • 编写一个小巧的Makefile以便能够使用make

  • write a tiny Makefile to be able to build your helloworld program using make

    了解如何从Emacs内部调用make(使用M-x compile)和gdb(使用M-x gdb)

    learn how to call make (with M-x compile) and gdb (with M-x gdb) from inside Emacs

    了解有关 valgrind 的更多信息(以检测大多数内存泄漏).也许考虑在您的某些应用程序中使用 Boehm的GC .

    Learn more about valgrind (to detect most memory leaks). Perhaps consider using Boehm's GC in some of your applications.

    这篇关于如何开始在* nix上进行开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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