Compile wt c++ project as shared object .so
Hi, I would like to compile a wt c ++ project as a dynamic library, shared object .so
My goal is to have a main project compiled to generate an executable to operate as web server, plus other shared object .so projects (that contains wt code) that are dynamically loaded.
My operating system is Scientific Linux 7.9 and I compile with gcc version 4.8.5
How can I do this? What build parameters should I add to the gcc?
RE: Compile wt c++ project as shared object .so - Added by Wim Dumon 4 months ago
There's nothing really Wt specific to your question. If you put the entire web UI in a so file: build a .so file that links to Wt, and instead of a main() method, create an (visible) entry method for your .so file. In that entry method, call WRun() or include code similar to WRun() (see its implementation in the documentation of WServer).
In your application, open the .so file by calling dlopen(), use dlsym() to find the entry symbol, and call the function.
You can consider any variation on this technique, where e.g. only widgets are contained in the .so file, or application objects, ... and you express your interface in terms of functions that create those objects.
RE: Compile wt c++ project as shared object .so - Added by eda srl 4 months ago
I tried to create a main project and a dynamic .so file; the two projects contain wt code.
When I try to call the .so file using dlopen () and dlsym (), I get an error: "cannot dynamically load executable".
Trying to edit the .so file, I see that it is an ELF 64-bit LSB executable, not an LSB shared object.
If, on the other hand, I try to create a main project with Wt code and a .so file without wt code (C ++ only) I get a .so LSB shared object file that doesn't give problems.
Both .so files (with wt code and without wt code) are compiled with gcc in the same way, using the parameters:
-fPIC -Wl, -S -g -shared -Wl, -soname, testfile.so
However, the one with wt code also contains the typical wt compilation parameters.
I have doubts about the cause of the problem.