Curl
Download the Curl source code [URL]
Create an Android project
Create an Activity with the code as below
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = new TextView(this);
tv.setText(JNIGetWebpage("www.baidu.com") );
setContentView(tv);
}
public native String JNIGetWebpage(String webpage);
static {
System.loadLibrary("curltest");
}
}
Download curltest.tar.gz
- Unpack cURL into $NDKROOT/apps/curltest/jni/curl
- Copy curltest/jni/curlbuild.h to curltest/jni/curl/include/curl
- Copy curltest/jni/curl_config.h to curltest/jni/curl/lib
Copy the related the Application.mk and Android.mk to the right place.
CD to the root path of the project
$NDK/ndk-build -B V=1
Opening AndroidManifest.xml, Add the line into the file
<uses-permission android:name=”android.permission.INTERNET”/>
Run the project
Reference:
成功在android平台用ndk上编译libcurl+openssl支持https
Android上使用curl(libcurl),无法连接Internet,couldn’t resolve host name or couldn’t connect to server
Windows平台用NDK成功移植编译curl到Android