Open shifaz opened 9 years ago
you need to read http://curl.haxx.se/libcurl/using/curl-config.html if your code uses libcurl try it:
$ `curl-config --cc --cflags` ${CFLAGS} -o example example.c `curl-config --libs` ${LDFLAGS}
OR:
$ gcc `curl-config --cflags` ${CFLAGS} -o example example.c `curl-config --libs` ${LDFLAGS}
Did as you have suggested. Its still showing errors about missing libs.
/storage/.../../C4droid_EXT $ arm-linux-androideabi-gcc -I/mnt/sdcard/C4droid_EXT/include -o example simple_curl.c -L/mnt/sdcard/C4droid_EXT/lib -lcurl -lssh2 -lssl -lcrypto -lz
/data/data/com.n0n3m4.droidc/files/gcc/bin/../lib/gcc/arm-linux-androideabi/4.9.1/../../../../arm-linux-androideabi/bin/ld: warning: libm.so, needed by /mnt/sdcard/C4droid_EXT/lib/libcurl.so, not found (try using -rpath or -rpath-link)
/data/data/com.n0n3m4.droidc/files/gcc/bin/../lib/gcc/arm-linux-androideabi/4.9.1/../../../../arm-linux-androideabi/bin/ld: warning: libstdc++.so, needed by /mnt/sdcard/C4droid_EXT/lib/libssl.so, not found (try using -rpath or -rpath-link)
/storage/.../../C4droid_EXT $
Because you are trying to compile without flags ${CFLAGS} and ${LDFLAGS} ,just add the flags, as I wrote above.
Thanks a lot for the help. Really appreciate it.
I got it to compile, but I also get an error saying Failed to copy file
when compiled from C4droid using a Makefile.
Because of the permission issues Im unable to execute the binary using any Terminal App.
If you can help, my question is, will it be possible to embed the binary in a Activity just like the hello world example supplied with C4droid.
You have 'Note 4' with android 5, right? С4droid-Shell not fully compatible with Android 5. I'm not sure, but I think you need to compile with additional flags -fPIE -pie like so:
$ gcc `curl-config --cflags` ${CFLAGS} -fPIE -pie -o example example.c `curl-config --libs` ${LDFLAGS}
maybe then you will be able to execute the binary. To answer your question: libcurl-code to be compiled using C4droid-Shell is not static and will only work in the C4droid-Shell P.S. Devices with the android 5 have enough memory to install Linux, there is a need-to C4droid-Shell?
I have similar error:
export PATH=/busybox-virtual:/data/data/com.n0n3m4.droidc/files/:/data/data/com.n0n3m4.droidc/files/gcc/bin:/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/bin/:$PATH
export CC="arm-linux-androideabi-gcc -I/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/include/ncurses"
export CXX="arm-linux-androideabi-g++ -I/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/include/ncurses"
export SHELL="/data/data/com.n0n3m4.droidc/files/busybox sh"
cd "/storage/emulated/0/Work/stocks/"
make CC="$CC" CXX="$CXX" SHELL="$SHELL"
echo "errorcode:$?"
echo "exit""term"
exit
/ $ export PATH=/busybox-virtual:/data/data/com.n0n3m4.droidc/files/:/data/data/com.n0n3m4.droidc/files/gcc/bin:/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/bin/:$PATH
/ $ export CC="arm-linux-androideabi-gcc -I/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/include/ncurses"
/ $ export CXX="arm-linux-androideabi-g++ -I/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/include/ncurses"
/ $ export SHELL="/data/data/com.n0n3m4.droidc/files/busybox sh"
/ $ cd "/storage/emulated/0/Work/stocks/"
/storage/emulated/0/Work/stocks $ make CC="$CC" CXX="$CXX" SHELL="$SHELL"
mkdir -p ./bin/
arm-linux-androideabi-g++ -I/data/data/com.n0n3m4.droidc/files/gcc/arm-linux-androideabi/include/ncurses -I/mnt/sdcard/C4droid_EXT/include main.cpp download.cpp -L/mnt/sdcard/C4droid_EXT/lib -Wall -Wextra -pedantic -O3 -std=c++11 -o ./bin/bot -lcurl -lssh2 -lssl -lcrypto -lz
/data/data/com.n0n3m4.droidc/files/gcc/bin/../lib/gcc/arm-linux-androideabi/4.9.1/../../../../arm-linux-androideabi/bin/ld: warning: libstdc++.so, needed by /mnt/sdcard/C4droid_EXT/lib/libssl.so, not found (try using -rpath or -rpath-link)
/storage/emulated/0/Work/stocks $ echo "errorcode:$?"
errorcode:0
/storage/emulated/0/Work/stocks $ echo "exit""term"
exitterm
I found only libstdc++.a in c4droid folder.
you need to add flag -Wl,-allow-shlib-undefined ( -lcurl -lssh2 -lssl -lcrypto -lz -Wl,-allow-shlib-undefined)
Or simply:
`curl-config --libs` ${LDFLAGS}
ok, now I get
CANNOT LINK EXECUTABLE: could not load library "libcurl.so.5" needed by "/data/data/com.n0n3m4.droidc/files/temp"; caused by library "libcurl.so.5" not found
at the memnent it starts. At least it's compiling now.
simply add -L/data/data/com.n0n3m4.droidc/usr/lib P.S. all you need is a ${CFLAGS} and ${LDFLAGS}.
It is added. And the file is there.
if you are trying to compile something in the C4droid without using C4droid-Shell, but using his library, you should do it with -I/sdcard/C4droid_EXT/include -I/data/data/com.n0n3m4.droidc/usr/include and with
-L/data/data/com.n0n3m4.droidc/usr/lib -L/mnt/sdcard/C4droid_EXT/lib
and redefine variables LD_LIBRARY_PATH like so:
export LD_LIBRARY_PATH="/data/data/com.n0n3m4.droidc/usr/lib:/vendor/lib:/system/lib"
may have to change other variables all environment variables can be found in c4dsh.c or in /data/data/com.n0n3m4.droidc/files/.C4dENV when compiling with the C4droid-Shell environment variables are already set,only need to use ${CFLAGS} and ${LDFLAGS} flags
After that I tried compiling sample curl code, its giving the following error. Please help.