Can't Compile Correctly


scienceman91

Still Fresh
Joined
Jul 27, 2008
Messages
26
I have downloaded and from source the open2x and gph sdks for the gp2x
when i compile my c++ hello world program
path-to-g++ hello.cpp -o hello

it works correctly however when i run in a terminal it just says
hello: hello: cannot execute binary file

and even when i try open2x sdk pre compiled it didn't work

i even professionally put together a project in kdevelop and switched out g++ with the cross compiler and it didn't work

I am using opensuse 11.0 amd64

can anyone help me

I am leaving for vacation Friday and of o haven't figured this out by then i will be incredibly bored
 
Whilst in opensuse and compiling using g++, afterwards type "file hello" and see what it reports. The expected answer would be "ELF executable, ARM". If it says "ELF executable, 386" or similar, your using the wrong compiler.
 
Listen to squidge.

As a summary:
- The GPH SDK and Open2x creates ARM binaries. Only for the Gp2x, they won't work on the PC.
- The standard compiler on your computer (probably) creates 386 binaries. Only for the PC, they won't work on the Gp2x.
- If you use standard libraries you can compile twice to have two different binaries, one with Open2x for the Gp2x and the other one with your standard compiler for your computer. Give different output names!
 
file path/to/hello
returns
path/to/hello: ELF 32-bit LSB executable, ARM, version 1, for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped

I know i am using the right compiler i'm not just using the g++ that came with opensuse i'm using the path to the open2x g++ to compile
 
Umm ok this may seam like a stupid question, but i use ide's to program so

how do you statically link

and

how do you strip
 
to static link: add -static to command line (eg. g++ -static)
to strip, use strip :) strip path/to/hello
 
it still says cannot execute binary file

file hello says
ELF 32-bit LSB executable, ARM, version 1, for GNU/Linux 2.4.3, statically linked, stripped
 
Linux linux-5or2 2.6.25.5-1.1-default #1 SMP 2008-06-07 01:55:22 +0200 x86_64 x86_64 x86_64 GNU/Linux
 
scienceman91, maybe this is a stupid question, but are you trying to run your Gp2x-compiled application on your PC? That will always show a "cannot execute binary file" message :)
 
scienceman91 said:
Linux linux-5or2 2.6.25.5-1.1-default #1 SMP 2008-06-07 01:55:22 +0200 x86_64 x86_64 x86_64 GNU/Linux
Aha! It seems we have found the problem. Sounds like your trying to run your GP2X executables on your PC. Your PC will not run GP2X executables.

(As stated above in the 2nd reply to your original post)

Copy them to an SD card, and run them from your GP2X. Since your doing a hello world app, you'll need to open a shell on the GP2X too, but thats not exactly difficult - there is lots of software to do this (try Termula2x for example).
 
Last edited by a moderator:
no no no no no no

im not an idiot

i upload them to the gp2x sd card duh

and i use sterm to run sh hello, exec hello, and just ./hello and they all say cannot execute binary file ON THE GP2X!!!
 
It's full perms on my pc and the gp2x, my host changes the perms on upload so no one can execute files on the server.

it still tried and it did nothing

and even then doesn't sh and exec ignore that anyway i know ./hello doesn't though
 
scienceman91 said:
It's full perms on my pc and the gp2x, my host changes the perms on upload so no one can execute files on the server.

it still tried and it did nothing

and even then doesn't sh and exec ignore that anyway i know ./hello doesn't though
Your program works fine on the GP2X, it outputs "Hello World!" on stdout, (which you cannot see outside a telnet or serial session, of course)

Classic PEBKAC
 
Last edited by a moderator:
hmmmmmmmmmmmmmmmmmmmmmmm

i am using a terminal program on the gp2x (sterm)

and even if you couldn't see the hello world
it shouldn't say cannot execute

i would say maybe it's because i have the new 4.1 firmware for the f100, but every program runs fine except for mine.

so it has to be a problem with my gp2x, most likely the firmware

any ideas

oh and i won't get your replies until after 7 central standard time

i have to go to tae kwon do
 
Back
Top