Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7720757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:45:06+00:00 2026-06-01T03:45:06+00:00

Summary I have looked over the code the SpiderMonkey ‘shell’ application uses to create

  • 0

Summary

I have looked over the code the SpiderMonkey ‘shell’ application uses to create the ctypes JavaScript object, but I’m a less-than novice C programmer. Due to the varying levels of insanity emitted by modern build systems, I can’t seem to track down the code or command that actually links a program with the desired functionality.


method.madness

This js-ctypes implementation by The Mozilla Devs is an awesome addition. Since its conception, scripting has been primarily used to exert control over more rigorous and robust applications. The advent of js-ctypes to the SpiderMonkey project, enables JavaScript to stand up and be counted as a full fledged object oriented rapid application development language flying high above ‘the bar’ set by various venerable application development languages such as Microsoft’s VB6.


Shall we begin?

I built SpiderMonkey with this config: ./configure –enable-ctypes –with-system-nspr

followed by successful execution of: make && make install

The js shell works fine and a global ctypes javascript object was verified operational in that shell.

Working with code taken from the first source listing at How to embed the JavaScript Engine -MDN, I made an attempt to instantiate the JavaScript ctypes object by inserting the following code at line 66:

    /* Populate the global object with the ctypes object. */
    if (!JS_InitCTypesClass(cx, global))
        return NULL;
    /*

I compiled with: g++ $(./js-config –cflags –libs) hello.cpp -o hello

It compiles with a few warnings:

hello.cpp: In function ‘int main(int, const char**)’:
hello.cpp:69:16: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
hello.cpp:80:20: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
hello.cpp:89:17: warning: NULL used in arithmetic [-Wpointer-arith]

But when you run the application:

./hello: symbol lookup error: ./hello: undefined symbol: JS_InitCTypesClass

Moreover

JS_InitCTypesClass is declared extern in ‘dist/include/jsapi.h’, but the function resides in ‘ctypes/CTypes.cpp’ which includes its own header ‘CTypes.h’ and is compiled at some point by some command during ‘make’ to yeild ‘./CTypes.o’. As I stated earlier, I am less than a novice with the C code, and I really have no idea what to do here.

Please give or give direction to a generic example of making the js-ctypes object functional in an embedding.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:45:07+00:00Added an answer on June 1, 2026 at 3:45 am

    The problem: Most platform distributors are ignorant to recommendations given by code developers. Therefore js-ctypes are not enabled for mozjs185 on most if not all systems hosting the library. This leaves some issues for you to sort out.

    After you have configured with –enable-ctypes and –with-sytem-nspr followed by make and then make install (might need to be root for last command)

    You will likely have two versions of libmozjs185.so on your system. One with ctypes enabled (located in /usr/local/lib) and one without ctypes enabled (located in /usr/lib).

    You, as per the question, want to link against the library with ctypes. So that’s what you do by specifying: -L/usr/local/lib -lnspr4 -lmozjs185 to your compiler. It will compile ok. But when the application runs, the os library loader will load the first instance of the library that it finds. Unfortunately this will likely be the library located in /usr/lib and this version likely does not have ctypes enabled. That’s where you’ll run into this [solved] problem: g++ Undefined Symbol Error using shared library

    The bottom line is this: multiple versions of the same library is creating one hell of an issue. The best way to provide js-ctypes to a spidermonkey embedding is therefore linking in the ctypes enabled static version of mozjs185 to your program unless you want to write a library for dealing with multiple platform libary loaders, or create your own (rebranded version of mozjs185) which I have covered in great detail over @ SpiderMonkey Build Documentation – MDN

    To perform the static linking you will need to use these parameters with g++:
    -lnspr4 -lpthread -lmozjs185-1.0 provided that you have built and installed the development package correctly. This is the ‘best’ (platform independant) way to provide js-ctypes to a spidermonkey embedding. Although this does increase the size of your application by at least 3.5 MB. If you have built the debug version it could be more than 15 times larger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

--Summary (shortened)-- I have a controller that loads a profile object from the corresponding
I have an object Title : foo Summary : foo bar Body : this
Summary I have written a process monitor command-line application that takes as parameters: The
Summary We have an ASP.NET application that allows users to query a SQL Server
I have the following code to create a new calendar for a gmail contact:
I have code that contains: @Html.ValidationSummary(true) I looked at the MSDN site and still
Quick summary: I have a Rails app that is a personal checklist / to-do
I need to have a summary field in each page of the report and
I have column named summary (tinytext, utf8_turkish_ci). I know it can store 255 byte
Summary A parent can have many children. How do you write a service such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.