Look at mine and configure where needed

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := crypto-prebuilt
LOCAL_SRC_FILES := libcrypto.a
TARGET_ABI := android-8-armeabi
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := ssl-prebuilt
LOCAL_SRC_FILES := libssl.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := appname #will turn into libappname
LOCAL_SRC_FILES := main.c
LOCAL_CFLAGS    := -Wextra -O3
LOCAL_LDFLAGS   := -llog
LOCAL_STATIC_LIBRARIES := crypto-prebuilt ssl-prebuilt
include $(BUILD_SHARED_LIBRARY)

On Mon, Sep 17, 2012 at 7:45 PM, Indtiny s <indt...@gmail.com> wrote:
> Hi,
> Thanks.. I have  generated the static libraries and pointed to the those
> libraries in my application android make .
>
> Below is the Android.mk file for my application which uses the curl and
> openssl , Here do I need to   build the static library separately   for the
> openssl or  have I followed the correct way ..?
>
>
> LOCAL_PATH:= $(call my-dir)
>
> ANDROID_ROOT := /home/chethan/Android/openssl
> CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs
> -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal
> -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels
> -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers
> -DHAVE_CONFIG_H
>
> include $(CLEAR_VARS)
> include $(LOCAL_PATH)/curl/lib/Makefile.inc
> LOCAL_MODULE := static-curl
> LOCAL_SRC_FILES := $(addprefix curl/lib/,$(CSOURCES))
> LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include $(LOCAL_PATH)/curl/lib
> $(LOCAL_PATH)/ares $(ANDROID_ROOT)/openssl/include
> LOCAL_CFLAGS += $(CFLAGS) -DHAVE_CONFIG_H
> LOCAL_STATIC_LIBRARIES := static-ares
> LOCAL_LDFLAGS := -lssl -lcrypto -lz -L$(ANDROID_ROOT)/openssl/libs/armeabi
> -L/Android/android-ndk-r8/platforms/android-4/arch-arm/usr/libarget/product/generic/system/lib
> include $(BUILD_STATIC_LIBRARY)
>
>
>
> # include $(BUILD_SHARED_LIBRARY)
> include $(CLEAR_VARS)
> LOCAL_MODULE := curl
> LOCAL_SRC_FILES := curl.c
> LOCAL_STATIC_LIBRARIES := static-curl
> LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include $(LOCAL_PATH)/curl/lib
> LOCAL_CFLAGS += -Wall
> LOCAL_LDFLAGS += -llog -lssl -lcrypto -lz
> -L$(ANDROID_ROOT)/openssl/libs/armeabi
> -L$(ANDROID_ROOT)/openssl/obj/local/armeabi
>
> include $(BUILD_SHARED_LIBRARY)
>
>
> On Mon, Sep 17, 2012 at 7:47 AM, farmdve data.bg <farm...@data.bg> wrote:
>>
>> Check the obj/local/armeabi folder for the static libraries.
>>
>> On Mon, Sep 17, 2012 at 7:02 AM, Indtiny s <indt...@gmail.com> wrote:
>> > Hi,
>> > Can you pls tell me how  to genearte the the static library from the
>> > android-openssl (from the link which you have sent .!
>> >
>> > I tried to edit SHARED to STATIC in the  Android.mk file at both ssl and
>> > crypto , but that did nt create any static library ..!
>> >
>> >
>> >
>> > On Sun, Sep 16, 2012 at 11:39 PM, farmdve data.bg <farm...@data.bg>
>> > wrote:
>> >>
>> >> Trust me, I tried to load the shared libraries as well, but failed.
>> >> Statically linking was the only way to ensure my application uses the
>> >> latest OpenSSL regardless of Android version(though my ABI is set to
>> >> API level 8).
>> >>
>> >> On Sat, Sep 15, 2012 at 1:18 PM, Indtiny s <indt...@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > Actually in my  java application I will load all three shared libries
>> >> > (ssl,crypto and curl)  ...  Hence Iam trying build all libs as shared
>> >> > .
>> >> >
>> >> > I tried to debug it as per your input , now I am getting the response
>> >> > as
>> >> > 1 i
>> >> > .e  CURLE_UNSUPPORTED_PROTOCOL (1)  when I tried to execute the https
>> >> > .
>> >> >
>> >> >
>> >> >
>> >> > I think still the openssl is not included properly ..!!
>> >> >
>> >> >
>> >> >
>> >> > I dunno where I have gone wrong .
>> >> >
>> >> >
>> >> >
>> >> > Rgds
>> >> >
>> >> > Indu
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Sat, Sep 15, 2012 at 1:04 AM, farmdve data.bg <farm...@data.bg>
>> >> > wrote:
>> >> >>
>> >> >> Try using LogCat by connecting an Android device via USB, or
>> >> >> launching
>> >> >> an emulator and opening a new Command Prompt for Windows or Terminal
>> >> >> instance in linux and type adb logcat.
>> >> >> Then launch the app and look at the output.
>> >> >>
>> >> >> You see, Android ships with OpenSSL, but the version is usually
>> >> >> quite
>> >> >> old. You need to compile OpenSSL 1.0.1c as static and link
>> >> >> statically
>> >> >> to use the new library.
>> >> >>
>> >> >> On Fri, Sep 14, 2012 at 9:14 PM, Indtiny s <indt...@gmail.com>
>> >> >> wrote:
>> >> >> > Hi,
>> >> >> > I have just ran ndk-build for the code
>> >> >> > https://github.com/aluvalassuman/OpenSSL1.0.1cForAndroid  and it
>> >> >> > generated
>> >> >> > the two shared libraries in libs/ floder which I required ,
>> >> >> > libcrypto.so
>> >> >> > and
>> >> >> > libssl.so( as build say these are shared libarray)  I just
>> >> >> > included
>> >> >> > them
>> >> >> > in
>> >> >> > the curl code as prebuilt shared library(edited now to shared in
>> >> >> > the
>> >> >> > android
>> >> >> > make) ,  then Since I need to include the curl with openssl in my
>> >> >> > java
>> >> >> > code
>> >> >> > I want to build curl as shared library only  .. I just changed my
>> >> >> > android
>> >> >> > curl make to shared   ..
>> >> >> > And sorry it was  System.loadLibrary("curltest"); only ..  but
>> >> >> > still
>> >> >> > I'm
>> >> >> > not
>> >> >> > getting the any response from the curl ...? am I following the
>> >> >> > correct
>> >> >> > way
>> >> >> > to use the openssl , becoz when I test the curl alone I get the
>> >> >> > proper
>> >> >> > http
>> >> >> > page requested ... !
>> >> >> >
>> >> >> > Rgds
>> >> >> > Indu
>> >> >> >
>> >> >> >
>> >> >> > On Fri, Sep 14, 2012 at 1:54 PM, farmdve data.bg <farm...@data.bg>
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> It's not clear if you built libcurl as a static library to begin
>> >> >> >> with.
>> >> >> >> And not clear if you built OpenSSL as a static or shared library.
>> >> >> >>
>> >> >> >> And you must load curltest(as that is the name of the module) not
>> >> >> >> curl.
>> >> >> >>
>> >> >> >> On Fri, Sep 14, 2012 at 8:28 PM, Indtiny s <indt...@gmail.com>
>> >> >> >> wrote:
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > Hi,
>> >> >> >> >
>> >> >> >> > yes I'm able to built the openssl1.0.1c version for android and
>> >> >> >> > got
>> >> >> >> > the
>> >> >> >> > shared libraries .
>> >> >> >> >
>> >> >> >> > Now I want to use the same with curl , first I built simple
>> >> >> >> > curl
>> >> >> >> > application
>> >> >> >> > and tested and it worked now I tried to include the openssl .
>> >> >> >> > below is the android.mk file which I have written to include
>> >> >> >> > openssl
>> >> >> >> > libraries for the curl code .
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > LOCAL_PATH:= $(call my-dir)
>> >> >> >> >
>> >> >> >> > CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline \
>> >> >> >> >  -Wnested-externs -Wmissing-declarations -Wmissing-prototypes
>> >> >> >> > -Wno-long-long
>> >> >> >> > \
>> >> >> >> >  -Wfloat-equal -Wno-multichar -Wsign-compare
>> >> >> >> > -Wno-format-nonliteral \
>> >> >> >> >  -Wendif-labels -Wstrict-prototypes
>> >> >> >> > -Wdeclaration-after-statement
>> >> >> >> > \
>> >> >> >> >  -Wno-system-headers -DHAVE_CONFIG_H
>> >> >> >> >
>> >> >> >> > include $(CLEAR_VARS)
>> >> >> >> >
>> >> >> >> > ## Crypto lib
>> >> >> >> > include $(CLEAR_VARS)
>> >> >> >> > LOCAL_MODULE := xcryptox
>> >> >> >> > LOCAL_SRC_FILES := openssl/lib/libcrypto.so
>> >> >> >> > LOCAL_C_INCLUDES := $(LOCAL_PATH)/openssl/includes/openssl
>> >> >> >> > include $(PREBUILT_SHARED_LIBRARY)
>> >> >> >> > #
>> >> >> >> > ### SSL lib
>> >> >> >> > include $(CLEAR_VARS)
>> >> >> >> > LOCAL_MODULE := xsslx
>> >> >> >> > LOCAL_SRC_FILES := openssl/libssl/lib/libssl.so
>> >> >> >> > LOCAL_C_INCLUDES := $(LOCAL_PATH)/openssl/includes/openssl
>> >> >> >> > include $(PREBUILT_SHARED_LIBRARY)
>> >> >> >> >
>> >> >> >> > include $(LOCAL_PATH)/curl/lib/Makefile.inc .
>> >> >> >> >
>> >> >> >> > LOCAL_SRC_FILES := $(addprefix curl/lib/,$(CSOURCES))
>> >> >> >> > LOCAL_CFLAGS += $(CFLAGS)
>> >> >> >> > LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include/
>> >> >> >> >
>> >> >> >> > LOCAL_COPY_HEADERS_TO := libcurl
>> >> >> >> > LOCAL_COPY_HEADERS := $(addprefix
>> >> >> >> > curl/include/curl/,$(HHEADERS))
>> >> >> >> >
>> >> >> >> > LOCAL_MODULE:= libcurl
>> >> >> >> >
>> >> >> >> > include $(BUILD_STATIC_LIBRARY)
>> >> >> >> >
>> >> >> >> > # Build shared library now
>> >> >> >> > # curltest
>> >> >> >> >
>> >> >> >> > include $(CLEAR_VARS)
>> >> >> >> >
>> >> >> >> > LOCAL_MODULE := curltest
>> >> >> >> > LOCAL_SRC_FILES := curltest.c
>> >> >> >> > LOCAL_STATIC_LIBRARIES := libcurl
>> >> >> >> > LOCAL_C_INCLUDES += $(LOCAL_PATH)/curl/include
>> >> >> >> > include $(BUILD_SHARED_LIBRARY)
>> >> >> >> >
>> >> >> >> > And below is my C curtest code with ssl include .
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > #include <string.h>
>> >> >> >> > #include <jni.h>
>> >> >> >> > #include <stdio.h>
>> >> >> >> > #include <stdlib.h>
>> >> >> >> > #include "curl_config.h"
>> >> >> >> > #include "curl/curl.h"
>> >> >> >> >
>> >> >> >> > typedef struct pageInfo_t {
>> >> >> >> >   char *data;
>> >> >> >> >   int  len;
>> >> >> >> > } pageInfo_t;
>> >> >> >> >
>> >> >> >> > static size_t
>> >> >> >> > HTTPData(void *buffer, size_t size, size_t nmemb, void
>> >> >> >> > *userData)
>> >> >> >> > {
>> >> >> >> >   int len = size * nmemb;
>> >> >> >> >   pageInfo_t *page = (pageInfo_t *)userData;
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >   if (buffer && page->data && (page->len + len < (16 * 1024)) )
>> >> >> >> > {
>> >> >> >> >     memcpy(&page->data[page->len], buffer, len);
>> >> >> >> >     page->len += len;
>> >> >> >> >   }
>> >> >> >> >   return len;
>> >> >> >> > }
>> >> >> >> >
>> >> >> >> >    //Inteface funciton that will recieve web page fom Java
>> >> >> >> > jstring
>> >> >> >> > Java_com_mtterra_curltest_curltest_JNIGetWebpage( JNIEnv* env,
>> >> >> >> >                                                jobject
>> >> >> >> > entryObject,
>> >> >> >> >       jstring webpageJStr )
>> >> >> >> > {
>> >> >> >> >   pageInfo_t page;
>> >> >> >> >   CURL *curl;
>> >> >> >> >   CURLcode res;
>> >> >> >> >   char *buffer;
>> >> >> >> >
>> >> >> >> >   static const char *pCertFile =
>> >> >> >> > "/sdcared/indu/openssl/testcert.pem";
>> >> >> >> >   static const char
>> >> >> >> > *pCACertFile="/sdcared/indu/openssl/cacert.pem";
>> >> >> >> >
>> >> >> >> >   const char *pKeyName;
>> >> >> >> >   const char *pKeyType;
>> >> >> >> >
>> >> >> >> >   const char *pEngine;
>> >> >> >> >   const jbyte *webpage;
>> >> >> >> >   pKeyName  = "/sdcared/indu/openssl/testkey.pem";
>> >> >> >> >   pKeyType  = "PEM";
>> >> >> >> >   pEngine   = NULL;
>> >> >> >> >   webpage = (*env)->GetStringUTFChars(env, webpageJStr, NULL);
>> >> >> >> >   if (webpage == NULL) {
>> >> >> >> >       return NULL; /* OutOfMemoryError already thrown */
>> >> >> >> >   }
>> >> >> >> >
>> >> >> >> >   page.data = (char *)malloc(16 * 1024);
>> >> >> >> >   page.len = 0;
>> >> >> >> >   if (page.data)
>> >> >> >> >     memset(page.data, 32, 16 * 1024);
>> >> >> >> >
>> >> >> >> >   buffer = (char *)malloc(1024);
>> >> >> >> >
>> >> >> >> >   curl = curl_easy_init();
>> >> >> >> >   if(curl) {
>> >> >> >> >     curl_easy_setopt(curl, CURLOPT_URL, webpage);
>> >> >> >> >     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPData);
>> >> >> >> >     curl_easy_setopt(curl, CURLOPT_WRITEDATA, &page);
>> >> >> >> >
>> >> >> >> >       /* since PEM is default, we needn't set it for PEM */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
>> >> >> >> >
>> >> >> >> >       /* set the cert for client authentication */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_SSLCERT,pCertFile);
>> >> >> >> >
>> >> >> >> >       /* if we use a key stored in a crypto engine,
>> >> >> >> >          we must set the key type to "ENG" */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,pKeyType);
>> >> >> >> >
>> >> >> >> >       /* set the private key (file or ID in engine) */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_SSLKEY,pKeyName);
>> >> >> >> >
>> >> >> >> >       /* set the file with the certs vaildating the server */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_CAINFO,pCACertFile);
>> >> >> >> >
>> >> >> >> >       /* disconnect if we can't validate server's cert */
>> >> >> >> >       curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >     res = curl_easy_perform(curl);
>> >> >> >> >         /* always cleanup */
>> >> >> >> >     curl_easy_cleanup(curl);
>> >> >> >> >     (*env)->ReleaseStringUTFChars(env, webpageJStr, webpage);
>> >> >> >> >     if(res == 0) {
>> >> >> >> >       if (buffer) {
>> >> >> >> >         page.data[page.len < 256 ? page.len : 256] = '\0';
>> >> >> >> > sprintf(buffer, "pagedata(%d): %s. done.\n", page.len,
>> >> >> >> > page.data);
>> >> >> >> >         return (*env)->NewStringUTF(env, buffer);
>> >> >> >> >       }
>> >> >> >> >     }
>> >> >> >> >     sprintf(buffer, "Result %d", res);
>> >> >> >> >     return (*env)->NewStringUTF(env, buffer);
>> >> >> >> >    } else {
>> >> >> >> >       return (*env)->NewStringUTF(env, "Unable to init cURL");
>> >> >> >> >    }
>> >> >> >> > }
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > I tried to run this but I get the response as just Result at
>> >> >> >> > the
>> >> >> >> > my
>> >> >> >> > java
>> >> >> >> > application code  ..  is the above method is the proper way to
>> >> >> >> > include
>> >> >> >> > the
>> >> >> >> > openssl in android..?
>> >> >> >> > in my java code I'm just loading  System.loadLibrary("curl");
>> >> >> >> >
>> >> >> >> > Rgds
>> >> >> >> > Indu
>> >> >> >>
>> >> >> >>
>> >> >> >> ______________________________________________________________________
>> >> >> >> OpenSSL Project
>> >> >> >> http://www.openssl.org
>> >> >> >> User Support Mailing List
>> >> >> >> openssl-users@openssl.org
>> >> >> >> Automated List Manager
>> >> >> >> majord...@openssl.org
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> ______________________________________________________________________
>> >> >> OpenSSL Project
>> >> >> http://www.openssl.org
>> >> >> User Support Mailing List
>> >> >> openssl-users@openssl.org
>> >> >> Automated List Manager
>> >> >> majord...@openssl.org
>> >> >
>> >> >
>> >> ______________________________________________________________________
>> >> OpenSSL Project                                 http://www.openssl.org
>> >> User Support Mailing List                    openssl-users@openssl.org
>> >> Automated List Manager                           majord...@openssl.org
>> >
>> >
>> ______________________________________________________________________
>> OpenSSL Project                                 http://www.openssl.org
>> User Support Mailing List                    openssl-users@openssl.org
>> Automated List Manager                           majord...@openssl.org
>
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to