hbruintjes / ceema

Threema protocol implementation in C++
Apache License 2.0
20 stars 4 forks source link

Problem with init plugin #3

Closed laszabine closed 3 years ago

laszabine commented 4 years ago

First, thanks a lot for writing this plugin!

I'm trying to install it, and the build looks successful (some warnings), but in Pidgin, the "Add Account" dialogue doesn't list anything related to Threema, and the "Debug Window" shows the following upon opening "Tools" > "Plugins" (where the plugin doesn't appear either):

(17:49:13) plugins: probing /home/sabine/.purple/plugins/libceema.so
(17:49:13) plugins: /home/sabine/.purple/plugins/libceema.so is not usable because the 'purple_init_plugin' symbol could not be found.  Does the plugin call the PURPLE_INIT_PLUGIN() macro?

Looks like this refers to this definition: https://github.com/hbruintjes/ceema/blob/f7b09684d4b6b442cbb1c97f136f8eaab05d3701/src/threepl/prpl/threepl.cpp#L258

Do you know what could be going on there? Thanks a lot!

OS: Fedora 32, 64-bit Kernel: 5.7.8-200.fc32.x86_64, gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) Pidgin version: 2.13.0-18.fc32 (libpurple 2.13.0)

hbruintjes commented 4 years ago

Not sure why the symbol is not found. What does nm -D /home/sabine/.purple/plugins/libceema.so | grep purple_init_plugin say?

laszabine commented 4 years ago

No results.

Here's my log of running cmake ../: cmake.log

And of running make: make.log

hbruintjes commented 4 years ago

Nothing looks odd to me looking at the logs. Can you run make with VERBOSE=1 as an argument to see which linker flags are being used?

laszabine commented 4 years ago

Here you go: make-verbose.log

Thanks a lot!

hbruintjes commented 4 years ago

Still not able to reproduce on Ubuntu 20 with gcc 10. Can you show the output of /usr/bin/c++ -Q -v /home/sabine/Downloads/ceema/src/threepl/prpl/threepl.cpp

myxor commented 3 years ago

I am not OP but i am having the same problem with current Pidgin 2.14.1. Here is the output of c++ command on my machine:

c++.log

@hbruintjes I am hoping you are still looking at this project at some time and can help us with this problem. If you need any more input feel free to ask.

myxor commented 3 years ago

Further investigation brings up that the macro PURPLE_INIT_PLUGIN can not be found inside the compiled libceema.so. I looked via objdump -d libceema.so | grep -i purple but no results are found. I thing something with the build process is messed up so that some stuff is dropped by the linker or is it being stripped out somewhere.

hbruintjes commented 3 years ago

Just had a fresh look at the original issue: Problem is that it should be libthreepl.so, located in the src subdirectory. Regarding the log file: SOmehow, it seems the linker is trying to build an executable, not a shared object (since it cannot find main()). How did you set up the CMake build?

myxor commented 3 years ago

Great to hear from you! There is a libthreepl.so in build/src and it contains the purple_init_plugin function:

nm -D src/libthreepl.so | grep purple_init_plugin
00000000002148af T _Z18purple_init_pluginP13_PurplePlugin

but when i copy it to ~/.purple/plugins and start pidgin i still get the error:

(22:02:22) plugins: probing /home/myxor/.purple/plugins/libthreepl.so
(22:02:22) plugins: /home/myxor/.purple/plugins/libthreepl.so is not usable because the 'purple_init_plugin' symbol could not be found.  Does the plugin call the PURPLE_INIT_PLUGIN() macro?

I did not change anything on the cmake config except using mbedTLS instead of OpenSSL. I am running mkdir build && cd build && cmake .. && make

btw: what's the difference between libceema and libthreepl?

hbruintjes commented 3 years ago

For some reason it uses C++ linkage, though it ought to be C. Is the extern "C" still present in the function definition?

myxor commented 3 years ago

Very strange but it now seems to work with

extern "C" gboolean purple_init_plugin(PurplePlugin *plugin) {
    threepl::init_logging();

    threepl_init(plugin);
    return purple_plugin_register(plugin);
}

which is the original code from you. I guess i only tested libceema.so and never libthreepl.so.

Nevermind, Pidgin now loads the plugin succesfully. Thank you for your help!

hbruintjes commented 3 years ago

Great, I'll consider this resolved, then.