From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daimrod Subject: Re: Org Babel C/C++ Date: Fri, 30 Mar 2012 13:17:00 +0200 Message-ID: <87zkaygwyb.fsf@gmail.com> References: <87fwcz6vbf.fsf@gmail.com> <87wr67po1v.fsf@gmx.com> <87zkb0qqj0.fsf@gmail.com> <1332984868.16913.YahooMailNeo@web161902.mail.bf1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDZpX-000145-4Y for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 07:17:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SDZpU-000057-WF for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 07:17:18 -0400 Received: from plane.gmane.org ([80.91.229.3]:50087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SDZpU-00004x-PJ for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 07:17:16 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SDZpR-0007u7-0x for emacs-orgmode@gnu.org; Fri, 30 Mar 2012 13:17:13 +0200 Received: from anantes-556-1-310-218.w2-9.abo.wanadoo.fr ([2.9.254.218]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Mar 2012 13:17:12 +0200 Received: from daimrod by anantes-556-1-310-218.w2-9.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Mar 2012 13:17:12 +0200 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 Michael Hannon writes: > On Wednesday, March 28, 2012 at 4:01 PM Daimrod wrote: > >> Eric Schulte writes: >> >>> Applied, Thanks! >>> >>> Daimrod writes: >>> >>>> Hi, >>>> >>>> I've made a small patch to ob-C.el so it now includes the current >>>> directory to the list of directories to be searched for header files. >>>> Without this, I cannot include a local header file because the >>>> compilation happens in /tmp and thus gcc or g++ doesn't search for >>>> header files in the directory I currently work. >>>> >>>> diff --git a/lisp/ob-C.el b/lisp/ob-C.el >>>> index f1525aa..4f33fc4 100644 >>>> --- a/lisp/ob-C.el >>>> +++ b/lisp/ob-C.el >>>> @@ -96,15 +96,14 @@ or `org-babel-execute:C++'." >>>>         (progn >>>>           (with-temp-file tmp-src-file (insert full-body)) >>>>           (org-babel-eval >>>> -        (format "%s -o %s %s %s -I >> \"%s\"" >>>> +        (format "%s -o %s %s %s" >>>>               (cond >>>>                 ((equal org-babel-c-variant 'c) >> org-babel-C-compiler) >>>>                 ((equal org-babel-c-variant 'cpp) >> org-babel-C++-compiler)) >>>>               (org-babel-process-file-name tmp-bin-file) >>>>               (mapconcat 'identity >>>>                   (if (listp flags) flags (list flags)) " ") >>>> -            (org-babel-process-file-name tmp-src-file) >>>> -            (file-name-directory (expand-file-name >> (buffer-file-name)))) "")))) >>>> +            (org-babel-process-file-name tmp-src-file)) >> "")))) >>>>       ((lambda (results) >>>>         (org-babel-reassemble-table >>>>       (if (member "vector" (cdr (assoc :result-params >> params))) >> >> Hum, I'm quite embarrassed, this doesn't work when the block is executed >> during an export. I didn't track it down yet, but (buffer-file-name) >> returns nil during the export probably because the buffer changes. >> >> A workaround would be to use the :flags header argument though it's a >> bit tedious because it doesn't seem possible to eval elisp during the >> export. >> >> i.e. >> >> #+BEGIN_SRC cpp :flags -I (file-name-directory (buffer-file-name)) >> ... >> #+END_SRC >> > > I ran into this problem a few months ago.  I don't have the elisp skills to > patch Org mode, but I found something that worked for me: > >     http://article.gmane.org/gmane.emacs.orgmode/49356/ > > -- Mike This won't work if you use different directories, you'll have to set the variable org-babel-C++-compiler every time. IMHO a good solution would be to be able to specify the directory used to compile, or maybe I should just use a Makefile.