How do I compile C?

For general discussion about Conway's Game of Life.
Post Reply
User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

How do I compile C?

Post by Saka » December 1st, 2015, 4:31 am

How do I compile C code? What programs can I use? I would really like to use dr soon and gfind

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 17th, 2015, 6:10 am

I have Cygwin and Micro C compiler (mcc) but I cannot compile dr

Sokwe
Moderator
Posts: 2688
Joined: July 9th, 2009, 2:44 pm

Re: How do I compile C?

Post by Sokwe » December 17th, 2015, 7:17 am

Saka wrote:I have Cygwin and Micro C compiler (mcc) but I cannot compile dr
There should be no need to compile dr under Cygwin. Since you are using Windows, I think you should get MinGW and compile dr using the GCC compiler.

I included a Windows executable for dr2 in this post (and forgot to include the source code, which is here). Does this executable not work for you?
-Matthias Merzenich

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 17th, 2015, 9:05 am

Sokwe wrote:There should be no need to compile dr under Cygwin. Since you are using Windows, I think you should get MinGW and compile dr using the GCC compiler.
I know Cygwin is overkill for source compilations like these but much of the Windows ConwayLife users would have Cygwin installed anyway because of compiling apgnano. Personally I do not like it too much as it can be kinda bloated and they say it's slower... but I guess windows users would have to stick with that.

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 17th, 2015, 10:38 am

Sokwe wrote:
Saka wrote:I have Cygwin and Micro C compiler (mcc) but I cannot compile dr
There should be no need to compile dr under Cygwin. Since you are using Windows, I think you should get MinGW and compile dr using the GCC compiler.

I included a Windows executable for dr2 in this post (and forgot to include the source code, which is here). Does this executable not work for you?
Thanks! Didn't see that post... :oops:

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 1:43 am

I tried the example on the thread and it does nothing, I'm confused

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 18th, 2015, 7:06 am

Saka wrote:I tried the example on the thread and it does nothing, I'm confused
Keep calm and read on: viewtopic.php?f=9&t=1445#p16606

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 8:32 am

Scorbie wrote:
Saka wrote:I tried the example on the thread and it does nothing, I'm confused
Keep calm and read on: viewtopic.php?f=9&t=1445#p16606
I did read that, but I am not sure what it meant, so, in dr, do I input
dr2 > output.txt
And then
dr2 < input.txt
(Or vice versa)?

User avatar
dvgrn
Moderator
Posts: 10685
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: How do I compile C?

Post by dvgrn » December 18th, 2015, 8:39 am

Saka wrote:
Scorbie wrote:
Saka wrote:I tried the example on the thread and it does nothing, I'm confused
Keep calm and read on: viewtopic.php?f=9&t=1445#p16606
I did read that, but I am not sure what it meant, so, in dr, do I input
dr2 > output.txt
And then
dr2 < input.txt
(Or vice versa)?
Both:

Code: Select all

dr2 < input.txt > output.txt
Or at least the second one. Otherwise dr2 won't have any input. Piping the output to a file is optional -- if you don't add the "> output.txt", you'll just see all the output in the command window, and if you want to save it you'd have to copy it from there.

The key idea is that two separate steps definitely wouldn't work -- dr2 isn't going to save any state from one run to the next. Each time you run it, it has to have all the information it needs to run a search and send the results wherever you want them to be stored.

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 8:51 am

@dvgrn
Does input.txt and output.txt have to be in the same folder as dr2?

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 18th, 2015, 9:29 am

Saka wrote:@dvgrn Does input.txt and output.txt have to be in the same folder as dr2?
Umm... Sort of. I guess you tested that. If not, a short test would have let you know.
(I originally tried to suggest a keyword to search on Google but umm... it's hard to describe this "thing".)

Here are some examples:

Code: Select all

drifter_directory
ㄴdr
ㄴinput.txt
ㄴoutput.txt

You may want to run:
dr < input.txt > output.txt
(You're on windows, right?)
The files needn't be in the same directory:

Code: Select all

drifter_directory
ㄴdr
ㄴfiles
  ㄴinput.txt
  ㄴoutput.txt

You may want to run:
dr < files/input.txt > files/output.txt (The cmd line is in the drifter_directory.)
or maybe:
../dr < input.txt > output.txt (The cmd prompt is in the files directory.)

Code: Select all

some_directory
ㄴdrifter_directory
  ㄴdr
ㄴinput.txt
ㄴsome_other_directory
  ㄴoutput.txt

You may want to run:
dr < ../input.txt > ../some_other_directory/output.txt
(.. means the parent directory. I haven't tested this on Windows but I think it would work.)
Or even:

Code: Select all

drifter_directory
ㄴdr
...Completely Unrelated...
C:
ㄴUsers
  ㄴSaka
    ㄴsome_folder
      ㄴinput.txt

You can run:
dr < C:\Users\Saka\some_folder\input.txt (cmd prompt is in the drifter_directory)
1)The last one is related to "absolute path", the others are related to "relative path". Recommend to search on Google to understand how that works.
2) About the backslashes: Windows works both with forward slashes and backslashes as a subdirectory "sign". I don't know the minor quirks of it, though.
3) You can drag a file to the command prompt to list its absolute path.

Tip: When asking questions, generally, I think it would save your time (and my time :)) if you specified what you tried, or things like that, more specifically. [+ Your Computer OS, Program, stacktraces etc. if something crashed] I think you would have solved the problem faster if you initially posted what you posted two posts later.
I didn't mean any offense, though... Just pointing out that this would help in getting answers to questions faster.
Last edited by Scorbie on December 18th, 2015, 9:34 am, edited 1 time in total.

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 9:33 am

OMG YOU GUESSED MY PC USERNAME!!(Not sure which emoticon to put) :shock:
I have not tried that out, because it's already late night

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 18th, 2015, 9:37 am

Saka wrote:OMG YOU GUESSED MY PC USERNAME!!(Not sure which emoticon to put) :shock:
LOL guess what my username is :lol:
Saka wrote:I have not tried that out, because it's already late night
Yep, Take your time :)

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 7:11 pm

Scorbie wrote:
Saka wrote:OMG YOU GUESSED MY PC USERNAME!!(Not sure which emoticon to put) :shock:
LOL guess what my username is :lol:
Scorbie? Scorbic? Not sure. Also, in response to my post in the "New p17 and other billiard tables" thread, you posted the way to compile dr with cygwin, I did not understand what you meant by "your_binary_name"

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 18th, 2015, 7:53 pm

Hehe my username is scorbie :)

You can set the executable name. If you do

Code: Select all

gcc -O3 dr.c -o drifter
the executable name would be drifrter.exe.

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 8:36 pm

You typed drifrter

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 18th, 2015, 10:07 pm

Help!
When I did dr < input.txt > output.txt
it said

Code: Select all

Bad bit in 'd' or 'D' command
same output for dr2
I was trying the example inputs on the thread

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 19th, 2015, 12:53 am

eek... I don't know what's wrong with that and I think the dr2 thread would be a better place for that (maybe there isn't a dr2 thread?)

User avatar
Saka
Posts: 3627
Joined: June 19th, 2015, 8:50 pm
Location: Indonesia
Contact:

Re: How do I compile C?

Post by Saka » December 19th, 2015, 1:21 am

Scorbie wrote:eek... I don't know what's wrong with that and I think the dr2 thread would be a better place for that (maybe there isn't a dr2 thread?)
Ok, I'll try to retrace:
1. Made input file with:

Code: Select all

c50
h15
w15
rot90symm
v127 1
d2 36 36 44 44
r36 36
444344o.4
....o.o.4
oooo.oo.4
4.o...o.3
4o.....o4
3.o...o.4
4.oo.oooo
4.o.o....
4.o443444!
d0 37 36 37 39
d0 38 36 38 38
d0 p39 37
skipstable
skipfizzle
(From thread)
2. Made output.txt in same folder as dr2
3.Opened dr2.exe
4.Ran

Code: Select all

dr2 < input.txt > output.txt
5. Got the message
Did I do something wrong? Maybe we can compare our steps

User avatar
Scorbie
Posts: 1692
Joined: December 7th, 2013, 1:05 am

Re: How do I compile C?

Post by Scorbie » December 19th, 2015, 10:20 am

Saka, I think it is better to ask questions at each thread instead of opening a new onein the general discussions forum... You could always read the existing Bellman, drifter, or ptbsearch threads and post something you don't understand there.

Post Reply