Link dynamically against Public\Qt inside ocean - qt

Using Petrel 2016.1
Libraries reference:
https://www.ocean.slb.com/~/media/files/testing%20plug%20ins/libraries/petrel_2016-1_3rd_party_libraries.html
My plugin uses Qt for a window and some plots with qwt. I would like to link against the Qt dlls present at Petrel\Public\Qt to save some space while deploying the app and because is not possible to deploy libs already present in Petrel as public libs by policy.
I've successfully linked with the same Qt version over there. The problem is that PluginPackager.exe does not see the libs. I've tried editing PluginPackager.exe.config inside Petrel dir to include Public\Qt, copied it to the Release folder, copied it to the main project folder and every dir that I may suspect PluginPackager.exe is looking for this file but nothing seems to cause any effect.
I've copied the Qt dlls to the Release folder, so PluginPackager.exe could see them and register the Plugin. It works, even if I delete the Qt dlls from the Release folder afterwards. Petrel is loading them from Public\Qt. The problem is that when I try to open the Qt window, a message saying that Qt failed to load plugin windows.
I figured that it is related to qwindows.dll, which is inside Public\Qt\plugins\platforms. If I set the environment variable QT_QPA_PLATFORM_PLUGIN_PATH to C:..\petrel...\Public\Qt\plugins\platforms, it works fine. I've tried to use addLibraryPath() from QApplication with no success.
I guess we have everything we need inside Public\Qt, but for some reason Petrel is not finding it. Two questions, then:
1- How to make PluginPackager to see all the libs inside Public\Qt?
2- How to make my application to find qwindows.dll?
Plugin has code in C#, C++ cli and C++
EDIT 1:
Ok, for Q.2 I've found a solution by trial and error.
QString path = QDir::currentPath();
QString finalPath = QDir(path).filePath("Public/Qt/plugins");
QApplication::addLibraryPath(finalPath);
This will add the plugins dir to the qt lib search path and does the trick. I hope I can deploy using this.
EDIT 2:
For Q.1
I realize now that the PluginPackager only sees things inside the Extensions folder. The problem was that, in my opinion, the folder name Public is misleading. This led me to think that all libs inside that folder could be used by developers freely. The Ocean guide states that all libs other than the ones inside Extensions are considered internal libs:
The PluginPackager.exe assumes that files in the Petrel installation directory tree other than those in the Extensions folder are internal Petrel libraries.
Well, why name a folder Public if all the libs inside it are internal? This is really confusing. Besides, the Slb.Ocean libs inside the Public folders are Ok to use, the others are not? As PluginPackager.exe.config has Public\ but not the folders inside it.

Related

Unable to add include path in Qt Creator

I've downloaded a C++ project which uses Boost. It's rather complicated and plenty of files reference its parts, like:
#include <boost/graph/fruchterman_reingold.hpp>
I've put Boost directory in the project folder and added INCLUDEPATH += "C:/Programming/my-project" in the .pro file but for some reason Qt keeps telling me "No such file or directory" about every single file. Now note that if I change the paths to absolute the references start working. I've ran Qmake explicitly but still get the same problem. What can I do about it besides changing all paths to absolute?
I'm running Qt Creator 3.3.0, Qt 5.4.0, the compiler is MinGW 4.9.1.
So I've figured it out. Apparently the project had several projects inside but I wasn't aware that I had to change .pro files in every single one to tell the compiler to add a new path. After I did it the problem was solved. Thank you for your time, people.

How to create a qt application for all unix versions?

I have been able create an application that depends on webkit and scripts in Qt5.2.1.But i was able to create a deb package for 14.04 version Ubuntu .But how can i make it as stand alone application .I have seen static and dynamic build .I tried static build but I don't kon w how to include webkit for static build.Also is it possible with shared library approach for creating a standalone application.Please help me out here..
Deploying a dynamically linked Qt application :
You should place Qt so files along the release version of your executable. These are libQtCore.so, libQtGui.so and possibly the ones for other modules that you have used. These so files are in your installed Qt directory in lib folder or in the directory /usr/lib/i386-linux-gnu. If you are using plugins you should place their so files in a folder named plugins beside your binary. In case of using icons and images you should ship their so files like libqico.so and libqsvg.so in a folder named imageformats.
Gathering required shared libraries :
If you want your application to run independently on a bare installed Linux, you should gather all dependent shared libraries and put them in your application directory. You can simply do it by a shell script named cpld. You can easily copy all dependencies to a folder.
It's worthy to note that you can put this in your .pro file to cause the dynamic linker to look in the same directory as your Qt application at runtime in Linux :
unix:{
# suppress the default RPATH if you wish
QMAKE_LFLAGS_RPATH=
# add your own with quoting gyrations to make sure $ORIGIN gets to the command line unexpanded
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
}

Undefined references - I'm including correct header

I'm trying to subclass from ProjectExplorer::ProjectExplorerPlugin but I'm getting error telling me about undefined references. Any ideas how to fix it?
class MyPluginPlugin : public ProjectExplorer::ProjectExplorerPlugin
{
Q_OBJECT
...
};
error: undefined reference to `imp__ZN15ProjectExplorer21ProjectExplorerPluginC2Ev'
The fact that you don't get a compilation error, but an undefined reference usually means that your project knows where the header files are, but it doesn't know where the library is which contains the already compiled source code.
I've never written a plugin for Qt Creator but I've taken a quick look at its source code structure and I see the following options:
Option A)
There is a projectexplorer.pro file in Qt Creator's source under src/plugins/projectexplorer. You could manually build that project in order to get a ProjectExplorer.lib (plus a .dll or a .a) and then reference this library.Example: Assuming the library would be created in the same directory as its .pro file (I have no idea if it is like that) and you created your plugin withing Qt Creator's source under src/plugins/myplugin, you would define your LIBS variable like this:
LIBS += -L../projectexplorer \
-lProjectExplorer
The first line adds "../projectexplorer" as an additional library directory and the second line adds "ProjectExplorer" as a library to search in any of the defined directories (it automatically adds the OS-specific file extensions like .lib on windows etc).
Obviously if your project or the library is located somewhere else, you need to change the first line accordingly.
Option B)
You could include the source and header files of the projectexplorer directory to your own .pro file using the HEADERS and SOURCES variables. I'm not sure if this wouldn't interfere with any other plugins (including projectexplorer itself) though.
Option C)
There probably is a way to include the projectexplorer.pro file so that you have a master project which first builds the project explorer library and then your own plugin. This would be the safest way to go as it ensures the Project Explorer library is built and up-to-date before your own project is linked against it.
However I have limited experience on this.
If anyone reading this can give a detailed explanation on this option, feel free to edit or provide your own answer.
If you are using Qt Creator built from source coded after April 2013 which includes Commit: #66a3553 - make library and plugin dependencies declarative, then you can simply specify dependencies for your plugin in its .pro file:
# myplugin.pro
QTC_PLUGIN_DEPENDS += \
coreplugin \
projectexplorer

Qt How to make and install plugins?

I would like to use the Qt Quick Components for Desktop mentioned here: http://labs.qt.nokia.com/2011/03/10/qml-components-for-desktop/
The author gives the following installation-instructions:
Since all of this is developed as a plugin to Qt itself, all you need to get started is the Qt 4.7.2 SDK. Just check out the http://qt.gitorious.org/qt-components/desktop and do the equivalent of a qmake && make install on your system.
I cloned the repository, executed qmake, mingw32-make and mingw32-make install on it in the command-line.
A new folder was created which includes the files libstyleplugin.a and styleplugin.dll.
I just don't know what to do with them. The sample-qml-files (using the components I try to install here) show nothing in the QML-Viewer, which means they aren't isntalled correctly.
So what am I supposed to do? (btw. I'm on Windows).
Hedge, I've done that on Linux but I believe you will be able to do the same on Windows. You already built the plugin which is good. Cause it seems "make install" doesn't really work (lets not blame the trolls - its just an experimental project), you need to do that manually. Now you need to do the following:
Create "imports" directory inside the directory whether you installed Qt.
Create "Qt/labs" directory inside that "imports" directory so overall it looks like this: YOUR_QT_DIR/imports/Qt/labs.
Copy "components" directory from the director where you built the components to "YOUR_QT_DIR/imports/Qt/labs" so it looks like this: YOUR_QT_DIR/imports/Qt/labs/components.
Go to "examples" directory in the directory where you built the components. You will find Browser.qml, Gallery.qml and Panel.qml files there. Open say Gallery.qml in a text editor and replace the following two lines on the top:
import "../components"
import "../components/plugin"
with
import Qt.labs.components 1.0
save changes and run Gallery.qml in qmlviewer. You should be able to run it.
Also you could leave the import statements from Gallery.qml as they were but that would rely on the relative directory where you built the components and won't work anywhere else.
Hope that helps
On Windows my directory ended up being C:\QtSDK\Desktop\Qt\4.7.3\mingw.
Hope this helps!

Qmake does not support build directories below the source directory

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?
Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.
Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.
Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.
.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)
Just remove the files with the pro.user extension , worked for me
I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)
Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

Resources