Thursday, June 5, 2014

Cross-compile C application for Win32/64 on Ubuntu

I used the MingW libraries to compile an application written in C (with makefile etc.)  with Ubuntu-32bit as host and Win 32/64 as the target.

Installation
sudo apt-get install mingw32 (for libraries with win32 as target ?)
sudo apt-get install mingw64 (for libraries with win64 as target ?)

Compilation
  i686-w64-mingw32-gcc      -o target.exe main.c // Compile for win32 target.
  x86_64-w64-mingw32-gcc -o target.exe main.c // Compile for win64 target.

Since my application used makefile,  I changed the variable
CC = x86_64-w64-mingw32-gcc (previously CC = gcc)

Tips 
The application I was working on had a subdirectory with a bunch of c files and a makefile to compile them. Sort of a library. My first mistake was that I hadn't removed *.o files from that directory, which means compilation of appln. was showing a ton of linker errors. So I removed the *.o, *.exe from all the folders. Then I changed the gcc command in this folder's makefile, so this library could be recompiled again with this application.

Other than Ubuntu, I tried to compile this appln. using MinGW32 tools for Win7. I could get it to work to compile and install simple applications, but couldn't get mine to work. The reason was that my application compilation requires bison / flex libraries and I couldn't get it to work on MinGW32 tools for win7.

References
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://www.mingw.org/wiki/MinGW_for_First_Time_Users_HOWTO
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://mingw-w64.sourceforge.net/download.php#automated-builds

Sunday, January 26, 2014

Install Thinkpad tools on Ubuntu 12.04

I own a T400 for 51/2 years now, and it has been treating me very well. I haven't still replaced my original battery, it still holds up 90% of its original capacity. Great Job Lenovo ! One possible reason is that I am using Battery Thresholding since the first few weeks of buying this machine, and made sure that this Thresholding works on all the OS I use. I use Ubuntu around 95% of my time using my PC (lets not talk about the other 5% time I spend editing the Word / PPTs on the crappy OS).  Thinkpad provides Battery driver software for Windows, but doesn't provide any drivers for Linux. Luckily drivers exist, and I found it on this link

The installation steps are very easy, I am reproducing here from the above link.

1. sudo apt-get install tp-smapi-dkms
2. sudo modprobe tp-smapi
3. Verify that the module is installed, using lsmod | grep smapi
4. Enable the superuser (su) mode on the terminal and do
echo 30 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh

5. Make sure that the module loads on startup. Add the following line in /etc/modules

tp_smapi

6. To set the threshold settings at startup, Add the following lines in the tail of /etc/sysfs.conf  file

devices/platform/smapi/BAT0/start_charge_thresh = 50
devices/platform/smapi/BAT0/stop_charge_thresh = 80
EOF

Thats it. I focused only on battery thresholding, but there are many other tools that this module provides. Just check the files in /sys/devices/platform/smapi/BAT0/*

Sunday, April 28, 2013

Mount CIFS directory in Ubuntu (Linux) for Duke University OIT

Tired of switching to your Windows, just to edit your webpages? Just because the OIT supports mounting those CIFS drives only on Win / MAC.

I used the following technique to mount the CIFS directory on my Ubuntu.

First, you  need to be on the Duke network. If not, get onto the VPN.

Then,
mkdir ~/mnt
sudo mount -t cifs //myserver_ip_address/folder ~/mnt -o username=netid,noexec

where
my_server_ip_address = homedir.oit.duke.edu
folder =  users/x/netid  (where x is the first letter of your netid. For e.g. if your netid is john, then folder  = users/j/john)

And thats it. You can see your CIFS directory mounted in ~/mnt.

For editing the files in the public_html, I usually do "sudo gedit ~/mnt/public_html/index.html", since the directory is mounted as a read-only directory. 


Saturday, August 27, 2011

Installing real Player 11 on debian (unsupported)


Real Player 11 is no longer supported for Linux.

here's a .deb copy of application that i could find download , in the article link . This installs the firefox real player plugin as well.