From: "numbchild@gmail.com" <numbchild@gmail.com>
To: Thierry Banel <tbanelwebmin@free.fr>
Cc: Org-mode <emacs-orgmode@gnu.org>
Subject: Re: ob-C doesn't support load libraries
Date: Mon, 13 Jun 2016 08:23:29 +0800 [thread overview]
Message-ID: <CAL1eYuKKLVStHM+mB-1ip6kjh-sF7J4xWzgdM6SCLXqL=egQHQ@mail.gmail.com> (raw)
In-Reply-To: <575AEE51.1060704@free.fr>
[-- Attachment #1: Type: text/plain, Size: 2926 bytes --]
Thanks.
[stardiviner] <Hack this world!> GPG key ID: 47C32433
IRC(freeenode): stardiviner Twitter: @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/
On Sat, Jun 11, 2016 at 12:44 AM, Thierry Banel <tbanelwebmin@free.fr>
wrote:
> Change the first line to
>
> #+BEGIN_SRC C *:libs -lm*
>
> This instructs the C++ compiler to link with the "m" library (mathematical
> functions).
>
> You need a pretty new version of ob-C.el, as the :libs parameter was
> introduced recently.
>
>
>
> Le 10/06/2016 14:01, numbchild@gmail.com a écrit :
>
> I have a code example like this:
>
> #+BEGIN_SRC C
> #include <stdio.h>
> #include <math.h>
>
> /* define complex struct */
> struct complex_struct {
> double x, y;
> };
>
> /* some helper functions on complex struct */
> double real_part(struct complex_struct z) {
> return z.x;
> }
> double img_part(struct complex_struct z) {
> return z.y;
> }
> double magnitude(struct complex_struct z) {
> return sqrt(z.x * z.x + z.y * z.y);
> }
> double angle(struct complex_struct z) {
> return atan2(z.y, z.x);
> }
>
> /* helper functions to construct complex variable */
> struct complex_struct make_from_real_img(double x, double y) {
> struct complex_struct z;
> z.x = x;
> z.y = y;
> return z;
> }
>
> struct complex_struct make_from_mag_ang(double r, double A) {
> struct complex_struct z;
> z.x = r * cos(A);
> z.y = r * sin(A);
> return z;
> }
>
> /* implement complex arithemtic */
> struct complex_struct add_complex(struct complex_struct z1, struct
> complex_struct z2) {
> return make_from_real_img(real_part(z1) + real_part(z2), img_part(z1) +
> img_part(z2));
> }
>
> int main(int argc, char *argv[]) {
> struct complex_struct z1, z2 = {1.1, 2.4};
>
> struct complex_struct z;
> z = add_complex(z1, z2);
>
> printf("%f", z);
> return 0;
> }
> #+END_SRC
>
> But evaluate it got error:
>
> ```
> /tmp/cckFlXlJ.o: In function `magnitude':
> C-src-18467gDZ.c:(.text+0xa8): undefined reference to `sqrt'
> /tmp/cckFlXlJ.o: In function `angle':
> C-src-18467gDZ.c:(.text+0xfe): undefined reference to `atan2'
> /tmp/cckFlXlJ.o: In function `make_from_mag_ang':
> C-src-18467gDZ.c:(.text+0x174): undefined reference to `cos'
> C-src-18467gDZ.c:(.text+0x190): undefined reference to `sin'
> collect2: error: ld returned 1 exit status
> zsh:1: no such file or directory: /tmp/babel-18467-Yn/C-bin-18467tNf
> ```
>
> So I think `ob-C.el` doesn't support to load included header files.
>
> [stardiviner] <Hack this world!> GPG key ID: 47C32433
> IRC(freeenode): stardiviner Twitter: @numbchild
> Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433
> Blog: http://stardiviner.github.io/
>
>
>
[-- Attachment #2: Type: text/html, Size: 11036 bytes --]
prev parent reply other threads:[~2016-06-13 0:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-10 12:01 ob-C doesn't support load libraries numbchild
2016-06-10 16:44 ` Thierry Banel
2016-06-13 0:23 ` numbchild [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAL1eYuKKLVStHM+mB-1ip6kjh-sF7J4xWzgdM6SCLXqL=egQHQ@mail.gmail.com' \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tbanelwebmin@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.