<div dir="ltr">Hi Sascha,<div>we've figured out, that the tracker library uses another library for the initialization of the connection. The problem was, that the symbols of this library couldn't be resolved. This leads to the assumption, that the plugin framework links correctly to a shared library, but not to shared libraries, that are used by the first shared library.</div>
<div>By loading the tracker library with your suggestion (ExportExternalSymbolsHint), it was possible to initialize our tracker correctly! Thank you very much for your help!</div><div><br></div><div>For people with the same problem, this is the code to load a class from a shared library which depends on other shared libraries (from a ctk plugin):</div>
<br>QLibrary library("library.so");<div>library.setLoadHints(QLibrary::ExportExternalSymbolsHint);<br>library.load();<br>if(library.isLoaded()){<br> MyClass * c = new MyClass;<br> if(c){<br> // dostuff<br>
}<br>}</div><div><br></div><div>and for a function:</div><br>QLibrary myLib("library.so");<div>library.setLoadHints(QLibrary::ExportExternalSymbolsHint);<br>library.load();<br>typedef void (*MyPrototype)();<br>
MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");<br>if (myFunction)<br> myFunction();<div><div class="gmail_extra"><br></div><div class="gmail_extra">Note, that you have to link your library.so also in the CMakeLists.txt with target_link_libraries.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Best regards,</div><div class="gmail_extra">Florian<br><br><div class="gmail_quote">2013/8/26 Sascha Zelzer <span dir="ltr"><<a href="mailto:s.zelzer@dkfz-heidelberg.de" target="_blank">s.zelzer@dkfz-heidelberg.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Hi Florian,<br>
<br>
this all sound really strange...<br>
<br>
as you have noted already yourself, plug-ins are also just shared
libraries, which are loaded dynamically at runtime. If I
understood you right, in the case of linking the proprietary
tracker library to the plug-in, the plug-in starts successfully
but the tracker library reports a runtime error. Is that correct?<br>
<br>
The only difference of which I can think of (compared to the
working cases you mentioned), is that the plug-in is loaded via
"dlopen" (on POSIX systems) using the QLibrary class. Depending on
the Plugin Framework options<br>
<br>
<a href="http://www.commontk.org/docs/html/structctkPluginConstants.html#a29af0cac606ca29ea8d66d342d05060e" target="_blank">http://www.commontk.org/docs/html/structctkPluginConstants.html#a29af0cac606ca29ea8d66d342d05060e</a><br>
<br>
different load hints are passed to QLibrary
(<a href="http://qt-project.org/doc/qt-4.8/qlibrary.html#loadHints-prop" target="_blank">http://qt-project.org/doc/qt-4.8/qlibrary.html#loadHints-prop</a>).
These load hints might affect symbol resolutions of subsequently
loaded libraries, like your tracker library.<br>
<br>
But if all this really relates to your actual problem is not clear
to me, sorry.<br>
<br>
Best,<br>
<br>
Sascha<div><div class="h5"><br>
<br>
<br>
On 08/26/2013 02:37 PM, Florian Ganglberger wrote:<br>
</div></div></div><div><div class="h5">
<blockquote type="cite">
<div dir="ltr">Hi Jc,
<div>we've built a new shared library which calls our
shared-tracker-library. It works perfectly outside of our
plugin and the tracker can connect. As soon as we link the new
shared library into the plugin, we have our connection problem
again. It calls the function, produces all the output, but
can't connect. So we can say that the<u> shared tracker
library works for:</u></div>
<div><b>- a normal example program</b>: example
program --> shared tracker library</div>
<div><b>- the main method of our ctk app:</b> ctk app
--> shared tracker library</div>
<div><b>- called from a "normal" shared library: </b>
example program --> "normal" shared library --> shared
tracker library</div>
<div><br>
</div>
<div><u>and not for:</u></div>
<div><b>- the plugin</b> (which is a shared library):
ctk plugin --> shared tracker library</div>
<div><b>- a call from a shared library which is called
by the plugin</b>: ctk plugin --> "normal" shared
library --> shared tracker library</div>
<div><br>
</div>
<div>Actually we have no idea, why it doesn't work....</div>
<div><br>
</div>
<div>Thanks for your help,</div>
<div>Florian </div>
<div><br>
</div>
</div>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">2013/8/26 Florian Ganglberger <span dir="ltr"><<a href="mailto:Florian.Ganglberger@student.i-med.ac.at" target="_blank">Florian.Ganglberger@student.i-med.ac.at</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">Hi Jc,
<div>we can't really use a debugger, since we don't have
the code for the shared library, only the header files.
The methods of the shared library is definitely called,
because we get an error message that a connection to the
tracker can't be established. Can it be a problem, that
the plugins are also shared libraries? We'll write a
shared library that calls the tracker today, so we can
see if the problem depends on calling the
tracker-library from a shared library or if it is ctk
specific.</div>
<div><br>
Additional information: As far as we know, the tracker
library was written in C (and not in C++)</div>
<div><br>
</div>
<div>Thanks for your help,</div>
<div>Florian</div>
<div>
<div>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">
2013/8/24 Jean-Christophe Fillion-Robin <span dir="ltr"><<a href="mailto:jchris.fillionr@kitware.com" target="_blank">jchris.fillionr@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<p>Hi Florian,<br>
If it build without problem, did you try using
a debugger to try to understand what s wrong?<br>
Jc</p>
<p>--<br>
Sent from my mobile device</p>
<div class="gmail_quote">
<div>
<div>On Aug 23, 2013 12:00 PM, "Florian
Ganglberger" <<a href="mailto:Florian.Ganglberger@student.i-med.ac.at" target="_blank">Florian.Ganglberger@student.i-med.ac.at</a>>
wrote:<br type="attribution">
</div>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>
<div>
<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Hi,</span>
<div style="font-family:arial,sans-serif;font-size:13px">
we are trying to link a shared
library to connect to tracker from a
plugin. We know, that the code that
calls the .so library works in a
test application and also in the
main method of our CTK application.
After we have added our code to the
plugin and linked it to the .so
library, we can link and compile the
code without errors, but we don't
get a connection to the tracker. </div>
<div style="font-family:arial,sans-serif;font-size:13px">The
cmakelists code to link the .so file
in our test application is</div>
<div style="font-family:arial,sans-serif;font-size:13px">TARGET_LINK_LIBRARIES(optoExtern
${OPTOTRAK_LIBRARY})</div>
<div style="font-family:arial,sans-serif;font-size:13px">(${OPTOTRAK_LIBRARY}
is the library path, optoExtern the
project name)</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br>
</div>
<div style="font-family:arial,sans-serif;font-size:13px">
The cmakelists code to link the .so
file in our plugin:</div>
<div style="font-family:arial,sans-serif;font-size:13px">
<div>ctkMacroBuildPlugin(</div>
<div> NAME ${PROJECT_NAME}</div>
<div> EXPORT_DIRECTIVE
${PLUGIN_export_directive}</div>
<div> SRCS ${PLUGIN_SRCS}</div>
<div> MOC_SRCS ${PLUGIN_MOC_SRCS}</div>
<div> UI_FORMS ${PLUGIN_UI_FORMS}</div>
<div> INCLUDE_DIRECTORIES
${Plugin_SOURCE_DIR}</div>
<div> RESOURCES ${PLUGIN_resources}</div>
<div> TARGET_LIBRARIES
${PLUGIN_target_libraries}
${OPTOTRAK_LIBRARY}</div>
<div>)</div>
<div><br>
</div>
<div>Has anyone an idea how to link
external shared libraries within a
plugin properly?</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Florian Ganglberger</div>
</div>
</div>
<br>
</div>
</div>
_______________________________________________<br>
Ctk-developers mailing list<br>
<a href="mailto:Ctk-developers@commontk.org" target="_blank">Ctk-developers@commontk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers</a><br>
<br>
</blockquote>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div></div></div></div>