I am using Qt Creator for development. I want to use Armadillo linear algebra library. Therefore I used following code in my pro file:
INCLUDEPATH += C:\armadillo-7.950.1\include
LIBS += \
-LC:\armadillo-7.950.1\examples\lib_win64 \
-llapack_win64_MT \
-lblas_win64_MT
It was all good and the project compiled and linked properly. Next task was to replace LAPACK and BLAS with OpenBLAS. So the pro file was changed as following:
INCLUDEPATH += C:\armadillo-7.950.1\include \
C:\OpenBLAS-v0.2.19-Win64-int32\include
LIBS += \
-LC:\OpenBLAS-v0.2.19-Win64-int32\lib \
-llibopenblas
Now I receive the error: LNK1104: cannot open file 'libopenblas.lib'. I have downloaded windows binary of OpenBLAS. The installed folder structure is as given in the image: installed OpenBLAS folder
Please let me know what is going wrong?
Thanks.
There are two reasons for this problem:
Weird naming of .lib file as libopenblas.dll.a even though package is called windows binary.
Incomplete binary package---- It doesn't contain all required dlls
Solution:
Choose a binary----win 64 or win32 and download it.
rename libopenblas.dll.a as libopenblas.lib as Yuriy has suggested
download from https://sourceforge.net/projects/openblas/files/v0.2.14/ required missing DLLs are bundled again under weirdly named zip files "mingw64_dll" or "mingw32_dll" depending upon the binary type which you have downloaded in step 1. These zip file contain "libgcc_s_seh-1.dll", "libgfortran-3.dll" and "libquadmath-0.dll"
Add include and lib as I have done to your project and build with correct target depending upon your downloaded binary i.e win64 or X86
Copy libopenblas.dll from bin folder of OpenBLAS binary and "libgcc_s_seh-1.dll", "libgfortran-3.dll", "libquadmath-0.dll" from "mingw64_dll" or "mingw32_dll" depending upon the binary type to build debug or release directory where the exe reside.
Run your program and you are good to go.
If you want to escape copying again and again set a required system environment variable for the path containing these DLLs
I'm not familiar with OpenBLAS, but your configuration looks correct.
On Windows, or at least with MSVC, you need a .lib file to link to, in addition to the DLL file for runtime. Instead it looks like OpenBLAS installs a mysterious .dll.a file. Sounds like it should be the same thing:
https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio
Possibly renaming it would do the trick, but you might need to rebuild from source to get the file.
Related
I'm trying to get openCV 3.1.0 to work in QT Creator 4.4.1 using this tutorial from their official site.
Right now, I'm setting up my project file. The whole file looks identical to the on in the tutorial apart from the last couple of lines, as my openCV build is in another place and it's a different version This is what I got:
INCLUDEPATH += C:\opencv\opencv-3.1.0\build\include
LIBS += -LC:\opencv\opencv-3.1.0\build\x64\vc14\bin \
libopencv_world310d \
As far as I understand, the "world" module has been introduced to openCV to unify all the different modules into one.
However, when I try to run this, QT produces the following error:
C:\opencv\opencv-3.1.0\build\x64\vc14\bin\opencv_world310d.dll:-1: error: file not recognized: File format not recognized
What am I doing wrong? In the tutorial there's an alternative way to link the libraries which even explicitly states them as .dll files. Why is this a problem?
You need to link to the .lib contained in the lib folder:
LIBS += -LC:\opencv\opencv-3.1.0\build\x64\vc14\lib \
and put the .dll in the PATH, or the same folder of the .exe
I have a C++ project using Qt and I have it working as expected. However, the problem is when I copy
the executable to a standard installation of a OS (e.g. Windows or a Linux) upon execution I receive the QtWidgets or some other Qt libraries missing error.
I tried referencing the Qt Documentation but I am unable to find a solution or an example of what I am after. It has something to do with Static and Dynamic Building... but could not locate a good example or tutorial.
I looked at the tutorial http://www.qtcentre.org/wiki/index.php?title=Deploying_Qt_Applications but it is not quite the most efficient solution.
Basically I want the system to include the required Qt libraries along with the final compiled file. How can I pull it off?
What you can do is making a script which copies your DLLs (or .so* files) in the executable folder. Once you make it add an extra Makefile target in your project file :
theproject.pro:
OTHER_FILES += copy.script # Assuming your copy script is called "copy.script"
deploylibs.target = deploylibs
deploylibs.command = ./copy.script # Launching the script
QMAKE_EXTRA_TARGETS += deploylibs
Now you can deploy your libraries by using the (n)make deploylibs command.
NB: there is a very useful tool called "Dependency Walker" to find the DLLs you need. It is only for Windows. As for Linux and its *.so* files you can use the ldd command :
>$: ldd theexecutable
alib.so => /path/to/library/on/your/computer.so
...
I created a Qt project in Ubuntu and everything went smoothly. However, I also need deploy it on Windows. It uses Boost libraries(the big problem).
I've been searching for hours to find a solution, but didn't have luck. I tried to install Boost libraries and link it with mingw; I think I missed something. Here is what I did and downloading the lastest version:
1) ran .\bootstrap
2) then .\b2 --prefix=C:\boost install
Sadly didn't install correctly. I got only 2 folder(bin and share) but no headers.
However, here (http://nuwen.net/) I found a bundle(Mingw+Boost and other libraries). This has everything I need.
Now I think the issue is .pro file, because I have a lot of undefined references. Here is .pro file with everything I tried (some commented):
http://pastebin.com/pBFMTAd8
Your help is appreciated!
I did solve the problem myself. And here is how I did it. First of all, it is required to have boost library compiled with same compiler you're using with Qt.
If you're using msvc, then you're lucky because Boost guys did you a favour and compiled libraries for you. You can download them here: http://sourceforge.net/projects/boost/files/boost-binaries/ .
If you're using mingw (which does come in bundle with Qt), you can do this:
add mingw compiler to Windows PATH variable:
~ go to control panel and search for System;
~ add mingw's path(e.g. C:\Qt\Tools\mingw\bin) to PATH variable by appending ';' to your path(e.g.: ";C:\Qt\Tools\mingw\bin")
compile Boost libraries:
~ unzip boost archive
~ open a Command Line window, go in the unzipped boost folder, then go in folder tools/build/v2/engine
~ you have you build installer with mingw toolset: .\build --toolset=mingw
~ this will create 2 files in folder bin.ntx86 or something similar; copy the files bjam and b2 in the unzipped boost folder;
~ now go in boost folder and start build it: .\b2 --toolset=mingw --build-type=complete stage (there is good tutorial to install it along with eclipse : http://theseekersquill.wordpress.com/2010/08/24/howto-boost-mingw/)
note: this gonna take few hours, so may want to watch a movie or what ever you want to do meanwhile. However you have the option to speed up things a little bit by adding another argument to the build command: -j N, where N is how many cores your processor have.
when build has finished, you can now link the library in Qt. To do this you need to modify .pro file. First you'll have to tell Qt where are headers are located, and you do so by adding:
INCLUDEPATH += path_to_boost_folder, e.g. : INCLUDEPATH += C:/boost_1_54_0
~ also if you're using libraries which requires link, for example system and filesystem you have to link them separately:
LIBS += "C:/boost_1_54_0/stage/lib/libboost_filesystem-mgw48-1_54.a",
LIBS += "C:/boost_1_54_0/stage/lib/libboost_system-mgw48-1_54.a"
after modifying the .pro file, run qmake, then rebuild.
Hope this works for you too!
Update: The folder hierarchy has change. For building the library, one should read the documentation associated with each version and Boost.Build's documentation.
Building the library from the root folder is easier (Building Boost 1.52 with MinGW):
C:\boost_1_60_0> bootstrap.bat mingw
C:\boost_1_60_0> .\b2 --toolset=gcc -j N --build-type=complete
building boost will not put the headers, the headers are for the developer when he creates new code. The installed dirs are the binaries for distribution.
see http://www.boost.org/doc/libs/1_54_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary
this will install libraries, that you use at runtime (not compile time). Because you add this bin folder to your path and that is why when runing an app build with boost it will run and not say "could not find xxx.dll"
main.cpp which should be executable C++ app. It shall depend on
Lib1 be a required to be compiled first (before main.cpp) project-lib (with lib1.h and lib1.cpp inside some separate folders)
'Lib2.lib' with its dependency given precompiled libs (like cross-platform OpenCV for example)
I need it to work for Windows and Linux and if possible Mac OS
found for windows: look here - "Common tasks" page 26
exe hello : hello.cpp some_library.lib /some_project//library
: <threading>multi
;
I hoped for better - more readable syntax form Boost creators... And BTW
What the hell on earth does
On Windows, if an application uses
shared libraries, and both the
application and the libraries are
built using Boost.Build, it is not
possible to immediately run the
application, because the PATH
environment variable should include
the path to the libraries. It means
you have to either add the paths
manually, or have the build place the
application and the libraries into the
same directory.
mean? I can not have a project with 2 nested project - one for .lib and one for app using that .lib?
With this I see how to connect 1 .lib but how to connect a folder with them? And how to connect includes? And when I'll go to Linux what shall be changed?
How should my bjam make/config file look like?
It sounds like you want a framework which works on a cross-platform(Multiple operating system) scenario.
Simplest option would be to install cygwin and create a standard makefile for linux. Compile in a cygwin environment to generate the windows equivalent.
You will save substantial time in creating the makefile.
Another option is mksnt.
I have developed an application with mac and for one month now, Im trying to link Qt with ImageMagick on windows.
I just cant find the files and the version of Imagemagick library that need to be linked to Qt in order to make my application work on windows.
I have tried most of the libraries from here
Thats the only thing I added to the .pro file while I was developing on a mac
INCLUDEPATH += . /opt/local/include/ImageMagick
LIBS += -L/opt/local/lib -lMagick++
When I add this to my .pro
INCLUDEPATH += C:/im6/include/ImageMagick
LIBS += C:/im6/lib/libMagickWand.a
LIBS += C:/im6/lib/libMagick++.a
LIBS += C:/im6/lib/libMagickCore.a
C:/im6/lib/libMagick++.a
I get 10.000 + simmilar errors to that:
(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4157: undefined reference to `__gxx_personality_sj0'
C:/im6/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4157: undefined reference to `_Unwind_SjLj_Register'
C:/im6/lib/libMagick++.a(Image.o):C:\msys\1.0\home\cristy\ImageMagick-6.6.6-0/Magick++/lib/Image.cpp:4178: undefined reference to `_Unwind_SjLj_Unregister'
For more errors check this
Has anyone tried to build and deploy an ImageMagick application using qt on windows ?
Which files do I need to link while building and which files while deploying ?
The error message tells me that you
use mingw (with qtcreator). Your
library might not work with this
compiler. You need a mingw version
of the library, probably named
libmagick.a.
LIBS += -L$$quote(c:/Program Files/ImageMagick-6.6.5-Q16/lib) -lmagick
(see the documentation about qmake Project Files
I have found that the minGW tool set is very much treated as a "stepchild" in the Windows world. I know it doesn't help your particular situation, but we had numerous problems with third-party libs while trying to use Qt with minGW. There were always extra steps, or non-existent build instructions that we had to figure out or tweak.
Once we switched to the MSVC version, all of those problems went away. Note that this doesn't mean you have to use Visual Studio (you can still use Qt creator), it just means that the Visual Studio compiler is being used. You can get the compiler for free using the Platform SDK. If this is an option, you might save yourself a lot of pain by switching now. It's unfortunate, but that is just the current status quo, at least as we discovered.
Please go get ImageMagick source package.
I can’t give direct instructions how to work with MinGW of Qt Creator, but basically following. I prefer to use qtvars.bat that comes with binary distributions of Qt to set environment.
Open Windows cmd
Set PATH to have /path/to/mingw/bin and /path/to/qt/bin before other paths
Go to directory where you have extracted ImageMagick source
read README, INSTALL and such to compile the ImageMagick (most likely just ./configure ; mingw32-make, but never be sure)
Edit your .pro file with something like LIBS += -L$$quote(/path/to/imagemagick/lib/dir) -lmagick . The lib may be in bin dir or in lib dir. See hmuelner’s answer for more information.
At this point, the configuration should be ready. Compilation at Qt Creator should work, but you can as well use this cmd windows to compile your program: go to program directory, run “qmake” and “mingw32-make”.
You cannot link against a ImageMagick++ library built with MSVC, as mingw and MSVC DLLs are incompatible for C++ libraries. You can't link a MSVC-built C++ library into a mingw project, nor vice versa. C-only libraries work fine. Also, according to this fortum thread, using builds against old mingw-versions with current mingw versions doesn't work as the exception handling changed (as you get more errors than that, I wouldn't expect that to be the only problem though). If there is no binary package for your mingw version (and I don't see any on the imagemagick website), your only option is to use a source package, as Smar suggests.
Another option of course is to install Visual Studio, download Qt for MSVC and build your project with MSVC.