Developing for Linux

Developing Linux software on Windows

If possible, install the entire development environment on the linux server. Then install an Xserver (e.g XMing) and an ssh client (e.g putty) on your Windows box. Then run the dev. environment remotely.

The big pro of doing this is that the linux windows integrate seamlessly in the Windows enviornment. I used to work with dual platform development and had a virtual linux box on my PC. Still, I used ssh+X-forwarding to access it. This way I got full copy-paste support etc. between the environments.

C++ development on linux - where do I start?

What are recommended guides on creating a make file, how do I compile from this makefile (do I call g++ myself, do I use 'make'?)

You build from the makefile by invoking "make". And inside your makefile, you compile and link using g++ and ld.

Looking at other linux software, they almost always seem to have a 'configure' file. What exactly does it do? Does it only check if the required libraries are installed or does it more than just checking requirements?

It's a script usually used to set up various things based on the environment being used for building. Sometimes it's just a basic shell script, other times it invokes tools like Autoconf to discover what is available when building. The "configure" script is usually also a place for the user to specify various optional things to be built or excluded, like support for experimental features.

How do I link libraries, and how does this relate to my makefile or g++ parameters? In windows I would compile the library, include some header files, tell my linker what additional lib file to link, and copy a dll file. How exactly does this process work in linux?

ld is the GNU linker. You can invoke it separately (which is what most makefiles will end up doing), or you can have g++ delegate to it. The options you pass to g++ and ld determine where to look for included headers, libraries to link, and how to output the result.

Recommendations for code editors? I am currently using nano and I've heard of vim and emacs, but don't know what the benefits of them are over eachother. Are there any others, and why would I consider them over any of the previous three? Note: I am not looking for an IDE.

Vim and Emacs are very flexible editors that support a whole bunch of different usages. Use whatever feels best to you, though I'd suggest you might want a few minimal things like syntax highlighting.

Developing for Linux

Funny story, actually. Two years ago, I developed this for a GTK frontend. You can grab the code at vive.sourceforge.net. I since abandoned it when nobody was using it and I had no need for it, anymore, but the code is still there and you're absolutely free to go tear it apart, laugh at my mistakes, and take what you can from it.

I will warn you, that code is fairly laughable. I was learning C and GTK at the time, so be easy on me :)

If you'd like to take it over, I'd be glad to turn it over!

It looked like this:
alt text

Developing Windows Software on Linux

There is probably no universal answer to this.

This is how I develop software on Linux that is used mainly on Windows:

  1. I use the Qt framework which abstracts away all platform-dependent details in my case.
  2. I use MinGW-w64 to cross-compile. It works very well with CMake-based projects and the excellent binaries from Martchus, which also have great support for static builds.
  3. I use Wine for testing. However during development I can test and debug the Linux binary. A luxury due to Qt abstraction that fits my needs.

What tools does Linux programmer use to develop programs?

No, it is not true. People just use what they prefer most. The definition of IDE is also a bit weak. On Linux, many text editors are very powerful, for example Emacs. You could perhaps call that text editor already an IDE. Though, to point out a difference, Emacs (and other text editors) were originally made to be very general and write just anything with it, and handy tools/functions for developing C/C++/whatever were added later. And their programming language support mostly* only covers syntax highlighting, not much more.

Applications like KDevelop or Eclipse were initially developed to be a development environment and most of these still have more/better functionality to develop. I call these IDEs.

There are many different IDEs on Linux, some more powerful, some less powerful, some for one specific programming language, some for many different. Depending what language you want to write in, some are better than others.

Also, some are more bloated than others. That is one of the main reasons people just use a text editor because it is very snappy, very stable and very fast.

I'll list some IDEs which I think are the best in term of functionality specific to that language (like code completion and many other stuff).

For C/C++:

  1. KDevelop

    For what I know there is no IDE which has better support for C/C++. I didn't found any other tool which handles C++ in such a way that it really understands STL, which is important that you can use autocompletion for STL containers and such stuff. It even understands macros, so autocompletion even works in very complicated cases with many macro-tricks. I work on a ~250k loc C++ project and it has understood the full code. (To use the extended C/C++ support though, you have to activate it in project settings, it is disabled by default. Also, to have full STL support, I preparsed the STL headers and added that to the C++ support in project settings manually. Don't know if that is still needed. But I guess it still doesn't work out-of-the-box.)

    Also, KDevelop is very snappy and fast (developed itself in C++), compared to many other IDEs. It loads almost as fast as any other simple text editor and feels as snappy as such. And that also doesn't change for very big projects. Whereby I myself just use it for editing/writing the code, not managing the compiling of the project. It has automake support but I prefer to use CMake. But KDevelop works fine with that: when I press compile in KDevelop, it just starts a make.

    Initially, KDevelop was developed as a development tool for KDE applications but it works fine for any C/C++ project. I actually have never done any Qt/KDE project with it. Also, support for other languages like Ada were added later on but I haven't tried that.

    I don't know any other IDE which has better support for C++. Please comment me if I am wrong here. I didn't checked many other IDEs anymore in the last one or two years.

  2. Eclipse

    You probably know that already. Initially it was developed in and for Java. Later, support for C/C++ was added.

    I want to note this IDE because I know many people using it. I am not really recommending it though because I have mostly made bad experiences.

    The C++ support is good, not perfect though; there are cases where autocompletion doesn't work.

    The possibilities and features of the IDE itself are very rich. I don't know many other IDEs which are such big (bloated). That, together that it is in Java, makes it often feel very slow and sometimes hanging while you are writing something. Also the memory usage is very high.

  3. Qt Creator

    Initially for Qt development, but also fine for any other C/C++ projects. Very good qmake support.

    The C++ support is nice, only some smaller problems. Also, the IDE is snappy and fast.

    After all, I found myself a bit too limited in this IDE and the C++ support in KDevelop was still better, so I kept using KDevelop for most C++ projects. But when you do a Qt project, Qt Creator is great because it also comes with some nice GUI builders for Qt and other nice Qt tools.

  4. CLion

    (Commercial, but free version.) A newcomer by JetBrains. Very promising.

For Java:

  1. Eclipse

    See my comments above.

    For Java, I think this is the most common IDE on Linux. The same disadvantages as noted above apply here also but I don't know any better IDE, so I keep using Eclipse when I develop in Java.

  2. NetBeans

    Also in and for Java. Never tried that because it was not really supported in my Linux distribution (I think because of licensing issues, don't remember exactly anymore).

    I have seen many flames in the past about NetBeans-vs-Eclipse. Don't know actually about the current state.

For C#:

  1. MonoDevelop

    Also haven't tried that myself, only have heard that it is one of the best tools for C#. Just wanted to note that because you referred to Visual Studio and you may be interested in C#.

I want to add some words to the usage of the terminal:

In addition to such an IDE, it is very common to use a terminal in parallel to your IDE. The terminal and all its shells together with all the Unix tools and other tools is very powerfull and you can do many tasks in a very simple way. Once you get a good overview over all the Unix tools and how to use them, they can save you a lot of work.

There are often tasks in a project which needs to be done again and again. That can be simple tasks like how you manage your source code and distribute it with your teammates or also more complex tasks.

For example, when you do some server-client work and start perhaps 10 servers and 100 clients on different machines, let them all doing something; then grep the output for some regular expressions and collect all that and do some performance tests over 10 seconds and repeat that progress several times - such things are all trivial once you manage the terminal.

You will find yourself ending up having just several scripts written which do all that for you. Writing such scripts is mostly straight-forward.

This goes perhaps a bit off-topic but I just wanted to have that noted because it is a common and powerfull way to work. When you switched from Windows to Linux as a developer, you should take a look at all those additional possibilities you have now. Those are the main reason for me (and many others) why I prefer developing on Linux/Unix than on any other system.


(*) Again some words to Emacs: Emacs can be extended my many tools and plugins which make it a very rich system with the same functionality as an IDE. For example, there is CEDET which comes with real language support, i.e. you also have features like smart word completion / IntelliSense and also a project management system. I haven't tried it myself but I will do that in the next weeks.

Developing on Windows Machines, deploying on Linux (Ubuntu)

I guess there are as many solutions as freelance developpers.

Maybe not the best, but here what I'm doing and it works well :

  • Windows7 hosting 2 Virtual machines (virtualbox)
  • Eclipse Helios on the Windows machine
  • 1 VM ubuntu, used for various script testing from a client
  • 1 VM Debian, as a development server, built as perfect image of the production server
  • 1 production server, so Debian in my case, where I transfer the "finished" product or validated releases.
  • 1 developpement server, only for SVN and/or TRAC or similar. This could be merged within your development VM server.
  • for Perl developments, I have added Perl modules -under cygwin- on the windows hosting machine, Eclipse being tuned accordingly to this set up. But being honest, such mixed solutions should be avoided.

What does it allow ?

  • the VM use allows you to have a kind of permanent backup of your development server,
  • the VM use allows you to come back easily to a previous server release - for instance in case of crash,
  • ssh from one machine to the other, even from one VM to the other,
  • sharing directories between Windows and your VM's,
  • using Eclipse as a developpment center for all these on the Windows machine (subclipse/svn client, java, python, php, perl, bash, js, ...)

You will loose some of the speed of a local server because of the VM required resources - hosted on the same machine than your windows stuffs, but the "how much" will depend on your hardware. In any case, this shall not become a bottle neck for such a layout.

It's a bit heavy to setup at the beginning but very convenient once on track.

Hope it gives you ideas at least.

PS: setting up a VM is quite straight forward, even a noob like me has done it :-)

Developing Windows applications on Linux?

Check Qt too. It's a very rich cross-platform framework.

As for installers I'd highly recommend WiX.

For testing it will be much better to use some kind of virtualization like Sun Microsystems's VirtualBox. I believe you could use a trial version of Windows or Windows 7 RC, which is free to use until March 2010.



Related Topics



Leave a reply



Submit