Mar 10 2009

Cross-compiling on Linux using Gentoo crossdev

Category: English posts,TechnicalRpx @ 22:38

Ever wanted to build your program for other architectures than the one on your system?

Maybe you wanted to build a piece of code for a 64bit system but don’t have a 64bit OS available? Or perhaps you want to compile some application for ARM to use on your mobile gadget? It’s all possible using Gentoo crossdev.

Gentoo crossdev will help you install a compiler, linker, runtime libraries and development tools for other architectures than the one native to your system. It does this by emerging the necessary packages in a separate overlay.

To start, emerge crossdev.

# emerge sys-devel/crossdev

Now, create the overlay for it.

# mkdir /usr/portage.crossdev
# echo PORTDIR_OVERLAY=\”/usr/portage.crossdev \$PORTDIR_OVERLAY\” >> /etc/make.conf

That’s all about configuration. It’s time to actually install the cross-compilers.

First, you should take a look at the help provided by crossdev. Issue crossdev –help and crossdev -t help.

Basicly, there are 2 commands which are of interest:

  • crossdev -t TARGET
  • crossdev -C TARGET

-t will install the specified target cross compiler, and -C will erase it.

Also, you can specify how deep the toolchain can go with -sn. The default will install a C compiler, the runtime libraries and a C++ compiler. (see –help).

crossdev -t help will show a comprehensive list of target choices, but I will describe the most usual ones for the average user.

# crossdev -t i686-pc-linux-gnu

installs the 32 bit tools for the PC architecture. Useful if you have a 64 bit system and want to compile for 32 bit without using the -m32 gcc hack.

# crossdev -t x86_64-pc-linux-gnu

install the 64 bit tools for the PC architecture. You can use this if you’ve got a 32 bit system and want to compile for 64 bit or want to test if your application is portable on 64 bit. Obviously, once built, you will not be able to run your application unless you move it on a 64 bit machine and operating system.

# crossdev -t i686-mingw32

installs the 32 bit windows toolchain. This toolchain will give you the ability to compile your application for use with Microsoft Windows. Includes the win32 specific headers and libraries (such as Winsock).

Amongst others, you can install toolchains for ARM, SPARC, Mips, PowerPC, HP-PA and ia64. It is great for checking if your application has any portability issues.

Once installed, the tools may be invoked at the user’s convenience. The format of the tool names is the as follows:

[target]-[tool]

where target is the one installed with crossdev (e.g x86_64-pc-linux-gnu or i686-mingw32) and tool is the tool name (e.g. gcc or ld). So in order to invoke the compiler for win32, we must run

$ i686-mingw32-gcc

And that’s all there is. :)

Note that if your application has dependencies that are not in the standard runtime library, those dependencies must also be compiled with the specific cross-compiler. For example, if your application links to the GTK+ library, GTK+ must also be compiled with that specific toolchain or you will encounter build problems.

If you want to test that everything is OK, here’s an example. It follows the i686-mingw32 approach.

After installing the i686-mingw32 toolchain, we’ll compile a short C program and try to run it with wine.

You can use this program. It’s not the omnipresent “Hello World!” example, but it demonstrates the point.

Save that piece of code as test.c. Next, invoke the builder.

$ i686-mingw32-gcc -o test.exe test.c

There should be no errors. Let’s test the file:

$ file test.exe
test.exe: MS-DOS executable PE  for MS Windows (console) Intel 80386 32-bit

Now let’s run it:

$ wine test.exe
a=10

Congratulations!

Remember! Your system is able to run only executables native to it. You need an emulator to run your cross-compiled applications (such as wine for windows targets), but that’s not always possible. For example, you will be able to compile a 64 bit application on a 32 bit system, but there is no way to run it on that system.


Mar 08 2009

Seaqxx’s laws

Category: English posts,MiscellaneousIuliana @ 0:35

In the same agenda I have found some rules which I tried to follow  while growing up.

  • Never ever fool around with the best friend of your girlfriend’s boyfriend.
  • Ideals usually stay buried in the heart, reality is  a different thing, no matter how hard it is. When ideals escape from the heart they make the dreamer a hero by killing him.
  • Try not to do things that you don’t enjoy at all. You will get it all wrong every time.
  • Females big absurdity is that they always love you when you have something else really important to do.
  • Males big absurdity is that they always have something else really important to do when you want them to love you.
  • A  battle on two fronts fought by one army is a lost battle unless the leader is Napoleon Bonaparte.
  • Never speak to a wide audience unless you are asked or you have something really important to say.
  • Choose wisely the moments when voice should be raised.
  • Don’t lower yourself to the level of someone intelligently inferior to you.
  • Hazard is very rare, but it is known to happen.


Mar 08 2009

Old days stuff

Category: English posts,MiscellaneousIuliana @ 0:03

I was making some cleaning today trying to decide what old stuff to throw out and I found a small agenda that I had been using for about 3 years, one of high school and two of faculty. Inside, among some of my favorite artists at the time autographs and a lot of stupid things, I found some quotes from a favorite writer of mine, named Liviu Rebreanu. So here they are.

  • Every man needs love and is worthy of it.
  • Love moves the sun… and the other stars.
  • Jealousy is born together with love.
  • In reality, nothing lasts forever.
  • Love never killed anyone, people have killed in its name.
  • Murder is always pregnant with punishment.
  • Love has filed for bankruptcy in this modern world, so did humility and respect.All is dominated by pride, vanity, selfishness, hypocrisy and chauvinism.
  • Hate is love’s sister, so it’s no shame to hate.
  • People with money escape any low, but this one.
  • I worth more than my reputation does.
  • True happiness lasts only a moment. Human nature cannot take more than that.


Feb 21 2009

Truth about Romania

Category: English posts,MiscellaneousIuliana @ 10:12

Some of rpx’s Wow friends, expressed the desire for us to write our posts in English so they can understand us. We tried this once before, at the beginning of this blog. But we gave up because was difficult, but mostly time consuming, to write the posts in Romanian and then translate them into English. From now on, posts that I consider interesting will be written directly in English.

Romania is a third world country, so you’ve been told or so you think because you don’t now where it is on the map. The truth is Romania is far from a third world country. I will tell you why.
Before 1989, Romanian people had everything any other people on this planet had except the freedom to live the country and access to information about the world around its country. This isolation made Romania technologically retarded so its inhabitants were forced to compensate the missing technology… by using their brains. The Romanians had jobs, lived in concrete blocks of flats or houses, paid bills and taxes, had access to medical services, their children were well educated and taken care of. Pretty normal for the inhabitants of a country isn’t it? Of course there was also poverty, isn’t it anywhere?
Romania has a geographical advantage being the center of the European continent and it is a pretty valuable “friend” to have. And before 1989 Romania was URSS’s friend.
In 1989 the revolution happened and this revolution is still suspected as being caused from outside, in order to break the communists friends apart. The break up happened and a people with broken beliefs can be easily seduced.
Limits were taken away, a phenomenon called freedom filled their hearts and some took it for granted without actually knowing what it meant. Internet was spreading like a plague, new concepts, new ways of life were overwhelming the “overprotected people”. Some Romanians took the chance and left the country in order to build a brighter future. Some of them are teaching at foreign schools and universities, some of them are respected members of science research teams(LHC team has 20 Romanians for example), some of them are important pieces of big IT companies(Sun and Microsoft) and some of them even have their own companies.
The ones not included above are the ones that don’t work with their brains but they use their arms in growing big economies.(Didn’t you ever wondered what Italian and Spanish economy flourished after 1989?)
Of course some Romanians got it all wrong and took advantage of the naivety of the “over-technologized” people, of course once the iron fist of communists disappeared, gypsies started multiplying and left Romania too, because in a democratic country anyone can leave and come back when he wants, what did you expect? There is no perfect people anywhere in this world, any people has its own thieves, killers, dictators, gypsies and bitches.
So next time when you hear about Romania, if you still don’t know where it is on the map or you have no idea about its history, bite your tongue and don’t say out loud that is a third world country if you haven’t been there to see it with your own eyes. Plus, the fact that you don’t know where it is on the map, doesn’t make you very well informed.

This text was written by a Romanian girl, that has a masters degree and works as a developer in a company which is owned by a French business man. A girl which was also an university teacher for a while, which lives in a beautiful house, has a beautful cat which she adores , writes almost daily on a blog, speaks two foreign languages and gains enough money to support herself and the cat :). Am I any different from you, except the fact that I’m living in a country that you don’t know nothing about? I don’t think so.


Feb 15 2009

KDE4

Category: TechnicalRpx @ 20:48

Seaqxx si-a pus Fedora 10. Acesta a venit spre uimirea noastra cu KDE4.2. Mi-as fi dorit sa nu vina cu el.

Desi KDE4 e trecut de mult de stadiul de beta (cel putin conform site-ului oficial), mie mi se pare o prostie sa fie inclus ca desktop manager implicit si fara alternativa (a se citi fara alternativa la KDE3.5. Excludem gnome si alte DM-uri).

Deci care au fost impresiile initiale?

  • Functionaliatea e jalnica.
  • Documentatia e la pamant.
  • Efectele sunt dragute.
  • Bugurile sunt la tot coltul.
  • Mai are cale lunga si batuta pana sa devina noob friendly.

Sa incepem cu primul din lista. Configuratia widget-urilor (Vista style widgets) este foarte greoaie. Click-urile sunt date foarte greu, drag’n’drop-ul necesita putin mai multa atentie decat ar trebui, optiunile banale care ar trebui sa fie disponibile “at a glance” sunt ascunse adanc in sistemul de gestiune. De asemenea, un lucru care poate fi observat din primele secunde si care ar fi trebuit remediat acum muuuulta vreme e ca daca ai un panel fara taskbar in el, atunci toate widgeturile se vor  ancora de mijlocul panelului si nu vor putea fi trase spre margini, sau mai ales (si aici nu exista scuza) faptul ca pe desktop nu se pot crea icoane intr-un mod simplu (a se citi: “click dreapta->new link”).

Documentatia. Care? Unde? La tot pasul exista cate un buton numit Help. Problema e ca acel buton de cele mai multe ori iti arunca in fata o fereastra de “About” care iti furnizeaza cu placere numele si adresa de mail a persoanei ce raspunde de acel widget/componenta. Asta nu e documentatie.

Ca un plus, efectele sunt misto. Maximizarea, minimizarea, schimbarea desktopurilor, toate merg bine. De asemenea, cu “putin” efort se pot instala efecte aditionale, insa adevarata provocare apare la activarea lor.

Ceea ce nu pricep este de unde si pana unde asemanarea izbitoare cu raposatul Vista. Nu voi sta sa derspic firul in 4 si sa aflu daca de fapt Vista a copiat pe KDE4 sau KDE4 s-a inspirat din Vista sau daca printr-o coincidenta uluitoare designerii celor 2 sisteme au avut o inspiratie ridicol de asemanatoare, fiindca ar fi de prisos. Ideea e ca interfata seamana foarte bine cu Aero, doar ca e mult mai greu de configurat si mult mai slaba ca functionalitate.

Cautand putina lumina in acest intuneric am dat peste acest post al unui developer de la KDE. Acesta afirma clar ca versiunea 4 a lui KDE nu este gata pentru a fi primita de publicul larg, iar eu ca un utilizator destul de vechi al lui KDE sunt total de acord cu acesta.


Jan 28 2009

KDE 4 on Windows

Category: TechnicalRpx @ 12:54

Desi Windows 7 pare a fi o clona ieftina a lui KDE, se pare ca si utilizatorii de XP/Vista au o sansa pentru un nou look.

Read more here.


Jan 16 2009

Map Sorter by size of it’s values

Category: TechnicalIuliana @ 15:41

Acum doua zile m-am vazut in postura de a optimiza ceva, din punctul de vedere al utilizatorului, nu al programatorului. Adica trebuia sa ordonez ninste procesari in functie de durata lor, pentru ca userul ce folosea aplicatia sa vada ca in spate chiar se proceseaza ceva. In fine, n-o sa intru in detalii. Ideea era ca datele de intrare ale procesarilor respective erau continute intr-un map de forma Map<K, Collection<V>> si eu ar fi trebuit sa parcurg mapul respectiv si sa pornesc procesarile in functie de dimensiunea colectiilor din map. Deci as fi avut nevoie sa sortez mapul respectiv in functie de dimensiunea valorilor mapului.

Continue reading “Map Sorter by size of it’s values”