emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Problems running C code in org-mode under Windows


From: Richard Stanton
Subject: Re: [O] Problems running C code in org-mode under Windows
Date: Tue, 27 Mar 2012 23:00:39 -0700

> 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
                        "C-src-"
                        (cond
                         ((equal org-babel-c-variant 'c) ".c")
                         ((equal org-babel-c-variant 'cpp) ".cpp"))))
         (tmp-bin-file (org-babel-temp-file 
                        "C-bin-"
                        (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?



reply via email to

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