Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to find a way to call Javascript functions from C. Are there any language bindings available for this purpose? I'm trying to make a library of Javascript functions accessible from C. (Something like a C -> Javascript foreign function interface would be suitable for this purpose, but I haven't been able to find one so far.)

share|improve this question
There are a few Javascript-to-C++ bindings available, but I need my Javascript functions to be invoked from C, not C++. – Anderson Green Aug 2 '12 at 17:13
Javascript doesn't make much sense without an engine. What exactly is the problem you're trying to solve here? Code reuse, or browser automation? – Jordan Aug 2 '12 at 17:19
I'm w/ @Jordan, what is the problem you are trying to solve? What platforms? Why C and not C++? – DevSolo Aug 2 '12 at 18:07
I'm aiming for code reuse, not browser automation. – Anderson Green Aug 2 '12 at 18:10
Also, I'd like it to be cross-platform. – Anderson Green Aug 2 '12 at 18:11
up vote 3 down vote accepted

There's quite a few Javascript engines you can use. Which one makes most sense will largely depend on your specific platform/target environments/needs.

There's the V8 javascript engine that powers Chrome, and Firefox's SpiderMonkey.

If Windows-only would suffice, you can use Active Scripting (IActiveScript site and other interfaces). A number of my Windows applications do this.

If QT, I believe they have their own JavaScript classes that can be accessed.

Thats not an exhaustive list, I'm sure there are others. But that should get your search started.

share|improve this answer
+1 for V8. I think that it's written in C++, you you could probably pretty easily wrap it in a C interface (if it doesn't have already). – Linuxios Aug 3 '12 at 13:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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