From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Hannon Subject: Re: Problem compiling C++ in Org-mode Date: Fri, 18 Nov 2011 11:59:23 -0800 (PST) Message-ID: <1321646363.68187.YahooMailNeo@web161909.mail.bf1.yahoo.com> References: <1321592202.64015.YahooMailNeo@web161913.mail.bf1.yahoo.com> <87wraxanis.fsf@avasys.jp> <1321605584.56574.YahooMailNeo@web161909.mail.bf1.yahoo.com> Reply-To: Michael Hannon Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRUar-0004H5-35 for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 14:59:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRUaq-0001bB-28 for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 14:59:25 -0500 Received: from nm1.bullet.mail.bf1.yahoo.com ([98.139.212.160]:38086) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RRUap-0001b7-Sz for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 14:59:24 -0500 In-Reply-To: <1321605584.56574.YahooMailNeo@web161909.mail.bf1.yahoo.com> 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 , Olaf Meeuwissen Cc: Org-Mode List =0A=0AJust 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 sour= ce block (written=A0 to a temporary file in /tmp/...) and was unable to fin= d an include file in the current working directory:=0A=0A(setq org-babel-C+= +-compiler=0A=A0=A0=A0 (concat "g++ -std=3Dc++0x "=0A=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 "-I"=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (expand-file-name "."= )=0A=A0=A0=A0 )=0A)=0A=0A-- Mike=0A=0A=0A=0A>______________________________= __=0A>From: Michael Hannon =0A>To: Olaf Meeuwissen =0A>Cc: Org-Mode List =0A>Se= nt: Friday, November 18, 2011 12:39 AM=0A>Subject: Re: [O] Problem compilin= g C++ in Org-mode=0A>=0A>Olaf Meeuwissen wrote:=0A>=0A>>=A0 Michael Hannon = writes:=0A>=0A>>> Greetings.=A0 I'm having a problem = compiling a C++ source-code block in=0A>>> Org-mode.=A0 The same C++ code c= ompiles and runs in the shell.=0A>>>=0A>>> The issue seems to relate to loc= al include files.=A0 [...snip...]=0A>>> What am I missing?=0A>>=0A>>> /tmp/= babel-245846_d/C-src-24584NIQ.cpp:7:26: fatal error: OtherStuff.cpp: No=0A>= >> such file or directory=0A>>> compilation terminated.=0A>>> /bin/bash: /t= mp/babel-245846_d/C-bin-24584aSW: Permission denied=0A>=0A>> Compilation is= taking place in a temporary directory, miles away from=0A>> where your org= file lives.=0A>=0A>>> ########## Org-mode compile uses same option as shel= l compile:=0A>>>=0A>>> org-babel-C++-compiler is a variable defined in `ob-= C.el'.=0A>>> Its value is "g++ -std=3Dc++0x"=0A>=0A>> The current directory= is not specified in the include path.=A0 You would=0A>> need to add a -I o= ption to set the (absolute path to the) directory the=0A>> org file is in.= =A0 If you have all your org files in ~/org, you could try=0A>> "g++ -std= =3Dc++0x -I~/org".=0A>=0A>Thanks, Olaf.=A0 That does fix the problem, and i= n some sense that's the obvious=0A>solution.=A0 On the other hand, it does = seem strange to me that the end user=0A>should have to specify the include = directory.=A0 I.e., Emacs clearly knows the=0A>current directory ("M-x pwd"= , for instance), and the C++ compiler "knows" to=0A>look in the current dir= ectory for include files enclosed in quote marks.=A0 I=0A>assumed that the = compilation process in Org-mode would include steps similar=0A>to:=0A>=0A>= =A0=A0=A0 + remember current directory=0A>=A0=A0=A0 + write contents of sou= rce block to obscure location in /tmp=0A>=A0=A0=A0 + compile source block i= n obscure location,=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0 but remembering the star= ting directory for such things=0A>=A0=A0=A0=A0=A0=A0=A0=A0=A0 as include fi= les=0A>=0A>Obviously I was wrong, but it still seems a reasonable approach.= =0A>=0A>-- Mike=0A>=0A>=0A>=0A>