compile – set – run mongoose web server in android (emulator)

source code mongose
http://mongoose.googlecode.com/files/mongoose-3.8.tgz

ndk android
https://developer.android.com/tools/sdk/ndk/index.html
ndk target 32, for 64bit linux
version: android-ndk32-r10-linux-x86_64.tar.bz2

sdk android
https://developer.android.com/sdk/index.html

extract ndk to ~/tmp/android-ndk-r10
extract mongoses-3.8 to ~/tmp/mongoose
extract sdk to ~/tmp/android-sdk-linux

# create folder for ndk project in mongoose folder
mkdir ~/tmp/mongoose/jni
# move all c code to jni folder
mv ~/tmp/mongoose/*.c ~/tmp/mongoose/jni
# create file Android.mk
nano ~/tmp/mongoose/jni/Android.mk
#insert this code
include $(CLEAR_VARS)

LOCAL_MODULE    := mongoose
LOCAL_SRC_FILES := main.c mongoose.c

include $(BUILD_EXECUTABLE)

 

mongoose-jni-file

 

# make sure ndk-build is executeable
chmod +x ~/tmp/android-ndk-r10/ndk-build
# set temporary value NDK_PROJECT_PATH
export NDK_PROJECT_PATH=~/tmp/mongoose/
# compile
~/tmp/android-ndk-r10/ndk-build -C ~/tmp/mongoose

# if error hapens " mongoose.c not found in ..."
cp ~/tmp/mongoose/jni/*.c ~/tmp/android-ndk-r10/sources/cxx-stl/system/
# and compile again
~/tmp/android-ndk-r10/ndk-build -C ~/tmp/mongoose

android-ndk-sources-css-stl-system

 

if success you will find the file in ~/tmp/mongoose/libs/armeabi

 

mongoose-execute-file

create and run emulator, emulator api level 18 (because more faster loading)


# make sure it executeable
chmod +x ~/tmp/android-sdk-linux/tools/android
# run avd manager
~/tmp/android-sdk-linux/tools/android

avd2


# go to adb file
cd ~/tmp/android-sdk-linux/platform-tools
# make sure it executeable
chmod +x adb
# push to local android emulator
./adb push ~/tmp/mongoose/libs/armeabi/mongoose /data/local/mongoose38

# set monggose38 to executable file
./adb shell chmod 751 /data/local/mongoose38

# create config file for mongoose
./adb shell echo "document_root    /data/local/web" > /data/local/mongoose.conf
./adb shell echo "listening_ports 8080" >> /data/local/mongoose.conf
./adb shell echo "index_files index.html,home.html" >> /data/local/mongoose.conf
./adb shell echo "enable_directory_listing yes" >> /data/local/mongoose.conf

# create folder for website
./adb shell mkdir /data/local/web

# create index.html for default
./adb shell echo "<h1>ini index HTML</h1>" > /data/local/web/index.html

# run mongose at android emulator
./adb shell ./data/local/mongoose38

run browser to 127.0.0.1:8080 (listening_ports value)
mongoose-android

Published by

G3n1k

just to remember what i had known :)

One thought on “compile – set – run mongoose web server in android (emulator)”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s