Looks like it's executing g++ there? emconfigure tries to make configure use emcc/em++ instead of the native toolchain (typically gcc/g++), by setting env vars (CC, CXX, etc.) but maybe that build system isn't configurable that way? Or, emconfigure has some situations where it falls back to using the native toolchain, for things it knows it can't do in JS (that code is in emcc.py, search for 'configure').
The resulting error, I suspect, is since libgmp.so.10 contains LLVM bitcode (can run the "file" utility on it, to see), which is what emscripten would emit. And g++ can't handle that since it expects native code. The configure script might need to be modified. For example you might hardcode the right results, instead of making it do checks. Another option is to avoid using the configure script, and write a new and simpler Makefile (or CMake, etc.). That's what I generally do if things don't just work out of the box. A lot of the complexity of configure scripts is unnecessary, I believe, if you just want things to work on a modern linux or os x. On Wed, Mar 16, 2016 at 10:12 AM, M. B. <[email protected]> wrote: > Hi, > > Thank you for your reply. I actually started porting from the beginning, > as my environment got a bit messed up. > A detail I forgot to mention earlier was that the NTL library also depends > on GMP library. > > So this is what I have done so far: > *GMP Setup* > I ran emconfigure ./configure --disable-assembly (otherwise emconfigure > fails because of files with .s extension), then "emmake sudo make" and > "emmake sudo make install". > > Running "emmake make check" gives me a ton of warnings like "ignoring > dynamic library libgmp.so because not compiling to JS or HTML, remember to > link it when compiling to JS or HTML at the end" and all the tests fail, > but as far as I understand from documentation, this shouldn't be an issue. > > This produces the following files in my /usr/local/lib: libgmp.a, > libgmp.la, libgmp.so (a symbolic link to libgmp.so.10.3.0, which contains > LLVM bitcode). > > *NTL Setup* > The issues now begin when running "emconfigure ./configure > NTL_GMP_LIP=on". The NTL_GMP_LIP option is necesarry for linking both > libraries together. > This is the output: > *** checking -march=native flag > CXXAUTOFLAGS=" -march=native" > g++ -I../include -I. -march=native -g -O2 -o CheckCompile > CheckCompile.c -lm > /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus: error while loading shared > libraries: /usr/local/lib/libgmp.so.10: invalid ELF header > make: *** [CheckCompile] Error 1 > *** -march=native does not work > CXXAUTOFLAGS="" > > > I am still unsure of how to proceed now. Could you please explain this > some more? As far as I understand, this is an issue with dynamic linking? > > Regards, > M.B. > > > Dne ponedeljek, 14. marec 2016 19.47.17 UTC+1 je oseba Alon Zakai napisala: >> >> 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. > -- 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.
