Build an android c++ eclipse project from a windows batch file

Hi all,

If you’re like me, you still use batch file on windows even if it’s very “old school”.

If you want to compile an android c++ eclipse project from a windows batch file it’s actually pretty simple

1) Have everything (java/SDK/NDK/ant/…) installed and accessible through your windows PATH

2) Don’t use ndk-build but ndk-build.cmd instead.  As it is not an executable but a command file you must add “CALL” otherwise you will break the execution of your current batch file.

3) Don’t use “ant release”, instead use “ant clean release” because the resources are not compatible when you switch from eclipse to ant.

4) The result :

PUSHD ..\myproject\android

call ndk-build.cmd clean
call ndk-build.cmd
call ant clean release

POPD

OSX Open Finder on a specific folder from a c/c++ program

It’s so stupid that I have to write it somewhere. I spent way too much time on this problem ;-)

I just wanted to open the finder app from my c/c++ Application . After a little research on Google I came across the solution (well that’s what I thought) a simple

system ('open mypath')

should do the trick.

I test it in Xcode … Bingo it works, I was so happy !

Unfortunately, when I ran my program outside of XCode (i.e. from the Finder)  => drama. Nothing worked, the “system” function returns me errors. Why ? I still don’t know, is it a privilege problem ? a sandbox problem ? If you got the answer please let me a comment, I’m really curious.
In fact the solution was more complex than expected, Thanks to qtcreator’s source code, It finally ended this way : You have to execute an applescript (via osascript) to tell the finder to open a POSIX file and another one to tell the finder to be in front of all others windows… Are you serious Apple ???


std::string tempPath;
std::string command;
tempPath = currentDir;
command = "osascript -e 'tell app \"Finder\" to open POSIX file \""+ tempPath+"\"'";
system(command.c_str());
command = "osascript -e 'tell application \"Finder\" to activate'";
system(command.c_str());