Note that there are some explanatory texts on larger screens.

plurals
  1. POInclude Boost C++ library in android
    primarykey
    data
    text
    <p>I have been trying to marry Boost and android on windows for long time and tried lot of approaches but still no luck. I want to make a sample program using Boost library in android. I am following this tutorial <a href="http://www.codexperiments.com/android/2011/05/tips-tricks-building-boost-with-ndk-r5/" rel="noreferrer">here.</a> </p> <p>As this tutorial suggested i have kept my Boost lib in ****(Android NDK)\sources\boost_1_44_0**** compiled it successfully.</p> <p>Then i made an <strong>Android.mk</strong> file inside <strong>sources/boost_1_44_0</strong> and made the entry of each library which i want to use. In this case lib. file is <strong>libboost_date_time-gcc-mt-s-1_44.a</strong> available in <strong>boost_1_44_0/android/lib/</strong><br> Here is the content of <strong>Android.mk</strong> file. </p> <pre><code>LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:= boost_date LOCAL_SRC_FILES:= boost_1_44_0/android/lib/libboost_date_time-gcc-mt-s-1_44.a LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) include $(PREBUILT_STATIC_LIBRARY) </code></pre> <p>Now the next step is to make an <strong>Android.mk</strong> file in my project directory, inside <strong>jni</strong> folder.(this is to create a shared library.). Here are its contents. </p> <pre><code>LOCAL_PATH := $(call my-dir) include $(call all-subdir-makefiles) include $(CLEAR_VARS) # Here we give our module name and source file(s) LOCAL_LDLIBS := -llog -ldl LOCAL_MODULE := ndkfoo LOCAL_SRC_FILES := ndkfoo.cpp LOCAL_STATIC_LIBRARIES := boost_date include $(BUILD_SHARED_LIBRARY) $(call import-module,boost_1_44_0) </code></pre> <p>Here is the Application.mk file placed on the same location, inside <strong>jni</strong> folder. Contents of Application.mk file are as follows: </p> <pre><code>APP_STL = gnustl_static #(or APP_STL = stlport_static as required) APP_CPPFLAGS = -fexceptions </code></pre> <p>And finally here is my <strong>ndkfoo.cpp</strong> file</p> <pre><code>#include &lt;string.h&gt; #include &lt;jni.h&gt; #include &lt;stdio.h&gt; #include &lt;boost/date_time.hpp&gt; using namespace boost::gregorian; void Java_com_ndkfoo_NdkfooActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) { date weekstart(2002,Feb,1); } </code></pre> <p>this program might be incorrect but the problem is that it does not recognize any boost headers or function. and i always get compilation error. </p> <p>Is there something i am missing or doing incorrectly? Any help would be really appreciated. </p> <p><strong>EDIT:</strong> <em>This question contains everything you would need to include Boost library in android. For more tips look at my answer below. Hopefully this would also work for you.</em></p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload