Page 1 of 1

Problem adding external libraries to plugin

Posted: Tue Sep 13, 2011 6:51 pm
by GlenboLake
One of the functions in the plugin I'm writing uses Google Protocol Buffers. I'm having a little trouble modifying to configure script to suit my needs.

Some context on how the protocol buffers work: You write a .proto file that specifies the contents of a buffer, which gets compiled into a pair of files. foo.proto becomes foo.pb.cc and foo.pb.h. In the linker phase, you need to include -lprotobuf.

My first attempt to account for this was to compile the .proto file I use into the C++ source and header files before running the configure script. I also renamed the .cc files to .cpp so I wouldn't have to change that part of the configure script in order to find them. Then, I modified this section of createPluginMakefile() in configure:

Code: Select all

	if [ "$plugin_name" = "CppCheck" ] ; then
	  createVariables "yes" "-I../sdk/codelite_cppcheck/"
	elif [ "$plugin_name" = "DatabaseExplorer" ] ; then
	  createVariables "yes" "-I../sdk/databaselayer/include/"
	elif [ "$plugin_name" = "MyPlugin" ] ; then
	  createVariables "yes" "" "-lprotobuf"
	else
	  createVariables "yes"
	fi
This successfully built and the -lprotobuf flag appeared in the Makefile for my plugin, but the plugin stopped showing up in CodeLite after building. I also tried explicitly adding -lprotobuf to both LINK_FLAGS and PLUGIN_LINK_FLAGS in the createVariables() function and had the same issue.

On a side note: There is one minor change that I had to make to the configure script to get the Makefile to generate properly. I have reported this as bug #3408692.

Re: Problem adding external libraries to plugin

Posted: Wed Sep 14, 2011 1:17 pm
by DavidGH
Hi,
On a side note: There is one minor change that I had to make to the configure script to get the Makefile to generate properly. I have reported this as bug #3408692.
Thanks for looking into this. Fixed in r5062.
This successfully built and the -lprotobuf flag appeared in the Makefile for my plugin, but the plugin stopped showing up in CodeLite after building.
Presumably the plugin is installed to the correct place. If so, you could watch CodeLite trying to load it by debugging through PluginManager::Load in LiteEditor/pluginmanager.cpp. That should show what's going wrong.

Regards,

David

Re: Problem adding external libraries to plugin

Posted: Thu Sep 15, 2011 12:27 am
by GlenboLake
Thanks, David. Unfortunately, the problem lies in dlopen, so it I would guess that something is wrong with the actual compilation of the plugin. Here's my GDB backtrace:

Code: Select all

#0  wxString::mb_str (this=0x7fffffffd9a0, conv=...) at ../src/common/string.cpp:1030
#1  0x00007ffff7ab1f2d in clDynamicLibrary::Load (this=0x1286b20, name=...) at Plugin/dynamiclibrary.cpp:61
#2  0x0000000000659074 in PluginManager::Load (this=0xad02a0) at LiteEditor/pluginmanager.cpp:142
#3  0x00000000005e89dd in clMainFrame::CompleteInitialization (this=0x15007f0) at LiteEditor/frame.cpp:3025
#4  0x00000000005d28d5 in clMainFrame::Initialize (loadLastSession=true) at LiteEditor/frame.cpp:668
#5  0x00000000004b2f74 in CodeLiteApp::OnInit (this=0xb8dd20) at LiteEditor/app.cpp:540
#6  0x00000000004b4db1 in wxAppConsole::CallOnInit (this=0xb8dd20) at /usr/include/wx-2.8/wx/app.h:76
#7  0x00007ffff4c22cf4 in wxEntry (argc=<value optimized out>, argv=<value optimized out>) at ../src/common/init.cpp:432
#8  0x00000000004b1ef6 in main (argc=1, argv=0x7fffffffe268) at LiteEditor/app.cpp:219
The only file I added was a .proto file, which compiles into a .cpp/.h file pair that are discovered by configure as I described above. Do you have any idea how I can pinpoint the problem further?

Re: Problem adding external libraries to plugin

Posted: Thu Sep 15, 2011 1:01 pm
by DavidGH
Do you have any idea how I can pinpoint the problem further?
The error returned by dlerror() is output at pluginmanager.cpp:145. Do you see an error message anywhere e.g. the 'trace' bit of the Output View, or the terminal in which you run CodeLite?

Otherwise, I'm no expert on dlopen but, for shared lib issues, I always go straight to the dwheeler site.

Re: Problem adding external libraries to plugin

Posted: Thu Sep 15, 2011 6:15 pm
by GlenboLake
Thanks for the tip. The error output there had to do with something in the protobuf library not being defined, so I went and tried explicitly adding -lprotobuf to both LINK_FLAGS and PLUGIN_LINK_FLAGS in the createVariables() function again. This time, the plugin showed up, so it seems like I need to be really thorough about linking the protobuf library. Apparently the cause of the issue was that I linked my plugin, but not all of CodeLite, against the protobuf library.

Thanks for the help!