RSS
 

Cross compiling samba-3.6.1 for ARM

04 Jan

After some googling I figured out how to compile samba for ARM, the device I am compiling samba for is “chumby one” ( look at http://wiki.chumby.com to get the compiler toolchain for it )

Here are the steps:

1. Download the sources, obviously.
2. export these env vars on your build machine:

export LD_LIBRARY_PATH=/usr/arm-linux/lib
export LDFLAGS=-L/usr/arm-linux/lib
export CPPFLAGS=-I/usr/arm-linux/include
export CC=arm-linux-gcc

3. edit your configure file, look for this:

if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
# getaddrinfo is broken on some AIX systems
# see bug 5910, use our replacements if we detect
# a broken system.
if test "$cross_compiling" = yes; then :

change it to:

if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
# getaddrinfo is broken on some AIX systems
# see bug 5910, use our replacements if we detect
# a broken system.
if test "$cross_compiling" = no; then :

why this? more info here: https://bugzilla.samba.org/show_bug.cgi?id=8410
I made a guess and it works for me.

4. invoke the configure script like so:

./configure --host=i686 --target=arm-linux samba_cv_CC_NEGATIVE_ENUM_VALUES=yes ac_cv_file__proc_sys_kernel_core_pattern=yes --prefix=/mnt/usb/samba

5. edit the makefile, change this:

CPPFLAGS=-DHAVE_CONFIG_H -I/usr/arm-linux/include -Iinclude -I./include -I. -I. -I./../lib/replace -I./../lib/tevent -I./librpc -I./.. -I./../lib/popt -I/usr/local/include

to this:

CPPFLAGS=-DHAVE_CONFIG_H -I/usr/arm-linux/include -Iinclude -I./include -I. -I. -I./../lib/replace -I./../lib/tevent -I./librpc -I./.. -I./../lib/popt

I am not a linux guru so I dont understand why it is including /usr/local/include when I am cross compiling, Samba project needs to fix these small issues, specially for ARM, with ARM gaining foothold in the server market.

6. run make

make

7. Copy files to chumby
I didnt do “make install”, obviously. i copied the bins in the /samba-3.6.1/source3/bin in the samba source folder on build machine to /mnt/usb/samba on chumby


scp * root@CHUMBY-IP:/mnt/usb/samba/

8. update the LD_LIBRARY_PATH on your arm device, chumy in this case.

export LD_LIBRARY_PATH=/mnt/usb/samba:$LD_LIBRARY_PATH

9. Test *

ssh root@CHUMBY-IP
cd /mnt/usb/samba
./smbget

10. make some required folders in /mnt/usb/samba

mkdir private
mkdir var
mkdir var/locks

11. run smbd and give it the conf file

./smbd -i --configfile=/mnt/usb/samba/samba.conf -S

12. tip: use -d 10 for more incase of errors

./smbd -i --configfile=/mnt/usb/samba/samba.conf -S -d 10

13. you can put the samba.conf in /mnt/usb/samba/lib

mv /mnt/usb/samba/samba.conf /mnt/usb/samba/lib/

14. sample samba.conf file:

[global]
workgroup = WORKGROUP
netbios name = CHUMBY

[ready]
path = /mnt/usb/samba_share
guest ok = yes
read only = no

[torrents]
path = /mnt/usb/torrents_share
guest ok = yes
read only = no

15. add samba user, we will use root since chumby comes with this only and there is no useradd command on the device.


smbpasswd -L -a root
smbpasswd -L -e root

16. test on other computers, enter root as user and password you set as the password.

Good luck, you are going to need it.

* works for me ….

 

Pakistan shutdown to mourn Nusrat Bhutto

24 Oct

Monday declared as a holiday and 10 days mourning period announced. 99% of the population does not know who she is. No need to even discuss that the people in power consider Pakistan as their personal state and make such childish decisions all the time.

This was also the front page news on Dawn. Which considers itself very liberal and forward thinking. We can think what ever we want about ourselves, it does not change the reality.

May she rest in peace.

source: http://www.dawn.com/2011/10/24/pakistan-shut-down-to-mourns-nusrat-bhutto.html

 
 

Windows Phone app development and the significance of DSLs.

27 Jul

Computers were supposed to do all the work for all humans, but as programmers we often neglect that very basic purpose of these machines. So we go on writing code doing every little bit ourselves, sure there are libraries to do some of that but using libraries does not really solve the problem. Good design for software is important, but we should not be designing and thinking how to write code when we want to download a file from network, when we need to parse an XML file, or any other easy but mundane task.

I have always thought about domain specific languages as a way to not only boost productivity but also free our thoughts from these small menial and mundane tasks. I am so excited about domain specific languages that I have thought numerous times to continue some research studies in this area. Sadly I havent been able to find any good place yet in Helsinki.

QML or QtQuick is an excellent DSL for creating nicely animated user interfaces, not just for desktop computers but also for mobile devices. The productivity boost is immense, I wrote complete applications in Qt Quick in weeks which even iPhone developers took months to write. Still more wild that the Qt Quick app ran fine on N900, N8 and other Nokia Qt devices. Since that time I have been hooked on Qt Quick. I havent found a better DSL for UI’s than Qt Quick. It is so simple, no crazy xml syntax like in XAML. XAML might be more powerful but the power is lost in its complexity and IMO bad idea of using XML.

The second experience of DSL came with LINQ when I wrote my first app for Windows Phone. I had previously done similar app on Android, iPhone and Qt/Symbian where I needed to parse huge XML documents, so I had to spend weeks just to write the code to handle the SAX events and create a state machine. This code was fragile and just too much work. Thank god for json.

Coming back to the point, the experience of parsing XML with LINQ was quite the opposite, it was … pleasant and enjoyable. I was amused by the speed at which I wrote the code and how simple it was. It all made sense.

I think Microsoft is on the right path. They already have two DSL’s incorporated in Windows Phone development, writing apps therefore for WP is quite easy and fun experience.

I hope in the future DSL’s will become even more common and we will have write apps in DSLs which are then glued together by a general purpose language.

 

Improving Qt’s properties.

01 Jul

I have known Qt for about 9 years now. My first encounter with Qt was as a normal user who was exploring Linux to find out what the fuss was all about. With KDE I got my first experience of Qt. But I have only very recently started to use Qt as a development tool, and I have been very happy about that. Makes life easy, with Qt being ported to Symbian, Meego the gates are open for developers to make money. Since I like to experiment with all the platforms no matter who they are from, I also played around with Objective-C on iPhone some while ago.

While Qt offers many many nice features which make Objective-C look like from stone age. Objective-C has some nice features as well, one I mentioned in my previous post, which Qt already solves rather nicely and in a better way as one of the commenter pointed out. Objective-C and Qt are quite similar in a sense that they provide improvements on top of an already existing language. Qt with meta object compiler and Obj-C with something similar.

So back to the point, I now use Q_PROPERTY macro in my QObjects based classes a lot:

class Person : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)

public:
void setName(const QString& aName) { iName = aName; }
QString name() const { return iName; }

private:
QString iName;
};

Now consider this Objective-C code:

// person.h
@interface Person : NSObject
{
NSString* name;
}
@property (nonatomic, retain) NSString* name; // same as Q_OBJECT 

// person.m:
@implementation Person
@synthesize name; // this generates getter/setter in the .m file

// rest of the code ...

So do you see what I see ? In the Objective-C version of the code I don't have to write the getter and setter methods, whereas in Qt i have to. I think all the information to automatically implement the getter and setter functions is already in the Q_PROPERTY macro, may be the moc compiler can go ahead and also generate the getter and setter methods for us ?

 

Developing Maemo5 and MeeGo applications on Windows

21 May

Maemo/Meego devices are like a computer that you can put in your pocket, for example the N900. Before N900 these maemo devices had been slow, but thanks to the iphone the whole computer industry has realized the importance of speed. N900 is not slow, what i like about this phone is the keyboard and the great web browser that it has. Just imagine the scenario, you are reading a web page on your desktop and then when you have to catch the bus, that page opens up when you start the browser on your N900. This is possible with the firefox addon called the Mozilla Weave. N900 is just awesome, it just needs to exercise 4 hours a week to lose some extra fat that it has, but other wise I really like it.

But perhaps the best thing about N900 is that my Qt apps that I write for  Symbian  also work with little modifications on my N900! you dont even need to install some crazy toolchains or use the linux os to do any of this; with the Nokia Qt SDK you can do all of this from your windows computer. Even though its in beta right now; but every thing works; i am using it for a meego/maemo app i am doing and no issues yet

 
 

Auto Updating apps in Android 2.2/Froyo.

21 May

I just love the idea of auto updating apps in android 2.2 both from the perspectives of the developer and a user. As a developer this will help me make sure all of the users of my app are on the same version. As a user I don’t have to care about updates any more, less work for me and every thing should just work.

 
 

Google now shows government take down requests by country.

20 Apr

at http://www.google.com/governmentrequests/

Do you know what is interesting about that page ? Pakistan made less than 10 removal requests last year, now compare that with Germany, United States, United Kingdom, India (??) and Brazil ( WTF ! )

Now lets look at the data requests, Brazil is again at the top, I wonder if the Brazilian government uses Google as an intelligence service. Pakistan is not even in this list. Israel made 30 requests. Hmmmm…..

I wonder what kind of information Brazil and India requested from Google, I am also surprised at UK and USA governments, the lands of the free people.

 

Gizmodo, where kids gossip on next years garbage

20 Apr

I must admit that I waste an awe-full lot of time on the internets, the web sites to be blamed for this are not so many, youtube, engadget, reddit, aljazeera, dawn.com, etc …

But one web site which I just stopped visiting after I realized that it was run by 16 year olds was gizmodo, the reasons were because they publish too much of apple specific stuff and … well, they sound so immature and most of their posts are kind of idiotic. But they just did another stupid thing recently, and since i dont go their any more, I found about this from reddit

So right now the top two links on reddit are about this, the other link is this

Any ways, back to the point now. I have realized that the best way to stop wasting time on these gadget blogs is just by realizing that life is just too short to waste.

ps: google facebrick if you have a nokia n900, its powered by qfacebookconnect :)

 

The iPhone OS 4.0 Agreement stink.

10 Apr

So the internets are abuzz with the news that the new iphone os 4.0 developer agreement prohibits using any non apple endorsed programming language, framework for iphone/ipad development. This is hardly any thing surprising, given the way apple has been acting ever since jobs came back in control. When they were irrelevant they didn’t have the power to make any rules, now that they have a good market share, they are showing it. It almost feels like a kid who lost a game in his teens taking revenge in his 50′s.

Some people are comparing this with the Window Phone 7 Series and how its limited to .NET and C#, well that’s not exactly the same thing, Windows Phone 7 has no market share as of now, it will be coming to market in the late 2010. Microsoft sets this standard before they have any kind of market share, and besides any language ( php, vb, python ) can be used to create CLR code and that can be used for making apps on wp7 ( yet ).

But I believe apple has every right to do what it is doing. It might be good for the company, but sad for most of the developers. I myself was looking at monotouch as a tool for doing apps for iphone, but I went with objective c instead, it was not that difficult to learn and I think if you are a good c++ programmer objective c would be a piece of cake to learn, in two or three days. Monothouch is also just too expensive in my opinion.

However, like google has said earlier and I believe it myself that webapps are the future way of doing apps. Phonegap for example is an awesome project and it has a lot of potential, what we need now is standardization of web apps / javascripts apis. W3C for example has now standardized the Geolocation api, I think we need similar standard apis for example to access the phone book, sensors etc ….

 

One good thing in Objective-C

21 Feb

While learning about objective-c. I came across a single feature of objective-c which I think if moved to c++ would make for a lot less coding.

Consider this objective c code for a class declaration:

// .h file:
@interface classname {
// instance variables
}
+(void)classMethod;
@end

// .m file:
@implementation classname
-privateFunction1{}
-classMethod { [self privateFunction1]; }
@end

While if you would have to do something similar in c++, this is how you would do it:


// .h file:
class classname
{
public:
void classMethod();

private:
void privateFunction();
}

// .cpp file:

void classname::classMethod() { privateFunction(); }
void classname::privateFunction() {}

Even if a function in a C++ class is private, you still have to declare it in the class declaration. why ?
It would be so much better if all the private functions can just placed in the cpp file, and we dont have to put them in the class declaration.

Objective C has the benefit of using @implementation … @end to figure out such methods. But if in c++ if we just declare a function in the .cpp file and such function is not present in the class declaration, the compiler can know that its a private function. Like so:


// .h file:

class sample
{
public:
void doSomething();

private:
int x;
};

// .cpp file:

void sample::doSomethingPrivately()
{
// has access to member data.
x = 7;
}

void sample::doSomething()
{
/// ...
doSomethingPrivately();
}

 
4 Comments

Posted in c, objective c