Hi Floh,
Thanks for the reply.
I have surrounded the includes like this:
extern "C" {
#include <Standard_Integer.hxx>
#include <IGESControl_Reader.hxx>
}
but it still doesn't compile. I get the following errors (I paste only one,
but there are more like this):
In file included from simple.cpp:4:
In file included from /opencascade-7.3.0/cmake-bin/include/opencascade/
Standard_Integer.hxx:1:
/opencascade-7.3.0/src/Standard/Standard_Integer.hxx:55:25: error:
conflicting types for 'HashCode'
inline Standard_Integer HashCode(const long long int theMe,
^
/opencascade-7.3.0/src/Standard/Standard_Integer.hxx:36:25: note:
previous definition is here
inline Standard_Integer HashCode (const Standard_Integer theMe,
Maybe the issue is how I compiled OpenCASCADE? How can I force it to use
C++? *.hxx look like C++ headers.
Thanks,
Pau
On Thursday, December 13, 2018 at 2:11:56 PM UTC+1, Floh wrote:
>
> I might be wrong but that looks like a missing 'extern "C" { }' problem.
> I'm stumbling over this from time to time myself in my own code when mixing
> C++ and C, and it is indeed baffling, at least when using clang :)
>
> If OpenCascade is compiled as a C library it will export its functions
> with an underscore (e.g. _BRepBuilderAPI_MakeShape). But if you're
> including the OpenCascade's C headers into C++ code, and the header isn't
> surrounded by an extern "C"... the compiler will expect C++ name mangled
> function exports (e.g. _XYZXWBRepBuilderAPI_MakeShape), the linker will
> still complain about a missing BPRepBuilderAPI_MakeShape function, because
> it only finds the C library export _BPRepBuilder... (and AFAIK the clang
> linker doesn't mention the C++ name mangling parts, and that's what's so
> confusing).
>
> TL;DR: surround all C header includes with an 'extern "C" { }' (the usual
> fix is to do this right in the headers though:
>
> #ifdef __cplusplus
> extern "C" {
> #endif
> ...
> #ifdef __cplusplus
> } /* extern "C" */
> #endif
>
> Cheers,
> -Floh.
>
> On Wednesday, 12 December 2018 11:05:04 UTC+1, [email protected] 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 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].
>>>> > 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.