emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem compiling C++ in Org-mode
@ 2011-11-18  4:56 Michael Hannon
  2011-11-18  7:38 ` Olaf Meeuwissen
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Hannon @ 2011-11-18  4:56 UTC (permalink / raw)
  To: Org-Mode List

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.  I.e., a program that
includes only standard files, such as:

    #include <iostream>

works fine.  But Org-mode seems to be unable to find a file included from the
current directory, such as:

    #include "OtherStuff.cpp"

I've appended the Org source code and associated error message.

I've also appended the log of a successful compilation of the same source code
in the shell, as well as the details of my configuration.

What am I missing?

Thanks,

-- Mike




########## Unsuccessful attempt to compile in Org-mode

* Test

#+begin_src cpp
    
  #include <iostream>
  #include <memory>
  #include "OtherStuff.cpp"
  
  using namespace std;
  
  int main() {
  
    cout << "Hello!" << endl;
  
  }
    
#+end_src

#+results:


/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

########## Successful compilation in linux shell

$ cat junk.cpp
#include <iostream>
#include <memory>
#include "OtherStuff.cpp"

using namespace std;

int main() {

  cout << "Hello!" << endl;

}
$ g++ -o junk -std=c++0x junk.cpp

$ ./junk
Hello!

########## 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"

Documentation:
Command used to compile a C++ source code file into an
  executable.

########## My configuration

Emacs  : GNU Emacs 23.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 2.24.5)
 of 2011-06-29 on x86-01.phx2.fedoraproject.org
Package: Org-mode version 7.7 (release_7.7.328.g1a97.dirty)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-19  5:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2011-11-18 22:57       ` Sebastien Vauban
2011-11-19  5:13         ` Michael Hannon

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).