57

I need to reconcile these 2 facts:

  1. I don't feel comfortable working on Linux;
  2. I need to develop software for Linux.

Some background: I have a 10+ years of programming experience on Windows (almost exclusively C/C++, but some .NET as well), I was a user of FreeBSD at home for about 3 years or so (then had to go back to Windows), and I've never had much luck with Linux. And now I have to develop software for Linux. I need a plan.

On Windows, you can get away with just knowing a programming language, an API you're coding against, your IDE (VisualStudio) and some very basic tools for troubleshooting (Depends, ProcessExplorer, DebugView, WinDbg). Everything else comes naturally.

On Linux, it's a very different story. How the hell would I know what DLL (sorry, Shared Object) would load, if I link to it from Firefox plugin? What's the Linux equivalent of inserting __asm int 3/DebugBreak() in the source and running the program, and then letting the OS call a debugger? Why the hell release builds use something, called appLoader, while debug builds work somehow different? Worst of all: how to provision Linux development environment?

So, taking into account that hatred is usually associated with not knowing enough, what would you recommend? I'm ok with Emacs and GCC. I need to educate myself as a Linux admin/user, and I need to learn proper troubleshooting tools (strace is cool, btw), equivalents to the ones I mentioned above.

Do I need to do Linux from Scratch? Or do I need to just read some books (I've read "UNIX programming environment" by Kernighan and "Advanced Programming..." by Stevens, but I need to learn something more practical)? Or do I need to have some Linux distro on my home computer?

9
  • 73
    I feel same about Windows
    – ralu
    Commented Apr 7, 2011 at 6:32
  • 15
    Considered getting a another job you are more comfortable with?
    – user1249
    Commented Apr 7, 2011 at 6:54
  • 3
    On Unices man is your friend. I would man nm and man ld as a starting point.
    – snakehiss
    Commented Apr 7, 2011 at 7:35
  • 1
    start using windows ;) Commented Apr 7, 2011 at 9:42
  • 1
    "Everything else comes naturally"? Of course it comes naturally, you've been doing it for 10 years. Linux isn't worse, its different. And now that you're 10 years older, your brain doesn't learn new things as easy as it used to, and all those things which are different become something you have to unlearn. Approaching the entire thing with "Linux sucks" is going to make your life miserable.
    – JesperE
    Commented Apr 26, 2013 at 10:53

16 Answers 16

62

You might find the article Dynamic Linking in Linux and Windows interesting which explains how each OS does dynamic linking. The article Shared Library Search Paths explains how the libraries are found. Also Static, Shared Dynamic and Loadable Linux Libraries is very good. A nice thing about Linux libraries is that they have better support for versioning and having several versions of a library around than Windows (AFAIK, I don't do Windows). See Library Interface Versioning in Solaris and Linux for that. These articles should really get you covered with libraries.

The GDB is very mighty, a good introduction is probably RMS's gdb Tutorial. You might want to read up on conditional breakpoints. For equivalents to __asm(int 3) see the question Set breakpoint in C or C++ code programmatically for gdb on Linux.

The book Advanced Unix Programming from Marc Rochkind is a must-read, IMHO. Has lots of examples and covers all POSIX/SUS topics in a very well explained way. It's the best book about this topic I've read so far.

But to make your life easier I actually recommend to use a highlevel API that abstracts stuff for you, like Qt. Also makes writing cross-platform a lot easier.

Doing Linux From Scratch helps you get an understanding on how a Linux system is composed, but I think it doesn't much improve your knowledge about it from a developers point of view. It does make you more comfortable with Linux though, as you learn what parts are there in a Linux environment (and partly also why). A Linux won't be a big blackbox to you after working through Linux From Scratch.

3
  • Sure, on 32bit system this interrupt will break into the debugger, if the process is already being debugged. That's this if I'm asking about. Windows allows to attach debugger after the trap happened. Under some scenarios, this is extremely convenient. And thanks for the links!
    – rincewind
    Commented Apr 7, 2011 at 16:44
  • 6
    Great answer! Note, for the gdb tutorial, RMS is "Ryan M. Schmidt" not "Richard M. Stallman." (an important note since Stallman was the original author of GDB)
    – entropo
    Commented Apr 7, 2011 at 17:42
  • Windows had Side-by-Side (msdn.microsoft.com/en-us/library/ms229072(v=vs.80).aspx) library loading supported for around 12 years now. So you're rather wrong with regards to versioning. Commented Jul 8, 2012 at 18:59
16

If you like strace, don't forget ltrace: the equivalent for library calls.
Also, yes, I recommend Linux From Scratch. It's a good exercise in working out the core elements of the OS and how they fit together.
For a modern, complete system programming reference treatment, I'd recommend picking up The Linux Programming Interface.

12

The Mac OS X is like a Mercedes; it's the prettiest and cleanest but it costs a lot. Windows is like a Toyota; it will get you there and back.

Linux is like a hot rod; It's for people to dig into and take apart and put back together again. Linux is not for someone who just wants to use the computer; it's for people who love computers. People who don't love computers should stay away from it.

The stuff you learned in Windows won't translate very well, no. But you get to see the internals and watch the engine run.

Try to take Linux as a new toy, that you can play with and crawl into and see what's going on. Things that are easy in Windows are harder in Linux; things that are impossible in Windows are possible in Linux.

If you love computers you can love Linux; if you don't love computers why are you programming at all?

21
  • 13
    +1, for "Things that are easy in Windows are harder in Linux; things that are impossible in Windows are possible in Linux". I'd add "Whereas Windows pushes pre-digested food in your mouth, with Linux you have the possibility to cook and the reward for this is that you get to eat what you like"... Of course, whether it's edible or not depends a lot on how good a chef you are... Commented Apr 7, 2011 at 8:36
  • 14
    @Andy: "Windows is like a Toyota". Toyota has much better quality than Windows. Commented Apr 7, 2011 at 10:15
  • 4
    @SK-logic, Precisely. Without engaging into yet another religious war, please consider the following. For mere strategic and financial reasons, MS target the largest audience possible. Technical stuff that computer aware users would like to be able to control are buried away out of sight so that the Joneses don't run into problems. You end up with red tape everywhere DEP, GPO, "Trusted installer", private or hidden APIs, "self repairing boot", etc. Geeks don't fix Windows, they just opt out. Linux does not have the same hegemonic goal; it's done by users for users. That's the whole point. Commented Apr 7, 2011 at 10:52
  • 3
    @SK-logic - "if you've got Windows sources"... :-)
    – Rory Alsop
    Commented Apr 7, 2011 at 10:53
  • 3
    "Mind naming a couple of things that are "impossible in Windows" and "possible in Linux" - I found a bug in a Linux system script and fixed it. I have found bugs in Windows but never been able to fix them. Suppose you have an ISO (CD) image in a disk file; I can mount that as a drive in Linux; can you do that in Windows? And remember that nearly everything in Linux is free, and nearly everything in Windows requires an expensive proprietary application. Commented Apr 15, 2011 at 6:30
9

How about you develop on Mono with Monodevelop? This would get you started quite easily by re-using your experience in .NET.

1
  • I tried this recently - some differences to Visual Studio, of course, but I was up and running in an evening. It's a great migration path. Commented Jul 21, 2012 at 18:39
7

It's daunting when you look at it from the outset (just like if you were a Linux developer being tasked with doing some Windows development). I would tackle this one problem at a time.

  • First get your environment setup (compiler, IDE - yes they exist, Netbeans/Eclipse etc.)
  • Next get the higher level apis installed (boost/Qt etc.)
  • Start slowly, if there is an immediate problem to solve, get the code compiling (or start writing from scratch etc.) Like you would tackle any development project, get the stuff you know working first (i.e. things that don't need OS specific interaction), and then when you hit a snag - search, I'm sure someone out there has come across the same problem before and have resolved it..

Most importantly, leave all your subjective opinions at the door. And no, you don't need to be a guru to develop in Linux, I know enough to get around, and not everything - but I'm comfortable with that...

1
  • 1
    +1 Nim: StackExchange has an awesome amount of prior information here. I am most comfortable in flavours of Unix, but currently working in Windows development environment and searching SE has answered almost all my queries in a very short space of time.
    – Rory Alsop
    Commented Apr 7, 2011 at 10:55
6

The success or failure of many thing in life comes down to our attitude, looking for positives and keeping your mind focused on the positives will do more to adide you as you start down this new interesting adventure.

How long did it take you to become proficient in working in a windows environment. You might say it was easy you just started. But you had a few years of working with windows before that. How long had you been using windows before you wrote your fist program. It was 8 years for me, all though I have now been using Linux almost exclusively for 5 years. I am now more proficient in Linux then in windows. You should give your self at least that much time to become familiar with a new system.

Start off with the list of application that you can't live with out in windows and look for alternatives in the *nix world. http://alternativeto.net/ and the Wikipedia further reading sections can be helpful here.

Here is a list of alternative software that could prove to be very useful. Here are some alternitives to the things you mentioned.

Other useful resources in moving from one system to another

About becoming a better power user or admin user have a look at these resources

It also sounds like it has been a while since you have looked at the *nix world. I would recommend some of the new distros releases from fedora, suse, debian, or my prefered work station Ubuntu.

You can now probably get away with not know the internals of the system and just the basics as in windows. I would not just try to get away with the minimum. If you see Linux as a tool that actually assists you in your development and not merly an operating system in which you develop it would be helpful.

Linux From Scratch will be much more important if you are specifically developing for Linux is a very specific and technical sense. I.E. you want to develop for the kernel, or port you program on to a super computer running Linux. It would be very useful never the less. I think you could probably leave that for a few months while you just try to get going in Ubuntu. Ubuntu will be as close to the things just work world of mac and windows.

3
  • 1
    Debian isn't exactly a new distro. :-P It's still a good choice though.
    – Steve S
    Commented Apr 7, 2011 at 13:49
  • Neither are SuSE and Fedora... SuSE is 15 years old now, Fedora is indeed one of the "younger" distros being 8 years old. Still, +1.
    – DarkDust
    Commented Apr 7, 2011 at 14:34
  • 1
    @Darkdust @Steve-s new as in the latest releases,
    – nelaaro
    Commented Apr 8, 2011 at 9:31
6

I think you answered your question in the question:

"On Windows, you can get away with just knowing a programming language, an API you're coding against, your IDE (VisualStudio) and some very basic tools for troubleshooting (Depends, ProcessExplorer, DebugView, WinDbg). Everything else comes naturally."

Gues what, on Linux you can get away with just knowing a programming language, an API (or a couple), your IDE (Eclipse or NetBeans, even Geany, Emacs, or vim, if you like) and some basic tools for troubleshooting (gdb, tracing tools, lint, htop, ps).

You have a lot of knowledge invested in the Windows programming ecosystem. Much of that is (hopefully) abstract knowledge (what's a compiler, a debugger, a shared library, a process, a thread? What do they do?) that will tranlate easily, once you get up to speed on the different tools. Some is domain specific (What DLL is linked when I add X to a project?), but even moving from one class of language to another within Windows would require some new learning.

Install Ubuntu or Fedora in a VM, read some C++ Hello World in Eclipse or NetBeans tutorials, and some debugging in Eclipse/NetBeans tutorials, and let your brain's natural ability to adapt take over. It'll translate ideas for you if you relax and just put it to work.

3

I learned Unix in general by reading the man pages. You should at least skim them. Yes, I mean all of them. The method I use it to cd into the man page directories, and attack them one section at a time.

I use this:

for i in *; do f=`basename $i .gz`; man `basename $f .1` ; done

...replacing the .1 with the number of the section you are reading, .2, .3, etc. Hit ctrl-Z ctrl-C to get out of the loop. You mileage might vary if your linux distro stores things differently, i.e. not as cmdname.1.gz.

Just go through the descriptions, and more if it's something interesting. Sections 1, 2 and 3 are the most important for a programmer. 1 covers general user commands, which include your compilation tools, and various forensics utilities. 2 is system calls, and 3 is library calls.

2
  • 2
    I'd suggest to fire up xman as a more “friendly” interface. Select a section, click the man page, read it. Rinse, repeat. Commented Jul 8, 2012 at 20:56
  • I'd forgotten about such things. The state of documentation in free OS land is less than ideal, and I found the tools often made it worse, so I stopped using them. I can only assume they've gotten a little better?
    – Hack Saw
    Commented Jul 11, 2012 at 19:52
3

Do not force yourself into doing something you do not like. Use Windows as your development environment, write a portable code, cross-compile it for Linux, and only test it occasionally in a VM.

2

I'm not sure it works for platforms but for programming languages, I've found it helpful to think about how I got familiar and comfortable with the ones I'm good at and try to replay those experiences and activities for the what I'm trying to learn.

Perhaps something on those lines?

Generally speaking though, my interest and confidence with GNU/Linux has come by it being much more tinkerable (and requiring of tinkering in the early days) than Windows. I needed to mess with a lot of stuff to get things working and that helped me learn a lot of stuff. Things are much better now but all those hours helped.

2

I was one of two tasked with something similar, but different. I work in a K-12 school district, and the business system (HR, financials, etc...) is migrating from an HP3000/TurboImage db to a Linux/MS SQL platform. I'm comfortable with the MS SQL side. But not the Linux side. The two of us are on the admin side, not the programming side. The programming is done outside - 3rd party business app for K-12 orgs.

I took a 5 weekend Intro to Linux (Redhat) class on weekends - was done mostly in command line mode - and it was worth the time for me as a quick jumpstart into the Linux way of doing things. Obviously YMMV depending on class/teacher.

You mentioned 'Worst of all: how to provision Linux development environment?'? Since you're very familiar with Windows already, I would strongly suggest you get a copy of vmWare Workstation. With that you can keep Windows as your workstation, and install Linux as guest systems - delete, rinse and repeat as needed. When you get a good setup, I believe you can snapshot it, but I can't say for sure which versions are capable of the snapshotting aspect. And if you go in the vmWare Workstation route to enable multiple development setups - bump up the memory, definitely.

I also don't mind recommending using CentOS as the Linux OS for the guests. From what I understand, it's like RedHat without the branding and/or sales pitch and/or support costs. I'm not familiar with the other Linux flavors, so can't give input on those.

Greg

1

I like both platforms and for all the differences in the user interface and the dev eco-system, I find them more similar than different under cover. In fact, for most Windows concepts you can find an equivalent Linux ones just by searching the Internet.

Having said that, I strongly suggest learning how to do things the "Unix way". Use command line rather than buggy GUI front-ends (I am talking mostly about gdb here); don't look for an IDE, and learn how to use a set of specialised tools instead. Pick a good editor (pointing to vim) and learn it well. Read how make works even if you don't plan to become an expert. Maybe you even get to like Linux. It is geek-friendly and fun to play with.

1

Consider this: you once didn't know anything about Windows, but you learned it and over time became comfortable with it.

Then MS changed whatever programming system you were comfortable with to .NET and you no longer knew anything about DLLS, COM, and whatever, you had to learn things like assemblies, GAC, app domains. You learned those ok.

So why are you now worried about doing the same with Linux?

There are loads of 'get you started' tutorials on the web for all kinds of programming environments. Now you say GCC so I'm going to assume C++ development. Get yourself Eclipse, install the CDT (c dev tools) on top of your Eclipse platform (Eclipse is a multi-purpose IDE, you can use it for C++, PHP, Java, whatever - but you need to install the tooling for your language as you wouldn't really want it all pre-installed like VS and take 3 days to install :) )

There are easy-to-use tutorials all over the web. IBM has one here that is quite comprehensive.

Debugging tools... eclipse has it embedded (tutorial), but you can find plenty of tools like the ones you mentioned, just search around the web and you'll find lots of options. It will take you a little while to figure out how to read a core dump (as opposed to a windows userdump for example) but you'll get there.

It might also be worthwhile starting a blog with your experiences, not only will it allow you to remind yourself of what you've done (eg setting up eclipse how you like it, you'll forget when you need to do it again in a year's time) but it'll help others in your situation.

0

I don't think you need to do Linux from Scratch. If I were you I would go for Ubuntu. It is more comfortable, and being based on debian, there is plenty of technical material available.

If you do want more of a head-first dive into Linux, Gentoo is a good option. It requires you to read quite a lot about configuration and kernels, but it also gives you quite a functional system to work in af

0

Google "The art of Unix programming" and read it. IMO, your main difficulty is the different philosophy, and that book is excellent reading for this.

It also introduces you to some non-obvious but technically very important differences between *n*x and Windows systems - these being key to understanding why doing things another way makes sense on Linux.

1
  • 1
    ... and it also presents you with a lot of tools and techniques to use on Linux.
    – user59625
    Commented Jul 19, 2012 at 4:06
0

The first question I'd ask is what is it that you want to develop? If it's a gui-based application then that can be different from having to write something like a kernel extension.

In the case of a gui app, I find the easiest method is to use Qt, which has its own development environment (Qt-Creator) and being cross-platform, allows you to learn just one API that can be used for Windows / Linux / OSX and even mobile development. Like visual studio in Windows, or XCode in OSX, you can create and layout windows and items from a graphical editor and the API is very easy to pick up with loads of sample applications.

If you need to get more low-level, then once you know your way around linux on the command line, know how to traverse directories, manipulate files, understand permissions etc., then either start reading how to compile a simple program with gcc, how to link files and run the executable and then how to debug with gdb.

Alternatively, if that seems a little daunting, you could download Eclipse or another IDE, but you'll probably become much more comfortable with Linux in the long term, if you put the time and effort into the command line first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.