emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Michael Hannon <jm_hannon@yahoo.com>
Cc: Org-Mode List <emacs-orgmode@gnu.org>,
	Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
Subject: Re: Problem compiling C++ in Org-mode
Date: Fri, 18 Nov 2011 13:16:15 -0700	[thread overview]
Message-ID: <87d3cpgp9s.fsf@gmail.com> (raw)
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)")

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 <jm_hannon@yahoo.com> 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 <jm_hannon@yahoo.com>
>>To: Olaf Meeuwissen <olaf.meeuwissen@avasys.jp>
>>Cc: Org-Mode List <emacs-orgmode@gnu.org>
>>Sent: Friday, November 18, 2011 12:39 AM
>>Subject: Re: [O] Problem compiling C++ in Org-mode
>>
>>Olaf Meeuwissen wrote:
>>
>>>  Michael Hannon <jm_hannon@yahoo.com> 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	other threads:[~2011-11-18 20:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18  4:56 Problem compiling C++ in Org-mode Michael Hannon
2011-11-18  7:38 ` Olaf Meeuwissen
2011-11-18  8:39   ` Michael Hannon
2011-11-18  9:32     ` Olaf Meeuwissen
2011-11-18 19:59     ` Michael Hannon
2011-11-18 20:16       ` Eric Schulte [this message]
2011-11-18 22:57       ` Sebastien Vauban
2011-11-19  5:13         ` Michael Hannon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d3cpgp9s.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jm_hannon@yahoo.com \
    --cc=olaf.meeuwissen@avasys.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).