PDA

View Full Version : setlibrarypath does not seem to work on qtnamespace modified frameworks



eric_vi
5th August 2012, 00:33
1 / using configure and make i built a new set of qtframework with a new namespace...
./configure -qtnamespace foo -qt-libjpeg

all works fine so far...


2/ to deploy i take care of my frameworks and that works fine

3/ now for my jpeg plugin ...
i create a 'myplugin' folder and i put the libqjpeg.dylib that was generated there

in my code i have a QCoreApplication::setLibraryPaths("/myplugin");


when i test my program .... the setLibraryPaths does not seemed to be used at all and the jpeg is loaded only if the frameworks are within /usr/local/Trolltech/Qt-4.8.2/lib which is not what i want at all when deployed

(working with the standard qt without namespace change, i have no problem, so i must be missing something...)

i am stuck here, have no clue what i am doing wrong, many thanks for all help

amleto
5th August 2012, 14:47
Do you only configure a qt namespace for a single plugin?

eric_vi
5th August 2012, 16:52
no i was simplifying... i did the ones within imageformats

./configure -qtnamespace foo -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg

amleto
5th August 2012, 17:23
so you have some of qt built with a namespace, and some built without a namespace.

Do you not think that might be a problem?

eric_vi
5th August 2012, 18:43
which ones can be without namespace? i use all the .dylib generated after make, the console is not giving me any message either what i do not understand is that qt does not seem to look at the path i provide (it does when i use the standard version of qt), i am not even sure where qt is loading those dylib from

amleto
5th August 2012, 22:29
I dont know what dylib is.

If you want to build qt in a namespace I would expect that you have to build ALL of it in a namespace.

eric_vi
7th August 2012, 05:41
the xx.dylib are the dll that are result of the make... and yes that is what i am thinking too... but i do not think the issue is there.

my problem is that if using my qtnamespace modified frameworks i do a setLibraryPath toward the folder where those (namespace modified) xx.dylib are in my deployed version, they are not seen or used!!! (if i do the same with the standard frameworks, i have no problem all works fine the setLibraryPath pick the standard dll fine...)

amleto
7th August 2012, 20:43
I shall find a brick wall to talk to. Dont mind me...

d_stranz
7th August 2012, 20:59
my problem is that if using my qtnamespace modified frameworks i do a setLibraryPath toward the folder where those (namespace modified) xx.dylib are in my deployed version, they are not seen or used!!!

How do you know that they are "not seen or used"? Maybe they are in fact "seen" and when Qt tries to load them and looks for the plugin class and its entry point, it finds "MyNamespace::QWhatever" instead and has no idea what to do with that. As amleto is trying to tell you, you can't expect a version of Qt built with no namespace to be able to use parts of a Qt built with a namespace inside a DLL, because you have no way to tell Qt what namespace should be used there.

It is basic C++: the symbols MyClass::someMethod() and MyNamespace::MyClass::someMethod() are different and cannot be used interchangeably. In the first case MyClass::someMethod() is in the global namespace and should actually be written as ::MyClass::someMethod() to be strictly correct.

So if you are trying to load a DLL with Qt classes that are qualified by your namespace, and Qt is expecting the plugin classes and their entry points in that DLL to be in the global namespace, then your plugin methods do not match the expected names.

You can try putting a "using MyNamespace;" declaration somewhere in your source file before you try to load the DLL, maybe that will work. But by doing that, you make the idea of a namespace on your DLL irrelevant because the "using" statement basically tells C++ to import everything into the global namespace before trying to match symbols.

eric_vi
8th August 2012, 01:38
i never said that my dll are using a qt modified namespace and that my frameworks are standard... no no! they both are the result of the same make with the -qtnamespace

this is what i did :

1/ i built a qt version with modified namespace, installed it... tested it and i know that my program is using it.

2/ i have deployed my program and my program is now using exclusively the qt modified namespace i built and this works fine. I have absolutely no standard qt anymore on my machine!

3/ i now for deployment take the dylibs that have been built together with modified qtnamespace (i am assuming they use the qt modified namespace framework, i also need to deploy each of them, i did that hundreds of time with standard library, it is not new for me) I place them in a folder and use the setlibrarypath to point into this folder.... i can see that my (qt namespace modified dylibs are not loaded...)


that is why i am asking is there something else you need to do to use qt namespace modified dll with qt namespace modified frameworks (assuming those qtnamespace are the same of course)

d_stranz
8th August 2012, 05:05
i can see that my (qt namespace modified dylibs are not loaded...)

How did you prove to yourself that this statement is true?


no i was simplifying... i did the ones within imageformats

./configure -qtnamespace foo -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg

In this previous post, you said that you only built part of Qt (the image support plugins) using the namespace, the rest was built using no namespace. Are you now saying that the entire Qt distribution was built using your namespace, and that everything you are compiling and linking to (dynamically or otherwise) is in the same namespace, including your application?

Did you actually try the "using namespace;" declaration? Did it make any difference?

eric_vi
8th August 2012, 05:27
no in previous posts if i quote myself i said " if using my qtnamespace modified frameworks i do a setLibraryPath toward the folder where those (namespace modified) xx.dylib are in my deployed version ... "

yes everything is built using qtnamespace there is NO mixup... when i run in a non deployed version all works fine and in debug mode i can see that the QT_BEGINNAMESPACE works properly and use the qtnamespace modified frameworks.


my issue is in deployment mode when i try to load the qtnamespace modified dll (who have been deployed too!) located in my own plugin folder using setLibraryPath those dll are not used.

i know they are not used because again i am in deployment mode.. the only qt left are the (qtnamespace modified) frameworks located in my own framework folder. (i removed those that were installed with make install). Now if i try to use the (qtnamespace modified) qtjpeg.dylib located in my own plugin folder (that has been designated thru setLibraryPath) to open jpeg image , they are not opened.