Super-quick tutorial for polymath5 users

Here’s a super quick tutorial on how to compile C++ code and use it as a black box.  I’m starting with Mac following Tim’s request.

Note: this post is likely to evolve quite a lot, I’ll try to set up a nicer tutorial over the next days, having in mind a mathematician who wants to go straight at the point.

Table of contents: I  on a Mac      II on Windows    III on linux

I. On a Mac: update, I’ve now had the chance to get hold of a Mac for a day, so I’ve made a detailed tutorial here .

II. On Windows.   This is something I’ve tested on WinXP, and which should work with Vista and Windows7.

Go to cygwin.com and press the ‘download cygwin now’ link on the top right of that page.  Follow the very nice visual instructions here, and make sure you install both the whole Base directory (normally it’s selected already by default)  and also  the gcc and make packages located in the Devel directory.

Now supposing you’ve intalled and set it up, here’s how to compile the C++ code I’ve put on the wiki.

1. go on the wiki, select the whole code with the mouse, copy it (i.e. while pressing the Ctrl key hit C)

2. open the notepad text editor (click start, go to all programs, then accessories, then notepad)

3. paste the code (Ctrl key and hit V)

4. save this file as seq2tab.txt   inside the folder   C:\cygwin\home\jack  (where jack is the username you chose for cygwin)

5. click on the green cygwin icon, it should open a terminal window

6. now type

ls

in the terminal and press and return. You should see the name of your file seq2tab.txt

Now type

cp seq2tab.txt seq2tab.cc

7. Then type the following, which converts the windows text format into unix format

dos2unix seq2tab.cc

8. Now type the compilation command

g++ seq2tab.cc -o xseq2tab

it should compile smoothly without any complaint or warnings.

8. finally to lauch the program type

./xseq2tab.exe

9. now it should ask you for the file containing the sequence. So far so good, press Ctrl and hit C to stop the program.

At this point you should copy the sequence to a text file like mysequence.txt in that directory, make sure it’s in the correct format regarding spacings and carriage returns (save the changes), and convert it to unix format with dos2unix.  Now you’re ready, launch again the program, provide the filename mysequence.txt  then provide the name of the HTML file you want to create, say mytable.html, and when it’s over you should be able to open that file into your browser.

III. on linux.  If your university has provided you with a PC under linux but you’ve used it so far in a windows-like fashion without doing any programming then here’s how to proceed.

1. go on the wiki, select the whole code with the mouse, copy it (i.e. while pressing the Ctrl key hit C)

2. open a text editor (there should be one in the scrolling menus, maybe kyle)

3. paste the code (Ctrl key and hit V)

4. save this file as seq2tab.txt   inside the folder,  say edpfolder

5. open a terminal (you be somewhere in the scrolling menus (possibly under the name term or Xterm)

6. now type

ls

in the terminal and press and return. You should see the name of your file seq2tab.txt

7. Now enter

cp seq2tab.txt seq2tab.cc

8. Now enter the compilaion command

g++ seq2tab.cc -o xseq2tab

it should compile smoothly without any complaint or warnings.

8. finally to lauch the program enter

./xseq2tab

9. now it should ask you for the file containing the sequence. So far so good, press Ctrl and hit C to stop the program.

At this point you should copy the sequence to a text file like mysequence.txt in that directory, make sure it’s in the correct format regarding spacings and carriage returns (save the changes).  Now you’re ready, launch again the program, provide the filename mysequence.txt  then provide the name of the HTML file you want to create, say mytable.html, and when it’s over you should be able to open that file into your browser.

Advertisements

Tags:

6 Responses to “Super-quick tutorial for polymath5 users”

  1. Miguel Lacruz Says:

    Thomas, thanks a lot for the tutorial. I will give it a try asap.

  2. Peter Lund Says:

    Hi, I just looked at the source. Just a quick comment…

    Why not forgo all the opening and closing of files and use stdin/stdout instead? And use stderr to report errors, which is a good idea anyway?

    • Thomas Sauvaget Says:

      Yes you’re right that it would speed-up things (and stderr is good practise but this is a tiny code here), just thought that would illustrate stuff. But feel free to add your version on the wiki (if so please explain succintly the changes you made).

  3. Peter Lund Says:

    Oh, it’s not to speed things up!

    It’s to make the code smaller and clearer — and more flexible, to boot, since it can then both participate in pipes on the command line and be used in scripts. The shell will even handle errors during open for you.

    • Thomas Sauvaget Says:

      It would improve performance slightly, and sure command line is efficient (I have my own version), but I wanted to make sure the users remember what each argument should be (I had really beginners in mind, hence my special error message and so on).

  4. Installing Xcode and using GCC on Mac « episodic thoughts Says:

    […] I have thus made the tutorial a very explicit step-by-step one with screenshots.   The aim is  to install on a Mac and use the GCC compiler, which allows to create executable programs from a C or C++ source code.   (For Windows and linux versions click here). […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: