WebGL Build Problem : error: duplicate symbol: PLUGINFACTORY

I wanted to add the function that import step file and export xmlocaf file in webgl demo. Add Include Files:

#include <STEPCAFControl_Reader.hxx>
#include <TDocStd_Document.hxx>
#include <BinDrivers.hxx>
#include <TDocStd_Application.hxx>
#include <XmlDrivers.hxx>

The Code:

Handle(TDocStd_Application) App=new TDocStd_Application();
XmlDrivers::DefineFormat(App);
Handle(TDocStd_Document) Doc=new TDocStd_Document("XmlOcaf");
STEPCAFControl_Reader Reader;
STEPControl_Reader StepReader = Reader.Reader();
StepReader.ReadStream(theName.c_str(), aStream);
Reader.Transfer(Doc);
std::ostringstream str;
App->SaveAs(Doc,str);
ConsoleLog(str.str());

When building,the make program throwed errors:

Linking CXX executable occt-webgl-sample.js
wasm-ld: error: duplicate symbol: PLUGINFACTORY
>>> defined in D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKXml.a(XmlDrivers.cxx.o)
>>> defined in D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/lib/libTKXmlL.a(XmlLDrivers.cxx.o)

Are there some functions that can't be used in WebGL?

Kirill Gavrilov's picture

These PLUGINFACTORY symbols shouldn't appear in libraries unless you've built OCCT without BUILD_LIBRARY_TYPE="Static" option.

Lee Dongming's picture

Hi~Kirill Gavrilov.

Thanks for your reply!

I am sure that the BUILD_LIBRARY_TYPE parameter is set with Static when building OCCT Static Libraries.

If we remove the include file and the code such as:

//include file
#include <XmlDrivers.hxx>
//code
XmlDrivers::DefineFormat(App);

the make program will build successfully.

Built target occt-webgl-sample
Install the project...
-- Install configuration: ""
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.js
-- Installing: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.wasm
-- Up-to-date: D:/Download/emsdk-main/upstream/emscripten/cache/sysroot/occt-webgl-sample.html
Attachments: