From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: [PATCH] org-babel C math.h issue Date: Sun, 20 Mar 2016 15:03:26 +0100 Message-ID: <56EEADAE.7090604@free.fr> References: <56E313E9.4010703@free.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050503070704060805050602" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahdx6-0001cp-95 for emacs-orgmode@gnu.org; Sun, 20 Mar 2016 10:03:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahdx5-0002O7-Cq for emacs-orgmode@gnu.org; Sun, 20 Mar 2016 10:03:32 -0400 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:30013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahdx5-0002Ns-7G for emacs-orgmode@gnu.org; Sun, 20 Mar 2016 10:03:31 -0400 Received: from [IPv6:2a01:e35:2e21:def0:9481:6e49:d605:e957] (unknown [IPv6:2a01:e35:2e21:def0:9481:6e49:d605:e957]) by smtp1-g21.free.fr (Postfix) with ESMTP id 6070294019C for ; Sun, 20 Mar 2016 14:59:50 +0100 (CET) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------050503070704060805050602 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Attached is Oz's patch adding optional :libs support to Babel C++ Thanks Oz. Thierry Le 11/03/2016 20:14, Oz Ben-Ami a =C3=A9crit : > Thanks for the response. > > On my machine, I get the undefined references even with GCC 5 (gcc > version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)), if I put -lm before > the source file name. > > As far as a patch, I can try but this would be my first time really > playing with org-mode code. As far as I can see, I would need to add > the following lines in ob-C.el: > L133: (libs (cdr (assoc :libs params))) > (libs (mapconcat 'identity > (if (listp libs) libs (list libs)) " ")) > L142: (format "%s -o %s %s %s %s" ;; (added %s) > L147: libs > > Am I missing anything? > > Oz > --------------050503070704060805050602 Content-Type: text/x-diff; name="0001-Add-libs-to-babel-C.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Add-libs-to-babel-C.patch" >From 69661d4406c51f678dad6f14aaa8f3447c398825 Mon Sep 17 00:00:00 2001 From: Thierry Banel Date: Sun, 20 Mar 2016 14:50:17 +0100 Subject: [PATCH] Add :libs to babel C++ * lisp/ob-C.el (org-babel-C-execute): add support for :libs header parameter to specify libraries to link with. --- lisp/ob-C.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index dd34b0b..d5855ab 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -130,6 +130,12 @@ or `org-babel-execute:C++' or `org-babel-execute:D'." (flags (cdr (assoc :flags params))) (flags (mapconcat 'identity (if (listp flags) flags (list flags)) " ")) + (libs (org-babel-read + (or (cdr (assoc :libs params)) + (org-entry-get nil "libs" t)) + nil)) + (libs (mapconcat 'identity + (if (listp libs) libs (list libs)) " ")) (full-body (case org-babel-c-variant (c (org-babel-C-expand-C body params)) @@ -139,13 +145,15 @@ or `org-babel-execute:C++' or `org-babel-execute:D'." (case org-babel-c-variant ((c cpp) (org-babel-eval - (format "%s -o %s %s %s" + (format "%s -o %s %s %s %s" (case org-babel-c-variant (c org-babel-C-compiler) (cpp org-babel-C++-compiler)) (org-babel-process-file-name tmp-bin-file) flags - (org-babel-process-file-name tmp-src-file)) "")) + (org-babel-process-file-name tmp-src-file) + libs) + "")) (d nil)) ;; no separate compilation for D (let ((results (org-babel-eval -- 2.1.4 --------------050503070704060805050602--