From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Meeuwissen Subject: Re: Problem compiling C++ in Org-mode Date: Fri, 18 Nov 2011 18:32:54 +0900 Message-ID: <87obw9ai7t.fsf@avasys.jp> References: <1321592202.64015.YahooMailNeo@web161913.mail.bf1.yahoo.com> <87wraxanis.fsf@avasys.jp> <1321605584.56574.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]:54374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRKoe-0005DB-Du for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 04:33:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRKod-0000xb-4f for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 04:33:00 -0500 Received: from ekc4.avasys.jp ([210.228.20.165]:62181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRKoc-0000x7-S5 for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 04:32:59 -0500 In-Reply-To: <1321605584.56574.YahooMailNeo@web161909.mail.bf1.yahoo.com> (Michael Hannon's message of "Fri, 18 Nov 2011 00:39:44 -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 Michael Hannon writes: > Olaf Meeuwissen wrote: > >>=C2=A0 Michael Hannon writes: > >>> Greetings.=C2=A0 I'm having a problem compiling a C++ source-code block= 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.cp= p: 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 wo= uld >> 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 could= 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 Of course, here's where Emacs would have to tell the compiler where that starting directory would be and know what option that compiler takes to do so. Here's hoping that -I works everywhere ... probably not. > Obviously I was wrong, but it still seems a reasonable approach. Hope this helps, --=20 Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION FSF Associate Member #1962 Help support software freedom http://www.fsf.org/jf?referrer=3D1962