Wednesday, June 6, 2012

Compile git on iPad

Having gcc up and running on an iPad, you should make a symbolic link so that cc points to gcc in /usr/bin (ln /usr/bin/gcc /usr/bin/cc) .

Download and extract the latest source from gitHub

curl –O -k https://nodeload.github.com/git/git/tarball/master

tar xvf master

Build by issuing the following command in the extracted source dir (which I renamed to git):

make NO_PERL=1 NO_TCLTK=1 NO_GETTEXT=1

Sign the app:

ldid –S git

And you are ready to use git to clone the webinos repository Smile 

iPad:~/git root# ./git clone git://github.com/webinos/Webinos-Platform.git ../webinos
Cloning into '../webinos'...
warning: templates not found /var/root/share/git-core/templates
remote: Counting objects:
4297, done.
remote: Compressing objects:
100% (2384/2384), done.
remote: Total
4297 (delta 1827), reused 3944 (delta 1647)
Receiving objects:
100% (4297/4297), 46.08 MiB | 275 KiB/s, done.
Resolving deltas:
100% (1827/1827), done.
Checking out files:
100% (1682/1682), done.

iPad iOS 5.1 “configure: error: connot run C compiled programs.”

I recently tried to compile a program in my iPad which runs iOS 5.1.1. Installing the gcc is quite straight forward and if you follow a slightly updated version of tootallnate’s guide you will easily get to the point of having gcc (get the iOS 5.0 sdk instead of 4.3 mainly). The problem is that Apple changed iOS 5 to run only signed apps and this renders most of the existing configure scripts useless.

Friday, December 16, 2011

Debugging a node.js app in windows (no eclipse)

If you don’t want to install eclipse and google dev tools to debug your node.js app you may use node inspector which is a node.js app that resembles google chrome’s dev tools. You start your node app passing the –debug-brk (or –debug if you don’t care about the first lines of code) and then fire up node inspector and debug the app. I actually have node inspector running all the time and I simply refresh the webpage when I reload the application.

Happy debugging…

Thursday, December 15, 2011

strcasecmp: identifier not found when porting from linux to windows

Ever tried to port from linux to windows and got the :

error C3861: 'strcasecmp': identifier not found

The easiest workaround is to add a  conditional define (visual studio add the –D _WIN32 or _WIN64 depending your OS) and define the following mappings:

#if defined(_WIN32) || defined(_WIN64)
  #define snprintf _snprintf
  #define vsnprintf _vsnprintf
  #define strcasecmp _stricmp
  #define strncasecmp _strnicmp
#endif

Another common missing identifier is the Uint which can be solved adding:

#define uint=unsigned int

Debugging native node modules loading failure on windows

If you ever need to build a module that requires another library (e.g. openssl, ict, expat etc) you may receive an “Out of memory” error when you require the file. This is unfortunately a generic error on windows but you can fire up visual studio and debug node (attaching to a process) and you can can see there the exact system error number (sys_errno) by adding a breakpoint in deps\uv\src\win\error.c when uv translates the error code (uv_translate_sys_error).

Wednesday, December 14, 2011

Node.js modules cross platform compilation using gyp

Update: I have made a pull request where you can find the updated tools discussed in this article, located here
Node.js has been using waf (node-waf) to configure and build modules up to version 0.4. From v0.6 and on, the team has moved on to gyp (Generate Your Projects) which seems to be a bit more promising when it comes to cross platform compilation. This post shows how to create a simply gyp file to build your own custom native node.js modules and provides some scripts to automate the project generation process.

Friday, December 9, 2011

Building a simple native nodejs module on windows from command line

Setting up a visual studio project to just build a simple native hello world node module is an overkill and there is a simpler way to do that by using the visual studio command prompt directly. Here you may find the required commands you have to issue, plus a vcbuild.bat file that does the whole thing at once.