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

  • SEARCH
  • Home
  • 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 8234125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:22:23+00:00 2026-06-07T18:22:23+00:00

My C++ Library function is int RFD_startBackgroundThread() My code in the overlay.js is uri

  • 0

My C++ Library function is int RFD_startBackgroundThread()
My code in the overlay.js is

uri = addon.getResourceURI("components/mac/libReverbFirefoxExtensionLib.dylib");
this.extensionLib = ctypes.open(uri.path);
this.startBackgroundThread = this.extensionLib.declare("RFD_startBackgroundThread", ctypes.default_abi, ctypes.unsigned_int);

The code throws an exception on the last line. It says “Couldn't find function symbol in library“.

The library is a “fat dylib binary” combining both i386 and x86_64 (but not PPC arch) on OS X Lion (10.7). Firefox version 11.

Desperately need help.
Thanks.
Rahul.

  • 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-07T18:22:24+00:00Added an answer on June 7, 2026 at 6:22 pm

    In most Unix platforms, including OS X, C functions are mapped to symbols just by prefixing with an underscore, so int foo(int) ends up as just _foo.

    But that doesn’t work for C++, because in C++, you can have two different functions with the same name, in a variety of different ways—you can have int foo(int) and double foo(double), or int MyClass::foo(int), or int foo<int>(int), and so on. So, C++ functions have to be “mangled” to give a unique string. (And then, that unique string is treated like a C function—that is, prefixed with an “_”.)

    jsctypes knows about knocking off the _, but it can’t know how to mangle your function, because you’re just giving it a name, not a full prototype. So, you have to figure out in some other way that the mangled name of your function is _Z25RFD_startBackgroundThreadv.

    There’s no portable standard for how names get mangled. However, the C++ ABI that Apple uses is based on the Itanium C++ API, which requires an API to mangle and demangle C++ functions. Xcode comes with a tool called c++filt that wraps up that API for use at the command line—but it only handles demangling, not mangling. So, it can tell you that _Z25RFD_startBackgroundThreadv means RFD_startBackgroundThread(), but it can’t get the other way around.

    One way to get the mangled name is to start with nm libfoo.dylib, then use c++filt to check the ones that look like good candidates, until you find one that matches the prototype you’re looking for.

    Another way is to automate that. Something like this:

    nm libfoo.dylib | awk 'NF==2 {printf "%s ",$1; system("c++filt " $2)} NF!=2{print $0}'
    

    … will print the demangled names of all of your symbols.

    But probably the best way to go about it is to create a tiny .cpp file that has nothing in it but that one prototype, compile it, and use “otool -SV tiny.a” to see the mangled name.

    So, it’s not that hard to get the name of the symbol for the C++ function you want to call.

    But that doesn’t mean you can just call it as if it were a C function. For one pretty obvious example, if you want to call (non-static) Foo::bar(int), you’d better have a valid thing to pass as a “this” pointer, and know how to pass it. See https://bugzilla.mozilla.org/show_bug.cgi?id=505907 for details on what jsctypes in Mozilla can’t do, and why.

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

Sidebar

Related Questions

I'm trying to PInvoke into this C++ library function: int Initialize(Callback* callback); struct Callback
I'm looking at the RegisterHotKey Function: http://msdn.microsoft.com/en-us/library/ms646309(VS.85).aspx BOOL RegisterHotKey( __in HWND hWnd, __in int
The standard SML library function Int.toString prefixes negative numbers with ~ instead of -
Yet another one of my P/Invoke questions! I have this C function: int _ei_x_new(ei_x_buff*
I am using the library Function ConnectToTCPServer . This function times out when the
in pthread library it is possible to find non blocking function: int pthread_mutex_trylock(pthread_mutex_t *mutex);
I have one function extern C int ping(void) in a C++ static-library project. Now,
I'm sorry if this is too entry-level, but I tried implementing the library function
A library function parses a file and returns an object. If a parser encounters
I am using a library function called get_count_and_price which returns a 2-tuple (count,price). In

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.