In this note I will describe the assembly of a project consisting of several libraries using Emscripten.
At the moment Emscripten does not support building shared libraries, so the first thing we do is convert all libraries from Shared to Static. Emscripten works with its own include files, so we need to solve the issue with the visibility of header files, I solved this by forwarding a symlink from the system directory to the Emscripten toolchain:
ln -s /usr/local/include/FlameSteelFramework $EMSDK/fastcomp/emscripten/system/include/FlameSteelFramework
If you use CMake, you need to change SHARED->STATIC in the CMakeLists.txt file of the add_library method. You can build a library/application for further static linking using the commands:
emcmake cmake .
emmake make
Next, you will need to build the main application specifying *.a library files at the linking stage. I was unable to specify a relative path, the build completed correctly only after specifying the full paths in the CMakeLists.txt file:
elseif(EMSCRIPTEN)
target_link_libraries(${FSEGT_PROJECT_NAME} GL GLEW
/home/demensdeum/Sources/cube-art-project-bootstrap/cube-art-project/sharedLib/libCubeArtProject.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FlameSteelEngineGameToolkitFSGL/libFlameSteelEngineGameToolkitFSGL.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FlameSteelEngineGameToolkit/libFlameSteelEngineGameToolkit.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FlameSteelCore/libFlameSteelCore.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FlameSteelBattleHorn/libFlameSteelBattleHorn.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FSGL/libFSGL.a
/home/demensdeum/Sources/cube-art-project-bootstrap/FlameSteelFramework/FlameSteelCommonTraits/libFlameSteelCommonTraits.a)
else()
Sources
https://emscripten.org/ docs/compiling/Building-Projects.html#using-libraries