I don't know how to do static linking, it gives me a lot of errors when trying, is there any documents on how to accomplish this?
The static linking option in the official cmake script is not really maintained right now, I had a to make a bunch of changes to the codebase in order to successfully static link it, or you get lots of errors.
In the cegui-emscripten project I did make those changes but I didn't make a pull request to send them back upstream (yet). I may do that at some point. I'm not sure if the way I'm fixing it would be officially sanctioned.
Also in that project I'm not using the official cmake, I'm using a smaller, simplified one that just has a single compilation unit for the whole CEGUI lib.
As I recall these are the things that I needed to do:
1) Use the `CEGUI_STATIC` define, and also the `CEGUI_STATIC_FACTORY_MODULE` define.
2) You will get compiler errors because of some apparent programmer errors. I reported these bugs here:
https://bitbucket.org/cegui/cegui/issue ... gui-staticWhen CEGUI builds "normally" as a collection of dynamic libs, the main lib must find the other libs at runtime and grab the appropriate symbols from them (using `dlsym`) so that they can be used. When CEGUI is instead built as one unit, instead of `dlsym` there are some global `getter` functions defined that produce references to various singleton objects, which provide the same functionality that be found via the `dlsym`.
But this part needs to be fixed up apparently, for instance, some of these getter functions are marked `extern "C"` when they cannot be `extern "C"` due to using C++ references... there is no compiler for which this code could ever have compiled. Instead such functions should be declared `extern` in a header and then defined normally in a compilation unit to return a reference, or refactored to use pointers so that they can actually be `extern "C"`.
I believe I only needed to fix up the code in this regard for the "WindowFactoryModule" and the "ImageCodecModule". Maybe also the XML parser module, I don't remember.
3) You will get link time errors because in CEGUI there are many .cpp files that have identical names. For instance, there is `src/ImageCodec.cpp`, and also, `src/ImageCodecModules/SILLY/ImageCodec.cpp`. This apparently causes problems when static linking. To fix it, I simply stick an underscore arbitrarily at the end of some of the filenames, so `src/ImageCodec_.cpp`. Since *my* cmake file works by globbing .cpp files from the source tree this makes no difference -- otherwise you probably have to update CMakeLists.txt also to reflect your changes.
I don't believe there were any other problems after that.