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

source code mongose

ndk android
ndk target 32, for 64bit linux
version: android-ndk32-r10-linux-x86_64.tar.bz2

sdk android

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
nano ~/tmp/mongoose/jni/
#insert this code
include $(CLEAR_VARS)

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





# 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



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



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


# 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 (listening_ports value)


Published by


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: Logo

You are commenting using your 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