Author Archives: Marko

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

Firefox 4.0 on Ubuntu 10.04 Lucid and Ubuntu 10.10 Maverick

Mozilla Firefox 4.0 Screenshot

Firefox 4 is here as you might have already heard. I've noticed that not many people had updated their Firefox installations cause Firefox 4 won't be in official repositories until Ubuntu 11.04 Natty arrives. But fear not, "Mozilla Team" maintains Firefox Stable PPA for all of you waiting to update their favorite Firefox browser on Ubuntu 10.04 and 10.10. So here's the procedure for updating to Firefox 4.0:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update && sudo apt-get upgrade

Enjoy!

Ubuntu / Debian environment variables and starting scripts at boot

Love your environmentEnvironment variables are very important aspect of Linux based operating systems. They are used by system to adjust its own behavior according to what you have specified during operating system installation and after that you can use it to tweak you system even more. Environment variables take form of name=value and you can view list of current environment variables by issuing following command on your favorite Linux terminal:

printenv

Some environment variables are set by the root user for all users on one PC, but every one of those users can have its own environment variables. Now lets see how should we assign lets say "en_US.UTF-8" value to environment variable named "LC_ALL" (by the way this is the way to tweak you environment locale setting for things like time and date format and things like that). Typically you will assign environment variable like this:

export LC_ALL=en_US.UTF-8
Continue reading

Start shell script on Network Manager successful connection

The other day I was writing a script that needed to do its job only when specific network interface is triggered (wireless broadband ppp0 in my case). Pinging Google every 10 seconds to detect Internet access was out of the question. There is a more elegant way to do this. If you are interested please proceed.

Do you know that authors of Network Manager built option to trigger scripts right into this great application. To use this option you need to write bash script with some specific bash variables and put it to "/etc/NetworkManager/dispatcher.d/" directory. Specific variables are necessary to receive instructions from Network Manager about network interface that triggers execution of your script and should it be executed on "up" or "down" operation on that interface.

Continue reading