Extending Google Chrome using NaCL with external library

I am developing a google chrome extension using NaCL. It's pretty cool and easy to use, but I have my doubts.

My extension requires GPGME (GnuPG Made Easy), so I will compile this library with the "--enable-shared" option and add the library to the .mnf file:

{
    ...
    "files": {
        "libgpgme.so": {
            "x86-64": {
                "url": "libs/libgpgme.so"
            },
            "x86-32": {
                "url": "libs/libgpgme.so"
        }
    }
    ...
}

      

I also update the makefile with the '-lgpgme' parameter, but when I compile my .nexe I have the following erro: "libgpgme.so: file not recognized: file format not recognized".

So my questions are:

  • Can I use an external library with my project?
  • How can i do this?

- Hooray, Jose

+2


source to share


2 answers


Since Inative CLient's internal sandbox is based on binary validation, you need to compile libgpgme using the Native Client tools. In general, the Native Client should validate any code before executing it, including any libraries, whether statically or dynamically linked. The easiest way to generate binaries that can be verified is using the Native Client compilers.

Porting for native client: Since libgpgme uses autotools and specifically configure, you will need to advertise the NaCl platform for them by adding a section like this in the basic_machine part of the config.sub file, which should be somewhere in the libgpgme source tree:

   nacl*)
           basic_machine=i686-pc
           os=-nacl
           ;;

      

and adding

  -nacl*

      



to the os section of the same file. An example of a particularly clean port is libogg. You can see the whole patch at http://code.google.com/p/naclports/source/browse/trunk/src/libraries/libogg-1.1.4/nacl-libogg-1.1.4.patch . (Strictly speaking, config.sub is generated from configure.in, but it's often better to edit config.)

Porting more than this first step, so some guides and pointers to existing ports follow to get you a feel for how it's done.

Guides: For more information, there are several posthumous ported at https://developers.google.com/native-client/community/developers . In particular, about XaoS at https://developers.google.com/native-client/community/porting/xaos has a short section on autotests.

Existing ports: In addition, there is a local repository for its own client called naclports. It contains several libraries that have already been ported, but unfortunately not yet libgpgme. A list of libraries in naclports can be seen at http://code.google.com/p/naclports/source/browse/trunk/src/libraries/ . While it contains useful examples of how to make ports, naclports is not for the faint of heart as it breaks frequently and given that it is maintained on a volunteer / best effort basis it may take time to fix.

+3


source


You need to port libgpgme to NaCl first. That is, libgpgme must be compiled with the NaCl compiler, not the Linux compiler.



GPGME uses configure. Thus, porting is usually done by passing the wrapping scripts as the compiler. These scripts replace the NaCl programs generated by the NaCl compiler with a script that calls them through sel_ldr. This way configure can run compiled NaCl programs like normal Linux.

+1


source







All Articles