my emacs version is 24.3.1.
i understand i have to put the ob-C.el (available from here) in a path where Emacs can read it.
i first copy-pasted the code from that .el file to my .emacs file and restarted emacs. then i went to a C code block (within an org file) and tried to execute it (using C-c C-c). the minibuffer said 'no org-babel-execute function for C'. the same story played out with trying to execute a C++ code block. note that R and python evaluate perfectly from within my org files. the problems seems to be only with these compiled languages.
i then tried putting this ob-C.el inside the ~/.emacs.d directory to see if that helped matters. restarted emacs and checked. it didn't work.
then i tried putting it into a directory ~/.emacs.d/lisp and added the following lines to my .emacs file
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "ob-C.el")
(require 'ob-C)
after restarting emacs, evaluating the C or C++ code blocks from within an org file still doesn't work. i keep getting the same error "no org-babel-execute function for C" or "no org-babel-execute function for C++".
Update
i upgraded my emacs version to 24.5, deleted all the previous elpa and melpa subdirectories in my ~/.emacs.d directory. suspecting that it had to do with the order in which i placed my
(custom-set-variables
'(org-babel-load-languages
(quote
((emacs-lisp . t)
(C . t)
(css . t)
(sh . t)
(awk . t)
(R . t))))
and
;; load the pathnames to custom lisp files
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "ob-C.el")
(require 'ob-C)
code blocks, i put the load "ob-C.el" before the org-babel-load-languages thing. i then executed the c++ code block multiple times. no luck.
then i removed everything (cleaned out the custom-set-variables block in the .emacs file) and now my .emacs file looks like
;; load the pathnames to custom lisp files
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "ob-C.el")
(require 'ob-C)
;; load the languages that are needed
(org-babel-do-load-languages
'org-babel-load-languages '((C . t)))
Its still not working.
The code that i am trying to evaluate in an orgmode buffer is :
#+BEGIN_SRC c
printf("Hello world");
#+END_SRC
My Messages buffer looks like this after restarting emacs and attempting to execute the above code block :
Loading /home/taeten/.emacs.d/lisp/ob-C.el (source)...done
Wrote /home/taeten/.emacs.d/.emacs.desktop.lock
Desktop: 1 frame, 0 buffers restored.
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [2 times]
Making completion list... [3 times]
org-babel-execute-src-block: No org-babel-execute function for c! [5
times]
Ignoring unknown mode `elisp-mode'
File local-variables error: (void-function elisp-mode)
byte-code: Beginning of buffer [6 times]
byte-code: Beginning of buffer
load
andrequire
bits.require
does loading (in case the file has aprovide
statement, which in this case it does), but you also don't need therequire
because this is handled byorg-babel-do-load-languages
, you do need to make sure to requireorg
before any of that happens. Also, I think it'sC
notc
, did you try that?