emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Problem compiling C++ in Org-mode


From: Olaf Meeuwissen
Subject: Re: [O] Problem compiling C++ in Org-mode
Date: Fri, 18 Nov 2011 18:32:54 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Michael Hannon <address@hidden> writes:

> Olaf Meeuwissen wrote:
>
>>  Michael Hannon <address@hidden> writes:
>
>>> Greetings.  I'm having a problem compiling a C++ source-code block in
>>> Org-mode.  The same C++ code compiles and runs in the shell.
>>>
>>> The issue seems to relate to local include files.  [...snip...]
>>> What am I missing?
>>
>>> /tmp/babel-245846_d/C-src-24584NIQ.cpp:7:26: fatal error: OtherStuff.cpp: 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=c++0x"
>
>> The current directory is not specified in the include path.  You would
>> need to add a -I option to set the (absolute path to the) directory the
>> org file is in.  If you have all your org files in ~/org, you could try
>> "g++ -std=c++0x -I~/org".
>
> Thanks, Olaf.  That does fix the problem, and in some sense that's the obvious
> solution.  On the other hand, it does seem strange to me that the end user
> should have to specify the include directory.  I.e., Emacs clearly knows 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.  I
> assumed that the compilation process in Org-mode would include steps similar
> to:
>
>     + remember current directory
>     + write contents of source block to obscure location in /tmp
>     + compile source block in obscure location,
>           but remembering the starting directory for such things
>           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,
-- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962



reply via email to

[Prev in Thread] Current Thread [Next in Thread]