bigfocalchord
bigfocalchord

Reputation: 563

Running Hello World on Sublime Text 3

So to set up compiling on sublime text3 on mac , I've downloaded the developer xcode tools and then

I made a new build system and saved it as 'c' :

{
"cmd" : ["gcc",  "-o", "$file_base_name", "$file_name"],
"cmd" : ["./$file_base_name"],
"selector" : "source.c",
"shell" : false,
"working_dir" : "$file_path"
}

After this my program is this:

#include <stdio.h>

int main(void) {
printf("Hello World");
return 0;
}

And when I tried 'building' it I get this error

[Errno 2] No such file or directory: './Hello World'
[cmd: ['./Hello World']]
[dir: /Users/(username)/Desktop/Programming/Random C Programs]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

What is wrong?

I have also saved my Hello World files on my desktop named specifically "Hello World.c" if that makes any difference


New Error referring to schwern's comment:

Now I am getting this:

[Errno 2] No such file or directory: './HelloWorld'
[cmd: ['./HelloWorld']]
[dir: /Users/(username)/Desktop/Programming/RandomCPrograms]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

Upvotes: 1

Views: 2633

Answers (1)

Schwern
Schwern

Reputation: 165268

The problem is likely that you have a space in the file name and didn't escape it or quote the filename.

./Hello World is running the program ./Hello with the first argument being World.

(That was wrong, Sublime doesn't run cmd through the shell so spaces are fine)

You can't have two entries with the same key, the second cmd has overwritten the first. I'm not sure how you'd run two commands. See Build Systems for more.

Upvotes: 1

Related Questions