Hi Thomas,
Humm, dunno why it didn't work when Matthew and I tried it before, but:
$ cat test.cpp #include <geanyplugin.h> #include <iostream>
extern "C" { PLUGIN_VERSION_CHECK(211)
PLUGIN_SET_INFO("Test C++","Test C++", "etc", "etc");
void plugin_init(GeanyData *){} void plugin_cleanup(void){}
}
class Test { public: Test() { std::cout << "Hello from Test" << std::endl; } ~Test() { std::cout << "Bye from Test" << std::endl; } };
static Test test;
$ g++ -c test.cpp -fPIC `pkg-config --cflags ../lib/pkgconfig/geany.pc geany` $ g++ test.o -o test.so -shared `pkg-config --libs ../lib/pkgconfig/geany.pc geany` $ cp test.so ../lib/geany $ geany -c ../config
does call the constructor/destructor for test. Maybe we got the mystery incantations wrong :) It also works using clang++ to compile test :)
Note, if the plugin isn't loaded the constructor is run when plugin manager is opened and, if you havn't selected the plugin, the destructor is run when plugin manager is closed.
When you select the plugin the destructor is run and then the constructor is run again but this time the destructor is not run when plugin manager is closed.
So it probably shouldn't do anything in the constructors/destructors that is slow or that leaves a trace.
[...]
FWIW, does anyone know why I needed to link libstdc++ explicitely in my testing?
As shown above Matthew is right, just use g++.
@Frank, sorry, wasn't meaning to blame you ;) just my failing .. ummm ... oh yeah, memory.
Cheers Lex