Tag Archives: Development

Netbeans 7.0 and "Cannot find java. Please use the -- jdkhome switch"

Netbeans LogoWhy do I like coding in Netbeans IDE? I don't really know why, I just do. Don't get me wrong, I use Eclipse and it is a great tool but Netbeans and me go way back. But unfortunately there is a little hiccup with the latest Netbeans 7.0. Installing Netbeans while having OpenJDK results in Netbeans refusing to start with error message "Cannot find java. Please use the --jdkhome switch" when you try to start it with Sun (now Oracle) Java. The fix for this annoying bug (I guess we can call it bug) is rather trivial so read on.

Continue reading

C/C++ library programming on Linux - Part three: Dynamic libraries using POSIX API

This is my third article in the “C/C++ library programming on Linux” series. I strongly suggest you read the first two parts parts of this article series where I’ve given some background about libraries on Linux operating system and explained static and dynamic libraries.

C/C++ library programming on Linux – Part one: Static libraries

C/C++ library programming on Linux – Part two: Dynamic libraries

In this third article I will explain the most interesting way of reusing code using libraries on Linux operating system - by using POSIX ("Portable Operating System Interface for Unix") application programming interface. Using POSIX functions dlopen(), dlsym(), dlclose() and dlerror() you can load and unload your shared libraries during the course of your programs operation. This functions present interface to the Linux dynamic linking loader explained in the first part of my "C/C++ library programming on Linux" article series. This system calls are typically used for implementing stuff like plugins for your application so that you can load functionality provided inside plugin specific dynamic library on-demand. So here's simple example of loading dynamic library into the "cprog" program presented inside my first article "C/C++ library programming on Linux – Part one: Static libraries".

Continue reading

C/C++ library programming on Linux – Part two: Dynamic libraries

This is my second article in the "C/C++ library programming on Linux" series. I recommend that you read the first part of this article series where I've explained the whole library thing, and gave an example of creating and using static library.

C/C++ library programming on Linux – Part one: Static libraries

In this article I will explain dynamic libraries and compare them to static libraries. I will also give an example of creating and using dynamic library.

Dynamic (shared) libraries

Dynamic libraries are different from static libraries in a way that by using them, during compilation process, GCC ads only code "hooks" and soname. That "hooks" and library soname are used during the startup of your application to load correct library and connect "inside" with the "outside" code.

Continue reading

C/C++ library programming on Linux - Part one: Static libraries

Background

One of the most important aspects of modern programming is concept of reuse of code. Even C programming language allows us to reuse our code using concepts like simple functions and structures. C++ programming language goes one step further and allows us to group related variables and functions into classes with the same purpose - the reuse of our valuable code. By using libraries we can go even further from sharing code inside one process - we can share code between completely different programs.

What changes when using libraries? Answer to that question is: "link phase" of your program. In this phase GNU linker links all code modules in fully functional program. When it comes to libraries on Linux operating system we have two basic concepts: static and dynamic (often called "shared"). In this article series I will do my best to explain both Linux libraries concepts using simple C language examples.

Continue reading

Qt 4 C++ development with Qt 4 Creator or Netbeans on Ubuntu Linux

Qt logoSo you want to develop GUI applications using Qt4 framework on Ubuntu Linux? No problem. Everything what you need is at the tip of you fingertips (official Ubuntu repository to be exact). Here's what you need to do to have Qt 4 Assistant, Qt 4 Designer, Qt 4 Linguist and last but not least important Qt 4 Creator (following is all one line at the terminal):

sudo apt-get install build-essential qt4-designer qtcreator qtcreator-doc qt4-demos qt4-doc qt4-dev-tools libqt4-dev

Now feel free to go to Applications -> Programming -> Qt 4 Creator and do something creative.

Qt 4 C++ Netbeans development

But what if you want to use Netbeans to develop Qt 4 C++ applications? Piece of cake. Follow me... First step is to install Netbeans (you've probably guessed that one).

sudo apt-get install netbeans

Next step is to start Netbeans by going to the Applications -> Programming -> Netbeans. Netbeans is primarily Java IDE so we must make sure that Netbeans has C++ support plugin. So inside Netbeans interface we go to Tools -> Plugins and then switch to "Installed" tab. Here we must make sure that "C/C++" plugin is amongst installed plugins. If not, we switch to "Available plugins" tab and put checkbox next to "C/C++" plugin and click install at the bottom of the dialog. After "C/C++" plugin is installed along with it we acquired Qt 4 project support for Netbeans.

But there is one thing we must do before we start coding. We must tell Netbeans the path to the "qmake-qt4" program necessary to compile Qt 4 applications. We need to go to Tools -> Options and switch to the "C/C++" tab. Next to the "QMake Command" label we must enter path to the "qmake-gt4" program. If you are using Ubuntu Linux operating system you need to enter this path:

/usr/bin/qmake-qt4

Now click OK and find "Hello World" tutorial like this one. So here you go, now you have full blown Qt 4 development environment inside you Ubuntu box.