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: Eric Schulte
Subject: Re: [O] Problem compiling C++ in Org-mode
Date: Fri, 18 Nov 2011 13:16:15 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux)

A slightly cleaner solution would be the following.

(add-to-list 'org-babel-default-header-args:C
             (cons :flags (concat "-std=c++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 <address@hidden> 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  to a temporary file in /tmp/...) and was unable
> to find an include file in the current working directory:
>
> (setq org-babel-C++-compiler
>     (concat "g++ -std=c++0x "
>             "-I"
>             (expand-file-name ".")
>     )
> )
>
> -- Mike
>
>
>
>>________________________________
>>From: Michael Hannon <address@hidden>
>>To: Olaf Meeuwissen <address@hidden>
>>Cc: Org-Mode List <address@hidden>
>>Sent: Friday, November 18, 2011 12:39 AM
>>Subject: Re: [O] Problem compiling C++ in Org-mode
>>
>>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
>>
>>Obviously I was wrong, but it still seems a reasonable approach.
>>
>>-- Mike
>>
>>
>>
>>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/



reply via email to

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