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++".


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


((emacs-lisp . t)
 (C . t)
 (css . t)
 (sh . t)
 (awk . t)
 (R . t))))


;; 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-load-languages '((C . t)))

Its still not working.

The code that i am trying to evaluate in an orgmode buffer is :

printf("Hello world");

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   
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
  • 2
    You really don't need the load and require bits. require does loading (in case the file has a provide statement, which in this case it does), but you also don't need the require because this is handled by org-babel-do-load-languages, you do need to make sure to require org before any of that happens. Also, I think it's C not c, did you try that? – wvxvw Oct 30 '15 at 16:43
  • 3
    ohh damn... it worked ! C (not c) and C++ (not c++) inside the #+BEGIN_SRC block was what it took after having done all the 'load' statements in the right order. Thanks a lot man ! – Arjun J Rao Oct 31 '15 at 1:46

You really only need this bit in your init file:

 'org-babel-load-languages '((C . t)))

Note it's a capital C. This enables Babel to process C, C++ and D source blocks.

  • 3
    Its not working still. I tried removing the earlier ob-c.el crap too. Still not working. Same error message "No org-babel-execute function for c++" – Arjun J Rao Oct 27 '15 at 13:25
  • 1
    @ArjunJRao did you evaluate the code after adding it? (It's ok to evaluate it multiple times). The error message technically means that it couldn't find org-babel-execute:c++ function, which would be defined in ob-C.el, but the way to tell Babel that it needs to load ob-C.el is to call org-babel-do-load-languages. – wvxvw Oct 27 '15 at 14:30
  • i updated my question. – Arjun J Rao Oct 29 '15 at 5:06
  • I've just bumped into this myself, the issue is that you been "#+begin_src C" with a capital C as well as all capital C in the configuration as mentioned prior. It provides C syntax highlighting without the lower c, making it hard to realize – syntaxError Sep 30 '20 at 19:20

It should be a capital 'C' not a lower case 'c' for the name of the source code block.


After solving this independently, I noticed @syntaxError also posted this solution above in the comments for @wvxvw's answer. I am submitting it here as an answer because it might be hard to see in a comment on an answer.

  • Thanks. Yes, Q&A needs to be in the Q&A. Comments aren't searchable, and they can be deleted at any time. – Drew Nov 14 '20 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.