Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Compiling for Android on Windows

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Compiling for Android on Windows
Eric Johnson
Member #14,841
January 2013
avatar

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
Member #261
April 2000
avatar

Yes it is.

Eric Johnson
Member #14,841
January 2013
avatar

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
Member #261
April 2000
avatar

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

Matthew Leverton
Supreme Loser
January 1999
avatar

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
Member #14,841
January 2013
avatar

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
Second in Command
February 2005
avatar

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.

They all watch too much MSNBC... they get ideas.

Matthew Leverton
Supreme Loser
January 1999
avatar

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
Member #261
April 2000
avatar

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
Member #14,841
January 2013
avatar

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
Member #261
April 2000
avatar

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

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Trent Gamblin
Member #261
April 2000
avatar

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
Major Reynaldo
May 2007
avatar

Trent Gamblin
Member #261
April 2000
avatar

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
Member #14,841
January 2013
avatar

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
Second in Command
February 2005
avatar

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

They all watch too much MSNBC... they get ideas.

Eric Johnson
Member #14,841
January 2013
avatar

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
Second in Command
February 2005
avatar

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.

They all watch too much MSNBC... they get ideas.

Eric Johnson
Member #14,841
January 2013
avatar

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
Second in Command
February 2005
avatar

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

They all watch too much MSNBC... they get ideas.

Eric Johnson
Member #14,841
January 2013
avatar

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

Arthur Kalliokoski
Second in Command
February 2005
avatar

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.

They all watch too much MSNBC... they get ideas.

Eric Johnson
Member #14,841
January 2013
avatar

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

Trent Gamblin
Member #261
April 2000
avatar

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".

 1   2 


Go to: