#17605: "How to call C code from Sage" thematic tutorial
-------------------------+-------------------------------------------------
       Reporter:         |        Owner:
  ncohen                 |       Status:  needs_work
           Type:         |    Milestone:  sage-6.5
  enhancement            |   Resolution:
       Priority:  major  |    Merged in:
      Component:         |    Reviewers:  Karl-Dieter Crisman
  documentation          |  Work issues:
       Keywords:         |       Commit:
        Authors:         |  96177d8ed62e5c88325c95f168406b27249b2ea1
  Nathann Cohen          |     Stopgaps:
Report Upstream:  N/A    |
         Branch:         |
  public/17605           |
   Dependencies:         |
-------------------------+-------------------------------------------------

Comment (by ncohen):

 Yo ! Thank you for looking at this.

 > * My compiler gives this.
 > {{{
 > $ gcc hello.c -o hello; ./hello
 > hello.c: In function ‘main’:
 > hello.c:7: warning: return type of ‘main’ is not ‘int’
 > Hello World
 > }}}

 My compiler does not say a word. I changed the return type of main to int
 and added a 'return 0'. I would prefer to remove this `return 0` (my
 compiler does not complain either if I do) for that is irrelevant
 information to what I want to illustrate. Can you tell me what it gives
 for you ?

 > * Inconsistent names here:

 Fixed.

 > * Compiler error:

 I fixed the indentation level.

 > * Even after fixing this:
 > {{{
 >
 > sage: %runfile hello_sage.pyx
 > Compiling ./hello_sage.pyx...
 > Error compiling cython file:
 > Error compiling ./hello_sage.pyx:
 > running build
 > ...
 > _Users_..._hello_sage_pyx_0.c:349:19: fatal error: hello.c: No such file
 or directory
 > compilation terminated.
 > error: command 'gcc' failed with exit status 1
 > }}}

 This I do not understand. Is hello_sage is in the same folder as hello.c ?
 `O_o` I really do not understand that.

 >   Maybe my file needs to be in my `PATH`?  But that didn't seem to help.

 No no, you should not have to. And I would prefer to avoid asking the user
 to change the PATH anyway `O_o`

 > * And since presumably I needed to compile `double_vector.c` first, I
 tried that, but...

 Nono, you do not need to compile it by itself (and when you do it
 complains because no 'main' function is defined, which is correct). It
 gets compiled when you call "runfile". Actually, you do not need to
 compile 'hello.c' at first. It is just to give an example. If it gets
 complicated we can remove this compilation of "hello world", actually. It
 is not necessary.

 > * Similar problems with the final library example.

 When you say "similar problem", is it also about 'main' ? `O_o`

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/17605#comment:28>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to