From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Problem compiling C++ in Org-mode Date: Fri, 18 Nov 2011 13:16:15 -0700 Message-ID: <87d3cpgp9s.fsf@gmail.com> References: <1321592202.64015.YahooMailNeo@web161913.mail.bf1.yahoo.com> <87wraxanis.fsf@avasys.jp> <1321605584.56574.YahooMailNeo@web161909.mail.bf1.yahoo.com> <1321646363.68187.YahooMailNeo@web161909.mail.bf1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRUrE-0000c6-UY for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:16:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRUrD-0005Fn-Fy for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:16:20 -0500 Received: from mail-iy0-f169.google.com ([209.85.210.169]:53684) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRUrD-0005Fh-Bg for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:16:19 -0500 Received: by iaek3 with SMTP id k3so5166952iae.0 for ; Fri, 18 Nov 2011 12:16:18 -0800 (PST) In-Reply-To: <1321646363.68187.YahooMailNeo@web161909.mail.bf1.yahoo.com> (Michael Hannon's message of "Fri, 18 Nov 2011 11:59:23 -0800 (PST)") 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: Michael Hannon Cc: Org-Mode List , Olaf Meeuwissen A slightly cleaner solution would be the following. (add-to-list 'org-babel-default-header-args:C (cons :flags (concat "-std=3Dc++0x -I " (expand-file-name ".")= ))) But either the above or below configuration will likely only work if the directory holding your .emacs is the same directory in which the included files are held. Best -- Eric Michael Hannon writes: > Just for the record, adding the following to my .emacs file seems to > solve the problem I was having, where the C++ compiler was compiling a > source block (written=C2=A0 to a temporary file in /tmp/...) and was unab= le > to find an include file in the current working directory: > > (setq org-babel-C++-compiler > =C2=A0=C2=A0=C2=A0 (concat "g++ -std=3Dc++0x " > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "-I" > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (expan= d-file-name ".") > =C2=A0=C2=A0=C2=A0 ) > ) > > -- Mike > > > >>________________________________ >>From: Michael Hannon >>To: Olaf Meeuwissen >>Cc: Org-Mode List >>Sent: Friday, November 18, 2011 12:39 AM >>Subject: Re: [O] Problem compiling C++ in Org-mode >> >>Olaf Meeuwissen wrote: >> >>>=C2=A0 Michael Hannon writes: >> >>>> Greetings.=C2=A0 I'm having a problem compiling a C++ source-code bloc= k in >>>> Org-mode.=C2=A0 The same C++ code compiles and runs in the shell. >>>> >>>> The issue seems to relate to local include files.=C2=A0 [...snip...] >>>> What am I missing? >>> >>>> /tmp/babel-245846_d/C-src-24584NIQ.cpp:7:26: fatal error: OtherStuff.c= pp: No >>>> such file or directory >>>> compilation terminated. >>>> /bin/bash: /tmp/babel-245846_d/C-bin-24584aSW: Permission denied >> >>> Compilation is taking place in a temporary directory, miles away from >>> where your org file lives. >> >>>> ########## Org-mode compile uses same option as shell compile: >>>> >>>> org-babel-C++-compiler is a variable defined in `ob-C.el'. >>>> Its value is "g++ -std=3Dc++0x" >> >>> The current directory is not specified in the include path.=C2=A0 You w= ould >>> need to add a -I option to set the (absolute path to the) directory the >>> org file is in.=C2=A0 If you have all your org files in ~/org, you coul= d try >>> "g++ -std=3Dc++0x -I~/org". >> >>Thanks, Olaf.=C2=A0 That does fix the problem, and in some sense that's t= he obvious >>solution.=C2=A0 On the other hand, it does seem strange to me that the en= d user >>should have to specify the include directory.=C2=A0 I.e., Emacs clearly k= nows the >>current directory ("M-x pwd", for instance), and the C++ compiler "knows"= to >>look in the current directory for include files enclosed in quote marks.= =C2=A0 I >>assumed that the compilation process in Org-mode would include steps simi= lar >>to: >> >>=C2=A0=C2=A0=C2=A0 + remember current directory >>=C2=A0=C2=A0=C2=A0 + write contents of source block to obscure location i= n /tmp >>=C2=A0=C2=A0=C2=A0 + compile source block in obscure location, >>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 but remembering th= e starting directory for such things >>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 as include files >> >>Obviously I was wrong, but it still seems a reasonable approach. >> >>-- Mike >> >> >> >> > --=20 Eric Schulte http://cs.unm.edu/~eschulte/