In our application we use several dynamically linked libraries. We recently updated the version of one of these libraries. The developers of that library are providing a main method since this new version (Doing nothing more than printing Hello World).
The problem is that we are using GTest and GMock, which generate their own main method. When we now run our test binary, we just get "Hello World", so the wrong main method is being taken.
How can we force the main method of the tests to be used?
UPDATE: This seems to be a GMock/GTest issue. The main method is normally generated, but this is not the case as it finds an already existing main method now.
No, the implementation of C library of gcc has an entry point not a main symbol.
Dynamic loading is a mechanism by which a computer program can, at run time, load a library (or other binary) into memory, retrieve the addresses of functions and variables contained in the library, execute those functions or access those variables, and unload the library from memory.
Simply put, A shared library/ Dynamic Library is a library that is loaded dynamically at runtime for each application that requires it. Dynamic Linking doesn't require the code to be copied, it is done by just placing name of the library in the binary file.
There are no ways around in your situation. You'll have to remove the main from the shared library. It simply doesn't belong there.
I had a similar issue with two libraries having main methods, which was resolved by changing the order of the libraries to the linker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With