Arm-Linux-G++ Doesn't Create Output File


dftruf

Still Fresh
Joined
Aug 9, 2006
Messages
61
I've wrote very simple program:

//++++++++ test.cpp ++++++

int main() {
int a, b;
a = 5;
b = a + 3;
}
//++++++++++++++


Without including any header files. Next, I've used official windows sdk compiler (for arm linux machine) on win XP:
D:\GPH_SDK\tools\gcc-4.0.2-glibc-2.3.6\arm-linux\bin\arm-linux-g++.exe -Wall -O3 -fexceptions -fomit-frame-pointer -fPIC -c test.cpp -o test.o

The compiler doesn't print any errors but doesn't create test.o file too.
What is incorrect ? I don't use any external library and header files in this example, so I don't have to put -L and -I dirs.
 

dftruf

Still Fresh
Joined
Aug 9, 2006
Messages
61
I've added dir to system's path: D:\GPH_SDK\tools\gcc-4.0.2-glibc-2.3.6\arm-linux\bin\ and now it compile.
Does anybody know what other tools from GPH_SDK\tools\gcc-4.0.2-glibc-2.3.6\arm-linux\bin\ the compiler uses for compiling such simple program?
 

hardyx

Member
Joined
Jun 9, 2008
Messages
272
Website
Visit site
GCC is a toolchain wich includes many commands like the preprocessor, the compiler, the linker (ld), make, etc. You can see the process in the makefiles of other applications for Wiz. You must to provide the library and include toolchain directories. The compiler uses system libraries like "libc" that he needs to find.

Your "simple" program does nothing. I'll explain, there is an optimizer that removes the code not used.
If you don't make anything with the values like: printf("b: %d", b ); the optimizer can wipe your code.

You can include "return 0;" at the end, because the main function returns a value.

Test the famous example:

Code:
#include <stdio.h>
 
  int main()
  {
     printf("Hello world\n");
     return 0;
  }
 

dftruf

Still Fresh
Joined
Aug 9, 2006
Messages
61
Hardyx said:
...
Test the famous example:

Code:
#include <stdio.h>
 
  int main()
  {
     printf("Hello world\n");
     return 0;
  }


I don't think that this example will run, without any additional options for linker. Because gp2x don't support stdout terminal in standard way.

I've wrote this test program and launched it on wiz with logview, and stdout.log is empty. So this example doesn't run.

My script for logview:
#++++++++++++++ for_test.gpe +++++++++++++

#! /bin/sh
sync
echo 3 > /proc/sys/vm/drop_caches
/mnt/sd/test/test.gpe > stdout.log 2 > stderr.log
/mnt/sd/logview/logview stderr.log stdout.log
sync
cd /usr/gp2x/
./gp2xmenu

#++++++++++++++++++++++++++++++++++++++++++++++++++++

After executing it, stdout.log and stderr.log is empty, stdout.log should be filled with "Hello world" text. (test.gpe is the compiled example program with printf to stdout)

I have two questions:
1) Why stdout.log is empty?
2) Why this script doesn't work when I don't put space char between #! and /bin/sh at the beginning of the script? (error message is: "Syntax error: word unexpected (expecting ")") "
 
Last edited by a moderator:

crow_riot

Well-Known Member
Joined
Sep 21, 2009
Messages
1,763
Location
.at
did you edit your script on windows? you need to take an editor that supports unix style line endings. i use pspad at home to do so.

you may also launching your program with termula - then you'll see what happens.
 

dftruf

Still Fresh
Joined
Aug 9, 2006
Messages
61
crow_riot said:
did you edit your script on windows? you need to take an editor that supports unix style line endings. i use pspad at home to do so.

you may also launching your program with termula - then you'll see what happens.


I use notepad++ (it supports unix style).
I launched compiled test.gpe on termula and instead of "Hello world" I see "Syntax error: word unexpected (expecting ")") "
 
Last edited by a moderator:
Top