• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps executing self-compiled c/c++ code in connectbot: Syntax error: word unexpected

piggebu

Lurker
Hi all,
(see at the end for setup and device info)

I am trying to compile my own c/c++ code and run it on my android phone.

I got the android toolchain and the program (hello world, "test" binary) compiles:
./agcc -c -o test hello.cpp
file test
test: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

The program executable is "test". I copy it to my android to /data (since other folders apparently do not have execution permission yielding the "permission denied" error when trying to execute) and do "chmod a+x test"

When I start connectbot on my phone, navigate to /data and do "./test" then I get the error: Syntax error: word unexpected (expecting ")")
As if connectbot would try to execute this binary as a shell script.

In principle, a step-by-step manual how to compile and run c/c++ code on android would be available
But I get this strange error mentioned above.

any ideas?




setup:
=====
Phone: Samsung Galaxy S2
Android: 2.3.4
Kernel: GINGERBREAD.XWKI4 (rooted, works all fine)

Crosscompile Toolchain: from google
Using agcc script from "plausible . org/andy/agcc"
Exporting: export PATH=[PathToToolchain]/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH

Hello World example:
// hello.cpp
#include <stdio.h>

int main()
{
int a=1;
printf("hello %d",a);
return 0;
}

compiling with: ./agcc -c -o test hello.cpp
 
Back
Top Bottom