Compiling for Android on Windows
Eric Johnson

Just as the topic suggests, I'm interested in knowing if it's possible to compile an A5 project for Android on Windows. So, is it?

I appreciate your feedback.

Trent Gamblin

Yes it is.

Eric Johnson

Very nice! Do you have any links to documentation or anything which would assist me in this endeavor? (I didn't see mention of Windows in README_android.txt.)

Trent Gamblin

The instructions are basically the same as in README_android.txt.

Matthew Leverton

I was able to get it working a few weekends ago based on that file (using Ubuntu) and no other prior knowledge.

The whole process is pretty hacky at this point, but it does work if you are able to follow instructions and fill in the missing gaps with a little bit of trial & error.

Eric Johnson

Thanks for the feedback, guys.

I only ask about Windows because I don't feel strong in my knowledge of Linux Ubuntu. Not only that, but I have Ubuntu running in a terrible virtual environment, with lots of bugs and laggard whatnot (I'll probably just do a fresh install soon enough here).

Trent, you say it's basically the same as in README_android.txt, but on Windows I can't use Linux commands (which is my struggle at the moment). Sure, I can download the Windows version of Android's SDK and NDK, and I can set environment variables, but when it comes down to it, I don't see how I'd execute the given commands in Windows. How would I get around that? ???

Arthur Kalliokoski
Quote:

export TC=$HOME/android-toolchain

Windows would use 'set' at the command prompt

"set export TC=$HOME/android-toolchain"

Quote:

$HOME/android-ndk/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=$TC

I haven't see what's in that script, but the Msys thing might help here.

Quote:

mkdir build
cd build
cmake .. -DANDROID_NDK_TOOLCHAIN_ROOT=$TC -DWANT_ANDROID=on \
-DWANT_EXAMPLES=OFF -DWANT_DEMO=OFF \
-DCMAKE_BUILD_TYPE=Debug
make && make install

These should all work as is in the Windows command prompt. You might have to download cmake for windows, and your make command might be different, e.g. mingw-make or similar.

The adb command I've never heard of before.

[EDIT]

The line "make && make install" might need to be broken up into "make" and "make install" as separate commands.

Matthew Leverton

Windows would use 'set' at the command prompt

You could just ignore all of the $HOME and $TC stuff and simply hardcode the directories.

Quote:

The adb command I've never heard of before.

That's part of the Android SDK.

Trent Gamblin

I'm using MSYS here. The one command that I have to run in CMD.EXE is "android" because it's a windows batch file. Luckily you don't have to run that very often so I'm basically only using MSYS unless I set up a new project.

Eric Johnson

I'm always amazed at how helpful and kind this community is. :) However, I ran into issues. After fiddling with setting environment variables for a while, I took Matthew Leverton advice and decided to hard-code where I wanted things to end up, and this was my result:

{"name":"al_001.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/9\/896de9fc50fd0a859c06184898a8179e.png","w":677,"h":511,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/9\/896de9fc50fd0a859c06184898a8179e"}al_001.PNG

Assistance would be much appreciated.

Trent Gamblin

You need to use MSYS to run 'sh' (bash) scripts.

Edgar Reynaldo

When did the windows command prompt window get so fugly?

Trent Gamblin

Looks like Windows 8. I still prefer Windows 7 since it has the best theme.

{"name":"607813","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c89c2b4d703a370b83a8ac68c9ff934e.png","w":988,"h":511,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/8\/c89c2b4d703a370b83a8ac68c9ff934e"}607813

Edgar Reynaldo

I thought git for windows uses a bash shell? The shortcut on my desktop does say git bash...

Trent Gamblin

Depends how you install it, but it can use cmd.exe also. But the problem is its a bash script he's trying to run in cmd.exe.

Eric Johnson

When did the windows command prompt window get so fugly?

Looks like Windows 8. I still prefer Windows 7 since it has the best theme.

Yeah, it's Windows 8 (pretty sweet on touch devices, but lacking on standard desktops).

Back on topic, I installed Cygwin and ran the .sh file with ease; the end result was a folder entitled "android-toolchain" under my C drive. From here I downloaded Allegro 5.1.7 and placed it under C:/android_allegro. I then make a builds directory, went inside of it, and ran the cmake command, but it gave me this error:

{"name":"al_002.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/989555915f0c4669d6914e3fa6f0516a.png","w":677,"h":427,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/8\/989555915f0c4669d6914e3fa6f0516a"}al_002.PNG

Am I in the wrong directory? I can see within the android_allegro folder that CMakeLists.txt exists.

Arthur Kalliokoski

I think those backslashes in the cmake command are supposed to be line breaks, which aren't being honored, try taking them out.

Eric Johnson

I think those backslashes in the cmake command are supposed to be line breaks, which aren't being honored, try taking them out.

Strange. Shouldn't they be \n if they are line-breaks? Anyway, removing the back-slashes furthered progress! Still, I run into errors--this time with CMake itself it seems.

{"name":"al_003.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/7\/77a69b4b71247d0a0a3e3cbc4eda87aa.png","w":677,"h":595,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/7\/77a69b4b71247d0a0a3e3cbc4eda87aa"}al_003.PNG

I'm missing several internal CMake variables. I ran CMake --check-system-vars and it returned "Also check system files when warning about unused or uninitialized variables. CMake Error: The source directory 'C:/android_allegro/build' does not appear to contain CMakeLists.txt." I don't understand why it's looking for the CMakeLists.txt file under the builds directory, when it exists within the root of the android_allegro directory. Shouldn't the two dots preceding the command tell it to search in the directory above the current one?

Arthur Kalliokoski
Sheegoth said:

Shouldn't they be \n if they are line-breaks?

Try it with your C compiler

printf("This is a very long line that doesn't\
 fit in my text editor so the preprocessor will\
 concatenate it by removing the backslashes and hard returns");

[EDIT]

I think you have to run vcvars32.bat (or the Start selection to set MSVC command prompt) to put cl.exe etc. in the path.

Eric Johnson

Try it with your C compiler

printf("This is a very long line that doesn't\
fit in my text editor so the preprocessor will\
concatenate it by removing the backslashes and hard returns");

[EDIT]

I think you have to run vcvars32.bat (or the Start selection to set MSVC command prompt) to put cl.exe etc. in the path.

Aah, makes sense. I was thinking in C++. As for your edit, where would I find these files? I looked under C:\Program Files (x86)\CMake 2.8 and didn't see it there. One thing I do see, however, is that there is a vcvars file under my android_allegro directory, but it is a .c file and not a .bat.

Arthur Kalliokoski

You're using the MSVC compiler and not mingw, right? If you're using MSVC then click the Start | Microsoft Visual C | Command Prompt (approximately) and then cl.exe, nmake.exe etc. will be in the path. If cmake isn't found then, I'd say to search for vcvars(something).bat in the Program Files wherever MSVC is, and copy that somewhere to another name and edit it to provide the proper path. I like to keep a C:\utility directory with all these batch files for compilers etc. where C:\utility is always in the path.

[EDIT]

FWIW, this is what's in "vc32.bat" in my C:utility directory at the moment, I forget exactly what everything does since I hardly ever mess with windows anymore.

"%VS90COMNTOOLS%vsvars32.bat"
set LIB=c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.1\lib;c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.1\lib;c:\prog\allegro-5.0.7-msvc-9.0\lib;"c:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86";c:\prog\alleg_scratchbuild;
set LIBPATH=c:\Windows\Microsoft.NET\Framework\v3.5;c:\Windows\Microsoft.NET\Framework\v2.0.50727;c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\LIB;c:\Windows\Microsoft.NET\Framework\v3.5;c:\Windows\Microsoft.NET\Framework\v2.0.50727;c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\LIB;c:\prog\allegro-5.0.7-msvc-9.0\lib;c:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86;c:\prog\alleg_scratchbuild;
set OGG_LIBRARY=c:\prog\alleg_scratch\lib
set OGG_INCLUDE_DIR=c:\prog\alleg_scratch\include

Just for comparison, this one enables the 32 bit Mingw compiler chain

set MINGDIR=c:\mingw
set C_INCLUDE_PATH=c:\prog\mingw_alg_test\allegro-5.0.7-mingw-4.6.2\include
set path=%path%;c:\mingw\bin

Eric Johnson

Actually, I am using MinGW. Is there any way I could continue with MinGW?

Arthur Kalliokoski

You have to tell cmake you're using Mingw, but I can't remember how to do that at the moment, and I have to go run errands for a few hours pretty soon.

Eric Johnson

Okay. I'll do some research on that then. Have fun with your errands. ;D

Trent Gamblin

Don't use Cygwin, it won't work. Use MSYS. Then do the same thing but add

-G "MSYS Makefiles"

to the CMake command.

EDIT: Actually Cygwin might work to build the Android port, just won't build the Windows port. So try it with -G "Unix Makefiles".

Eric Johnson

Let's forget Cygwin; I now have MSYS. I'm still fairly new to this, so please excuse my obtuse nature.

{"name":"al_004.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/d\/8d766b40e0a3cd6fe046b1f4e472d3b3.png","w":677,"h":283,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/d\/8d766b40e0a3cd6fe046b1f4e472d3b3"}al_004.PNG

Edgar Reynaldo

MSYS gives you a basic unix shell, and ~ is your home directory. You need to cd to the correct directory first, presumably your build directory, and then you do something like this :

cd /c/allegro/android/build
cmake -G "MinGW Makefiles" [BUILD OPTIONS] ..

MinGW Makefiles should work with MSYS as well as MSYS Makefiles, but that will build Windows libraries instead of *nix ones (not sure which you need for Android).

Replace [BUILD OPTIONS] with your build options, obviously, like -DSHARED=off or -DCMAKE_BUILD_TYPE=Release.

Trent Gamblin

Use the same command you use in your last Cygwin post, but ADD the -G.

Eric Johnson

Before I continue, I just want to say that I am incredibly appreciative of everyone who has contributed to this particular topic. ;D Now then, I tried it again, yet the errors persist. Almost there!

{"name":"al_005.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c70f005737d204cb506f332cbaf2ad8.png","w":677,"h":583,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/c\/5c70f005737d204cb506f332cbaf2ad8"}al_005.PNG

I have a few questions:

  1. Does the above command look correct?

  2. Does my directory look correct?

  3. What is your favorite color?

  4. I am using Allegro 5.1.7; is this O.K.?

  5. My build directory should be within my Allegro directory, correct?

Trent Gamblin

It should work if you ADD -DCMAKE_EXECUTABLE_SUFFIX=".exe". I would highly recommend you upgrade to Allegro git though. This particular fix is in there. There are other fixes too. If you don't want to upgrade, at least build WITHOUT the Android native image loader (probably best to do so even if you do upgrade because I haven't tested if it's truly fixed.) To do that you'll need to compile libpng for Android (and libjpeg if you need it.) I'm not sure the best way to do the next step in 5.1.7, but one sure way is to remove the lines in addons/image/CMakeLists.txt for Android that have "HAVE_LIBPNG", "HAVE_LIBJPEG" etc. Remove that whole group of statements. Sorry I can't be more specific. I'd really just recommend you download Allegro git and build libpng/jpeg (if you need them.)

Eric Johnson

I downloaded Allegro from GIT, took your advice, yet am still having issues--I'm terrible with Window's command line and really prefer Ubuntu Linux. I may just scrap Windows from this machine and go strictly Ubuntu soon. I'll look into this now.

Thanks for all of your help though. I'll make a new topic or will reply/update this one if I need help in the future. Godspeed.

Thread #612971. Printed from Allegro.cc