emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Richard Stanton <stanton@haas.berkeley.edu>
To: 'Eric Schulte' <eric.schulte@gmx.com>
Cc: "'emacs-orgmode@gnu.org'" <emacs-orgmode@gnu.org>
Subject: Re: Problems running C code in org-mode under Windows
Date: Tue, 27 Mar 2012 23:00:39 -0700	[thread overview]
Message-ID: <40C7B1BFC291ED4E9D10436D07736A334702EB9999@EXMAIL7.haas.uc.berkeley.edu> (raw)
In-Reply-To: <0B0951AC10878A45A228603F57EEA0CE46F5DD0CBF@EXMAIL7.haas.uc.berkeley.edu>

> I think the "Access is denied" problem is probably the same as that listed
> here:
> http://lists.gnu.org/archive/html/help-gnu-emacs/2010-04/msg00247.html
> Unfortunately, when I switch to using bash as my shell under Windows, this
> causes problems with python-mode (though this is not really your
> problem...) This change does get the compilation to work on my machine,
> however, and a .exe file is created. So far so good...
> However, the output still appears blank in the org buffer. More tracing
> required...

One problem - when using bash as the shell, when trying to execute the compiled file, it tries to execute the empty file, not the file that was just compiled (which has the same name, but the extension .exe, added by the compiler). 

A partial solution to this is to append ".exe" to the name of the binary temp file if running under Windows. E.g., start org-babel-C-execute something like this:

(defun org-babel-C-execute (body params)
  "This function should only be called by `org-babel-execute:C'
or `org-babel-execute:C++'."
  (let* ((tmp-src-file (org-babel-temp-file
			 ((equal org-babel-c-variant 'c) ".c")
			 ((equal org-babel-c-variant 'cpp) ".cpp"))))
         (tmp-bin-file (org-babel-temp-file 
			(if (equal system-type 'windows-nt) ".exe" "")))


I say "partial solution" because the output in the org file is *still* blank, but at least the program does get run this way...

One question - why create a temp file for the executable before running the compilation? Why not just have it created by the compiler?

  parent reply	other threads:[~2012-03-28  6:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-26 23:04 Problems running C code in org-mode under Windows Richard Stanton
2012-03-27  1:44 ` Eric Schulte
2012-03-27 17:25   ` Richard Stanton
2012-03-27 16:06     ` Eric Schulte
2012-03-27 20:43       ` Richard Stanton
     [not found]       ` <0B0951AC10878A45A228603F57EEA0CE46F5DD0CBF@EXMAIL7.haas.uc.berkeley.edu>
2012-03-28  6:00         ` Richard Stanton [this message]
2012-03-28  7:14       ` Richard Stanton

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:

  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=40C7B1BFC291ED4E9D10436D07736A334702EB9999@EXMAIL7.haas.uc.berkeley.edu \
    --to=stanton@haas.berkeley.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \


* 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


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