Hi, So I managed to do the whole compilation. I basically compiled OpenCASCADE as a dynamic library and make sure that Emscripten generated bitcode. Then, when compiling, I had to do what Sam mentioned, which is explicitly include all the dependencies of the package that I was using.
Thanks to all of you for your help! Pau On Thursday, December 13, 2018 at 11:28:00 PM UTC+1, Sam Clegg wrote: > > On Wed, Dec 12, 2018 at 2:05 AM <[email protected] <javascript:>> > wrote: > > > > I've been taking a look at it, and I've been trying to compile without > CMake like: > > > > emcc --bind -o simple.js simple.cpp > -I./opencascade-7.3.0/cmake-bin-dyn/include/opencascade > -L./opencascade-7.3.0/cmake-bin-dyn/lin32/clang/lib -lTKIGES -std=c++11 > > > > I have tried with dynamic (.so) and static (.a) OpenCASCADE compiled > libraries, but neither work. I still get the undefined symbol error. Then, > I run > > > > nm libTKIGES.so | grep BRepBuilderAPI_MakeShape > > > > to get if the symbol is defined and indeed I get that it's not > > > > U _ZTV24BRepBuilderAPI_MakeShape > > > > It is weird because if I do the same command with the clang mac .dylib, > I also get the same symbols as undefined. > > > > If you run it through `c++filt` it will tell you that > _ZTV24BRepBuilderAPI_MakeShape is "vtable for > BRepBuilderAPI_MakeShape". > > Perhaps this symbol is part of another shared library? I would look > at what other shared libraries your native libTKIGES.so depends on (on > linux you would use `ldd` to show this but on max its probably some > kind of objdump tool). Find that one that contains this symbol and > make sure you are building and linking against that too. > > Remember when you link against a static library you need to explicitly > mention all of its transitive dependencies on the link line. This is > different to linking against a dynamic library. > > > If I try to compile with the flag -s ERROR_ON_UNDEFINED_SYMBOLS=0 > compilation succeeds, but when launching the JS code I get errors and it > doesn't work. > > > > Any ideas? > > > > On Tuesday, December 11, 2018 at 3:56:18 PM UTC+1, [email protected] > wrote: > >> > >> Hello, > >> > >> So I've managed to compile OpenCASCADE, by disabling some components > with 3rd party dependencies that I didn't need and explicitly including > sys/utsname.h. Now I'm facing the problem I was already mentioning: I am > not able to compile my own program with CMake (I get the undefined symbol > error). How can I specify that I should use the OpenCASCADE libraries that > I've compiled? > >> > >> I see in the example on Emscripten's website that it doesn't specify > that and it links the two parts in a third step like: > >> > >> emcc project.bc libstuff.bc -o final.html > >> > >> > >> Thanks! > >> > >> > >> On Monday, December 10, 2018 at 10:53:41 PM UTC+1, Sam Clegg wrote: > >>> > >>> On Mon, Dec 10, 2018 at 9:11 AM <[email protected]> wrote: > >>> > > >>> > Hello, > >>> > > >>> > I have a simple C++ code that makes use of some of the APIs of > OpenCASCADE, and I have successfully run compiled with clang in macOS. I > want to call the functions implemented in my C++ codebase, so I'm using > wasm for it (I already have some code that does not call OpenCASCADE > working in a browser). > >>> > > >>> > Normally, I compile my C++ code using CMake: > >>> > > >>> > cmake_minimum_required(VERSION 3.12) > >>> > project(oc_test) > >>> > > >>> > set(CMAKE_VERBOSE_MAKEFILE on) > >>> > set(CMAKE_CXX_STANDARD 14) > >>> > > >>> > include_directories(/usr/local/include/opencascade) > >>> > link_directories(/usr/local/lib) > >>> > > >>> > add_executable(oc_test_bin CMakeLists.txt main.cpp) > >>> > > >>> > target_link_libraries(oc_test_bin TKernel TKXSBase TKIGES TKBrep > TKGeomBase TKTopAlgo TKG3d) > >>> > > >>> > > >>> > If I try to compile the former project with > >>> > > >>> > emconfigure cmake . > >>> > > >>> > emmake make > >>> > > >>> > it compiles fine, but on the linking stage I get warnings such as > >>> > > >>> > error: undefined symbol: > _ZN11GeomConvert23SurfaceToBSplineSurfaceERKN11opencascade6handleI12Geom_SurfaceEE > > > >>> > warning: To disable errors for undefined symbols use `-s > ERROR_ON_UNDEFINED_SYMBOLS=0` > >>> > error: undefined symbol: > _ZN13Standard_Type8RegisterEPKcS1_mRKN11opencascade6handleIS_EE > >>> > error: undefined symbol: _ZN16Standard_Failure16SetMessageStringEPKc > >>> > error: undefined symbol: _ZN16Standard_FailureC2EPKc > >>> > > >>> > Which indeed refer to the symbols the OpenCASCADE library. > >>> > > >>> > On the other hand, I'm trying to compile OpenCASCADE so I can get > the .bc files to link, but I don't manage to do that. I download the source > code, and I fail to build the CMake project. When doing > >>> > > >>> > emconfigure cmake . > >>> > > >>> > the system doesn't find FreeType neither TCL-TK: > >>> > > >>> > Could not find headers of used third-party products: > >>> > 3RDPARTY_TCL_INCLUDE_DIR 3RDPARTY_TK_INCLUDE_DIR > >>> > 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build > >>> > 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 > >>> > > >>> > Then, if I disable USE_TCL and USE_FREETYPE, I manage to generate > the Makefile, but when compiling I get the following error: > >>> > > >>> > [ 1%] Building CXX object > src/TKernel/CMakeFiles/TKernel.dir/__/OSD/OSD_Path.cxx.o > >>> > opencascade-7.3.0/src/OSD/OSD_Path.cxx:45:18: error: variable has > incomplete type > >>> > 'struct utsname' > >>> > struct utsname info; > >>> > ^ > >>> > opencascade-7.3.0/src/OSD/OSD_Path.cxx:45:10: note: forward > declaration of 'utsname' > >>> > struct utsname info; > >>> > ^ > >>> > 1 error generated. > >>> > ERROR:root:compiler frontend failed to generate LLVM bitcode, > halting > >>> > make[2]: *** > [src/TKernel/CMakeFiles/TKernel.dir/__/OSD/OSD_Path.cxx.o] Error 1 > >>> > make[1]: *** [src/TKernel/CMakeFiles/TKernel.dir/all] Error 2 > >>> > make: *** [all] Error 2 > >>> > > >>> > Any ideas on what might be causing this? > >>> > >>> `struct utsname` is defined in `sys/utsname.h` which is availing in > >>> emscripten. Perhaps this header is not correctly being detected > >>> during cmake therefore not bring included? Perhaps the code is simply > >>> failing to include this header and relying on its transitive inclusion > >>> on other platforms? > >>> > >>> > >>> > > >>> > Thanks! > >>> > > >>> > -- > >>> > 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] > <javascript:>. > >>> > 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] <javascript:>. > > > 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.
