Installing Qt SDK, cannot link to the C++ libraries - qt

So I have installed the QtSDK on my Windows 7 64 bit machine. However, it seems like when I try to run a simple program like hello world such as:
#include <iostream>
int main(....) {
std::cout << "Hello World\n";
}
My program first gets the error:
CreateProcess: No Such file or directory.
So what I did was I went to this link here:
http://wiki.codeblocks.org/index.php?title=Installing_MinGW_with_Vista
And I first tried to add the directory to the
PATH: C:\MinGW\libexec\gcc\mingw32\MinGW-Version
(my directory is slightly different but follows same idea)
where MinGW-Version is the Version of MinGW you are using
So now that got rid of that error but now I get the error:
iostream: No such file or directory
So now I add the path where the iostream library is and that fixes that error but then I get all these other errors where it can't find other standard C++ libraries such as stddef.h or stdio.h etc. So it seems as if the C++ libraries cannot be linked to. I have tried various other things such as including C:\MinGW\bin in my path and have tried uninstalling and reinstalling Qt. Also I have checked that Qt is using the right gcc compiler by going to Tools->Options->Toolchains in Qt Creator.
It seems that the linking to C++ libraries is not correct for some reason. Could anyone help me or guide me as to why this may be happening and how to fix this?

I'm not sure why it's not working, so I'll just tell you how my environment is set up. I don't think you need to add any library paths to the system path. You should only need to add C:\MinGW\bin.
So get rid of everything except for that. Also, are you setting this through cmd or control panel? If doing it in the control panel, make sure you are putting it in the "Path" variable not "PATH" -> the former is in the lower box. I've had problems before using "PATH" in the upper box - not sure what the difference is to be honest.

The QtSDK installation usually install the mingw compiler for you in ...\QtSDK\mingw. The libraries and dlls in ...\QtSDK\Desktop\Qt\4.7.3\mingw were compiled with this compiler. The mingw compiler you installed to c:\MinGW may be a different version than that. If you want to use this compiler you would have to recompile the Qt libraries.

C++ librairies in Qt.
Go to this URL http://doc.qt.digia.com/qtcreator-2.4/creator-overview.html for how to.
It seems (I did not try it, yet) that other librairies can be easily linked to a Qt Project.
This could solve the problem.
Pythagooric

Related

Program installed with CMake /CPack / NSIS64 cannot find Qt plugins

I am trying to install a C++/Qt/Qml program with CMake. I tried the IFW generator, but I'd rather stick to NSIS64.
Setup install file is correctly generated, and program is correctly installed. But my installed Qt program crashes right away, because
qt.qpa.plugin: Could not find the Qt platform plugin "windows" in ""
It is an easy to solve problem when running the program from the command line: we just need to set QT_QPA_PLATFORM_PLUGIN_PATH to the current directory (I installed/copied qwindows.dll there).
It is strange that the .exe does not look into the current program directory for Qt plugins. Anyways, a way to solve my problem would be: how to set an environment variable in a shortcut .lnk (created by NSIS)?
I have tried a bunch of things with NSIS (added in NSIS.template.in):
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\#CPACK_NSIS_DISPLAY_NAME#.lnk" "QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin $INSTDIR\bin\#CPACK_NSIS_DISPLAY_NAME#.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\#CPACK_NSIS_DISPLAY_NAME#_cmd.lnk" \
"C:\Windows\System32\cmd.exe" "/c SET QT_QPA_PLATFORM_PLUGING_PATH=$INSTDIR\bin && start $INSTDIR\bin\#CPACK_NSIS_DISPLAY_NAME#.exe"
but this does not compile.
Maybe there is a different way to achieve this. Even if that would work, I would like to avoid setting QT_QPA_PLATFORM_PLUGING_PATH globally during the install, if possible, and restrain it to the program launch.
NOTE: documentation says:
CreateShortcut "$SMPROGRAMS\My Company\My Program.lnk" "$INSTDIR\My Program.exe"
"some command line parameters" "$INSTDIR\My Program.exe" 2 SW_SHOWNORMAL
ALT|CONTROL|SHIFT|F5 "a description"
but I am not too sure about how to use this in my case.

setting up Marble to work with Qt

I am trying to set up Marble to work with Qt 5.5 on OSX. I'm not very experienced with the details of linking and such and I think that is causing the problem I am having.
Question: Did I screw up the 'marble` install or is this an easily solved linking issue?
Qt 5.5 is installed in my user directory (using Qt's network installer) on a system running OSX 10.9.5. It works fine. I followed the instructions on the Marble site to clone, build and install from source with (I believe) the appropriate Qt flags. That seemed to go without issue. When I try to build the simple test app listed here, the #include <marble/MarbleWidget.h> line gives a "file not found" error.
After the install I've ended up with the following:
A "marble" directory in my root user folder
A "Marble.app" file along with various other marble related files in the bin and include directories. However the Marble.app gives the following error on launch:
Dyld Error Message: Library not loaded:
#rpath/QtCore.framework/Versions/5/QtCore Referenced from:
/usr/local/Marble.app/Contents/MacOS/marble-qt Reason: image not
found
Binary Images:
0x7fff6a1f9000 - 0x7fff6a22c817 dyld (239.4) <7AD43B9B-5CEA-3C7E-9836-A06909F9CA56> /usr/lib/dyld
So a semi-solution: I used the Qt Creator "add Library" function and ended up with the following additions to the .pro file. I had to paste in the link to the lib since the dialog doesn't allow browsing of "usr/local/". Also, although I tried to link to the lib alias ("libmarblewidget-qt5.dylib"), the actual lib name is used.
macx: LIBS += -L$$PWD/../../../../../usr/local/lib/ -lmarblewidget-qt5.0.21.80
INCLUDEPATH += $$PWD/../../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../../usr/local/include
I don't understand what this $$PWD/../../../../../ business is.
But it worked and I am able to run the example code at the link in my question.
I wish this install/build stuff wasn't so damned arcane. I've spent endless hours just trying to get things set up – really sucks the joy out of exploring this stuff and I can't say I really learned much of anything from it.
Update
So I cleaned out the "$$PWD" crap and the literal lib name and it works. Not sure what difference it makes – but there you go.
macx: LIBS += -L/usr/local/lib/ -lmarblewidget-qt5
INCLUDEPATH +=/usr/local/include
DEPENDPATH +=/usr/local/include
Either the build is faulty or you need a different version of Qt installed to run it. Usually the app has the Qt libraries that it needs wrapped up in the app itself. If it's not in there it will search your mac for it. The message says that QtCore can't be found in either place. If you look inside Google's Google Earth, you can see where the libraries are stored. You can also copy a version of QtCore into your Marble to see if it will work.

GLEW program can't find libglew.so even when file exists

I am trying to set up an OpenGL development environment on a Linux machine (Mint 17). I have just installed GLEW from the source on the GLEW source forge page (Downloaded source; extracted; make install).
I want to check that everything is set up correctly and am trying to run a test program. My program compiles and links but when I try to run it I get the error "error while loading shared libraries: libGLEW.so.1.12: cannot open shared object file: No such file or directory"
libGLEW.so.1.12 exists; from what I read I think I have a 32bit executable and the SO is 64bit. However I can't find a solution to this problem; I know I need to create a 32bit library but I can't find any instructions for doing this.
Can someone please provide instructions to either (or preferably both):
Install 32bit libraries for GLEW
Link with GLEW statically
Preferably I'd like to link statically for now (I find it far more convenient for testing) but the instructions on the GLEW website only say how to do this for windows. Eventually I do plan to link everything dynamically.

Qt | Can't get any cryptographic library to work

Over a week now I tried to implement every Cryptography-Library I could possibly find into QT to encrypt files and strings, but it just seems to be impossible for me.
I started with a clean Ubuntu-Installation, updated everything, installed QT and as Openssl is allready installed on Ubuntu, I tried to start with that.
I've read some tutorials, tried some examples, but nothing I did seemed to solve my "undefined reference" problem.
I googled for the right libs I maybe had to add to the project file, but nothing worked.
As Openssl didn't work for me, I googled my way through "QCA", "Crypto++", "MCrypt" and some public librarys I found.
With the first three I got the "undefined reference" errors again and the other librarys either had depracted code or wrong conversions between data types in the code itself.
I'm new to the whole cryptographic stuff, but I can't get it to work at all.
It would just be awesome if someone could release me from my pain and help me to get ANY library working from a clean ubuntu installation with QT.
I just have to do something wrong....it can't be that the tutorials I found on the web are working just fine for everbody else.
As an example....I installed the packages "libmcrypt-dev", "libmcrypt4" and "mcrypt" and followed the code example here: mcrypt linux how to use rijndael 256 cbc
The include works fine, the header file can be found and the code for the mcrypt classes is highlighted, so it should work, right?
But as I try to compile the code, I get "undefined reference" errors in every line that uses a function from mcrypt.
This also happened with all the other librarys....though I can't find anything missing that others did.
No additional includes are stated anywhere nor any additional library-references which I'd have to include in the project file.
What am I doing wrong?
I fear I don't really have anything to show you guys either, except you want to see a huge list with "undefined reference" errors. :-/
If I try something like that:
#include <mcrypt.h>
int main()
{
MCRYPT td = mcrypt_module_open("rijndael-256", NULL, "cbc", NULL);
mcrypt_module_close(td);
}
I get the following errors
error: undefined reference to `mcrypt_module_open'
error: undefined reference to `mcrypt_module_close'
Project file:
QT += core
QT -= gui
TARGET = untitled
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
error: undefined reference says, that linker can not find library itself. It has headers files, that you have included, but does not see source. To fix this, you have to tell linker, where the sources are, so add in your *.pro file add line, for example like this for libmcrypt library:
LIBS += -L/path/to -lmcrypt
In linux, if you have installed with apt-get install or something similar, -L usually is not needed

Cant use shared libraries in Qt project

I created a C++ library project in Qt creator. After building the project I have the libMylib.so, .so.1, .so.1.0, .so.1.0.0, Makefile and mylib.o files. I added the library headers to my other project and added the path to my .pro file like this:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
When building the application I don't get no such file error, but when running it I get this:
/home/peter/Workspace/build-Libtester-Desktop-Debug/Libtester: error while loading shared libraries: libMyLib.so.1: cannot open shared object file: No such file or directory
which I can't understand, because it's right there next to the .so which it seem to find, because when the path is wrong I get a no such file or directory error when trying to build the project.
Could someone explain what I'm missing here?
Thanks for your time.
Fortunately, your problem has nothing to do with both Qt and Qt Creator. The error simply boils down to how shared libraries are searched by LD for dynamic linking on Unix OS family.
Today, I've answered similar question, have a look, please. This question was asked in regard to Mac OS X. However, Linux and Mac OS X are the same in the context of your problem. I've provided additional explanation for Linux at the bottom, so pay attention to it. "it's right there next to the .so" - you seem to have Windows background if you make this assumption, but it is wrong for Unix OS family altogether (as stated in the answer too). If you have further questions, just ask.
You are adding the library incorrectly. You are doing:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
instead of:
LIBS += -L"/home/peter/Workspace/build-Libtester-Desktop-Release" -lMyLib
The first version works on windows, but not linux.
Basically, you create a library, which will be named "libMyLib.so", and then you specify the path to its folder, prepended by "-L" and then do "-lMyLib" at the end, note that it's not "-llibMyLib", but just "-lMyLib", despite the fact that the .so name is "libMyLib".
Look here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application for more info.

Resources