I'm trying to get bindings to OCCT working (an old and large C++ CAD kernel) I'm finding I can't build a minimal project if certain headers are included in my ffi.cpp, the error is undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE.
importLakeopenLakeDSLSystemdeflink_libs:=#["stdc++","TKernel","TKBRep","TKMesh","TKTopAlgo","TKGeomBase","TKGeomAlgo","TKOffset","TKG3d","TKG2d","TKMath","TKBO","TKFillet","TKService","TKPrim","TKSTL","TKStd","TKV3d","TKRWMesh","TKLCAF","TKXCAF","TKShHealing","TKXSBase","TKSTEP"]package«Keyboard»where-- add package configuration options hereprecompileModules:=truelean_lib«Keyboard»whereprecompileModules:=truetargetocct.opkg:FilePath:=doletoFile:=pkg.buildDir/"native"/"leanocct.o"letsrcJob←inputFile<|pkg.dir/"C"/"ffi.cpp"letflags:=#["-I",(←getLeanIncludeDir).toString,"-I","/usr/include/opencascade"]++link_libs.foldl(·++#["-l",·])#[]++#["-fPIC"]buildO"ffi.cpp"oFilesrcJobflagsextern_liblibleanffipkg:=doletname:=nameToStaticLib"leanocct"letffiO←fetch<|pkg.target``occt.obuildStaticLib(pkg.nativeLibDir/name)#[ffiO]@[default_target]lean_exe«keyboard»whereroot:=`Main-- Enables the use of the Lean interpreter by the executable (e.g.,-- `runFrontend`) at the expense of increased binary size on Linux.-- Remove this line if you do not need such functionality.supportInterpreter:=true
Looking through the offending headers, apart from the fact one throws an exception, I can't see why some will build and some won't?
I am also getting this problem with a header only json library which uses modern c++ features, do I need to wrap everything in a c interface before I start linking it to lean?
The general suggestion in these cases is to link in the foreign parts dynamically so as to avoid any conflicts with Lean's own copy of the C++ stdlib. There are some older threads about this approach.