A file named myCFuntionsForUnix.so is successfully created. This native file can be placed in any folder of an addon and then loaded from js-ctypes. They can also be loaded from the system library path.

Loading the native file

If your addon is restartless, you must set it to be unpacked. See: http://stackoverflow.com/questions/19382201/how-to-load-dll-from-sdk-addon-data-folder

It is important to note that custom native files cannot be loaded through chrome:// or resource:// URIs. They must be accessed through a local file path (file://) or a JAR path (jar:). If the addon is an unpacked addon, such as bootstrap or Add-on SDK addons, the JAR path must be used. Therefore, the path has to be converted and then the converted path is used for loading with ctypes.open.

If the native file is located at chrome://youraddon/content/mySubFolder/myCFunctionsForUnix.so then it is converted to a File URI like this:

If your add-on is a bootstrap add-on, then you don't need to use this method to convert a chrome:// path; instead, on startup procedure of the bootstrap add-on obtain the File and/or JAR path from installPath from the aData parameter.

function startup(aData, aReason) {
var nsIFile_folder = aData.installPath; // if addon is unpacked, this will be the addon folder. if addon is packed, this will be addon xpi
}

This can then be joined with your file name to obtain it's path like this: