Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Compiling C with VMware
« previous next »
  • Print
Pages: [1] 2

Author Topic: Compiling C with VMware  (Read 4380 times)

Offline mschneider

  • Member
  • *
  • Posts: 235
Compiling C with VMware
« on: August 03, 2007, 06:37:37 PM »
I'm trying to learn how to code in C. So i wrote a very simple plugin and tried to compile it in the VMware image using "cc file.c"
I get a ton of errors when compiling and get no output file (no surprise there).
I even just tried writing a simple helloworld
Code: [Select]
main()
{
    printf("Hello, world\n")
}

I get all of the same errors. Is the VMware image just not set up to compile like that (if it isn't does anyone have any suggestions about what i could use to compile) or am i doing something wrong?
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Compiling C with VMware
« Reply #1 on: August 03, 2007, 06:44:58 PM »
Depends what the error is.  If its " error: expected ; before } token", then its because you didn't put a semicolon after you printf statement.

Since the vmware image can compile rockbox, I doubt the c compiler is broken.  If adding the semicolon doesn't fix it, post the log from your command window.
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #2 on: August 03, 2007, 07:18:25 PM »
sorry, there was a semicolon there (i wasnt copy/pasting my code). Here are the errors i get:

Code: [Select]
user@debian:~$ cc hello.c
hello.c:1: error: syntax error before '{' token
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:1: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2:24: too many decimal points in number
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: stray '\' in program
hello.c:2: error: syntax error before "par"
hello.c:3: error: stray '\' in program
hello.c:3: error: syntax error before '{' token
hello.c:3: error: stray '\' in program
hello.c:4: error: stray '\' in program
hello.c:5: error: stray '\' in program
hello.c:5: error: stray '\' in program
hello.c:7:1: warning: null character(s) ignored
hello.c:7:1: warning: no newline at end of file
Logged

Offline tdtooke

  • Member
  • *
  • Posts: 151
Re: Compiling C with VMware
« Reply #3 on: August 03, 2007, 08:43:41 PM »
Do you have #include stdio.h in there somewhere?
« Last Edit: August 03, 2007, 08:45:26 PM by tdtooke »
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #4 on: August 03, 2007, 09:02:33 PM »
Why should i have to? Its just a simple printf statement.
Logged

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Compiling C with VMware
« Reply #5 on: August 03, 2007, 09:11:13 PM »
Because "A simple printf statement" still has to be defined somewhere. "stdio" is short for standard input/output (if I recall correctly). printf is part of the standard output.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Compiling C with VMware
« Reply #6 on: August 03, 2007, 10:02:40 PM »
It should compile without the include since gcc includes stdio.h by default on every machine i've tried.

More interesting is what is on lines 1 and 2?  I see thats where the errors are coming from, but you haven't included them in your code.
Logged

Offline tdtooke

  • Member
  • *
  • Posts: 151
Re: Compiling C with VMware
« Reply #7 on: August 03, 2007, 11:19:14 PM »
When I tried to compile that with wxdevcpp it required me to have that include.  When I just ran mingw32-gcc it did compile.  Not sure what the deal is since wxdevcpp would've just ran mingw32-gcc to compile that anyway, but it's a thought.

Edit: It compiles with cygwin as well.  Only thing I can think of at this point is making sure there is a blank line at the end of your file.  Some compilers seem to like that in my experiences.
« Last Edit: August 03, 2007, 11:28:39 PM by tdtooke »
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #8 on: August 04, 2007, 12:31:38 PM »
Ok, but what about all the "stray '\' in program" errors? The helloworld code i posted first is the entire file i'm trying to compile. But there are not backslashes on lines 1, 2 or 4.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Compiling C with VMware
« Reply #9 on: August 04, 2007, 03:41:38 PM »
Quote from: mschneider on August 04, 2007, 12:31:38 PM
Ok, but what about all the "stray '\' in program" errors? The helloworld code i posted first is the entire file i'm trying to compile. But there are not backslashes on lines 1, 2 or 4.

The program you posted is 5 lines long, the one you tried to compile is 7 lines long.  Type "cat hello.c" and post what it gives you.
Logged

Offline GodEater

  • Member
  • *
  • Posts: 2829
Re: Compiling C with VMware
« Reply #10 on: August 04, 2007, 05:12:39 PM »
Also - the "cc" command is ambiguous across different linux distros. Make *sure* your VMWare image is calling gcc, and not some bizarre alias to it by explicitly calling it - so do :

gcc hello.c -o hello

Logged

Read The Manual Please

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #11 on: August 05, 2007, 08:49:12 AM »
Alright, thanks for all of your help. I'll give it a try.
Logged

Offline bluebrother

  • Developer
  • Member
  • *
  • Posts: 3421
  • creature
Re: Compiling C with VMware
« Reply #12 on: August 05, 2007, 03:25:20 PM »
I also suggest reading a good C book while trying -- "The C programming language" by Kernighan & Ritchie isn't the easiest book for beginners but a really good one.
Logged
Rockbox Utility development binaries (updated infrequently) · How to ask questions the smart way · We do not estimate timeframes.

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #13 on: August 06, 2007, 03:19:32 PM »
 :D In Fact, that's exactly what i've been reading! My dad had a couple lying around so i've been using that to get me started for the past week or so.
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Compiling C with VMware
« Reply #14 on: August 08, 2007, 12:56:55 PM »
Ok, so i've got everything compiling (it turns out all the stray '\'s were a result of how i was saving the file). I get a.out but i cant run it. When it type a.out into the terminal i just get a "command not found". I'm probably not going about running this the right way so could someone help me?
Logged

  • Print
Pages: [1] 2
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Compiling C with VMware
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.103 seconds with 15 queries.