惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
博客园 - 司徒正美
罗磊的独立博客
D
Docker
Last Week in AI
Last Week in AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
V2EX
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 叶小钗
B
Blog RSS Feed
A
About on SuperTechFans
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
P
Proofpoint News Feed

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker
Programming in Linux for newbies
Ashish Bhatia · 2010-06-01 · via ashishb.net

This is meant to be a small guide (though not exhaustive) for students beginning to program on Linux system. Particularly for those, who have done extensive C/C++ programming in Windows, using the Borland/Turbo interface or the Visual C++ interface, and are greatly intimidated by the Linux platform.

There are three major steps to program in linux

(assuming that you have thought of the algorithm you wish to implement)

  1. Coding the solution In windows, we have borland/turbo/Visual c++ IDE where we code, compile and execute our code in a single interface. In linux, these three steps are preformed separately (there are editors which allow you to do that but it is better to avoid them till one has gained enough familiarity with linux) I feel the best editor to write your code as a newbie is kate (type “kate &” (without quotes) on the shell prompt. kate is quite similar to editplus editor available on windows. Later on, one should move to a more powerful editor like vi or emacs (I personally prefer vi and nice tutor for vi can be accessed by tyoing vimtutor on shell prompt)

  2. Compiling the code To compile the code, again go to shell prompt ( Yes, on linux you will soon get use to shell prompt for almost every task) and execute the command gcc progfilename eg. gcc helloworld.c or g++ progfilename Note: gcc is C compiler for Linux (written by GNU) and g++ is C++ compiler for linux (written by GNU) In case there is no output => your code compiled successfully

    In case there is an output => you will see the output is readable, it tells you which lines of your code has errors/warnings.

  3. Executing the code Assuming that your code compiled successfully, a file named “a.out” is created in the same directory in which you gave the compilation command. Now execute the command “./a.out” (without quotes) to execute your program Note: In case you compile your code using -o switch you can decide the name of output file which by default, is a.out for example, gcc helloworld.c -o helloworld.out g++ helloworld.cpp -o helloworld.out

Which libraries are supported by gcc/g++

gcc/g++ support almost all the libraries of borland C/C++ with one main exception : It does not support conio.h library. Therefore, please do not include conio.h in your source file.

When compiling C++ source files, if you happen to use the iostream.h header library, you may get to see some ugly warning messages by the compiler. The program will compile fine, but if you want to get rid of the warning messages, you can include your files in the following manner :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <iostream>

#include <stdlib.h>
//... Other include statements here
using namespace std;
//this will come only in the end

instead of just

#include <iostream.h>
#include <stdlib.h>

....

Page updated by Ashish Bhatia (Y5 batch prog club coordinator) on Feb 29, 2008 Page originally written by : Shashi Mittal(Y2 batch prog club coordinator)