Yeah, this is an area where things are different than regular native builds, so it can be confusing.
The simplest solution is to build the 2 support libraries into bitcode, and not all the way to js. And then to link them in in that last build command and build them all together into js. For example, if you have ntl.a, ntl.bc, or ntl.o for NTL, then just adding ntl.a or ntl.bc etc. to the final build command should work. Or, -lntl should work as well, it will look for those suffixes. (And it will require that they contain LLVM bitcode, which emcc/em++ will emit for object files and libraries.) More details here: http://kripken.github.io/emscripten-site/docs/compiling/Building-Projects.html#using-libraries That's for static linking of bitcode. There is also a way to do dynamic linking of js files, but it's trickier and generally not recommended, https://github.com/kripken/emscripten/wiki/Linking On Sun, Mar 13, 2016 at 10:01 AM, M. B. <[email protected]> wrote: > Hi, > > I am new to emscripten and have a few questions. > > My setup is the following: I have a C++ encryption library that depends on > two other libraries, GMP and NTL. I would like to call a program that uses > this encryption library from JavaScript source. If I understand correctly, > all three of my libraries have to be ported in order to be able to do that. > I ported all three libraries using emconfigure and emmake, so I have 3 > javascript files now: gmp.js, ntl.js and fhe.js (this is the one I want to > use). > > Now I have a program that uses this FHE library. I want to expose it's > "main" function so it can be called with arguments from JavaScript. > > Here is what confuses me: > In order to compile a program (without emscripten) that uses this FHE > library, I have to run the following command: > > g++ -g -O2 -o helloWorld helloWorld.cpp fhe.a -L/usr/local/lib -lntl > -lgmp -lm > > > I am lost since I can't figure out how exactly to link these ported > libraries together. I know it's probably completely wrong, but I tried this: > > em++ -g -O2 -o helloWorld helloWorld.cpp fhe.a -L/usr/local/lib -lntl -lgmp > -lm -I/usr/local/include > > > and it gives me 20+ errors regarding the use of "undeclared identifiers". > > I appreciate any advice and help. > Thank you in advance, > M.B > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
