Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Cannot find many libs
Konstantinos last edited by
I try to build some projects, and I meet very often the same error: cannot find..., collect2.exe: error: ld returned 1 exit status.
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lqserialdevice
C:/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lcompfiles
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [bin\compedit.exe] Error 1
mingw32-make: *** [release] Error 2
10:40:15: The process "C:\mingw32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project compedit (kit: Qt 4.8.6 (4.8.6))
When executing step "Make"
And in many projects, not just in one....
After googling, I have understood that it may be spelling mistake in libs or paths, or spaces characters in paths etc... Or it could be something else?
What is the easiest way to solve it? Is there a standard way to solve it? What exactly I have to look for in the code?
Without irony, in 2016, there is not smart solutions, without human influence? Is it difficult for compiler or debugger to solve this problem themselves, without any human help?
I know this project well. Email me directly if you have any questions ...
The error messages are likely as stated ('... cannot find library ...'). You need to compile these sub projects first. For example, the library 'compfiles' must be compiled before 'compedit'. Same with 'qserialdevice'.
To compile the support projects go into the directory and run qmake followed by make.
cd libcompfiles qmake make
Once this is done you can compile compedit:
cd compedit qmake make
As long as all the source code folders are in the same directory no other changes are required. If you still run into a problem where it cannot find <something> likely whatever is missing is in the wrong spot.
It is possible to setup a group project file so that dependencies are compiled in the proper order (the order of the sub projects are compiled in the proper order) but it didn't seem necessary to set this up at that time.
Konstantinos last edited by
Thank you for your answer Rondog.
The libcompfiles library has been compiled but the qserialdevice has not.
I have this problem. No such file or directory #include <ddk/ntddser.h>, and if I remove the ddk/, then 'PHYSICAL_ADDRESS' does not name a type.
Maybe, because I am confused about paths.
Can someone make clear in my mind all about paths?
If any folder has 2 subfolders, then soon we can have millions of combinations.
Just explain to me what happens if I want to add a library to my project.
a) First of all what is library? the .pro file? the .pri file? The headers? a header? the source folder? A .cpp file? The src folder? Or library is just a folder that contains all of them?
b) How to include - put the library in another project? Where will I put its .pro or .pri file? Where will I put its headers and its source files (.cpp)? And what path exactly I will put in LIBS += or INCLUDEPATH += on project.pro file? Does it matter, if it has /bin or /debug? Can't I put all the .cpp files in the same source and all the headers in the same folder, and to compile all the project as it would be one without any distinguish between libraries and non-libraries?
I know, many of you have understood these things very well, so, can you make them clear in my mind?
For your QSerialPort problem, do you have
QT += serialportin your .pro file ?
I don't think the path is wrong or anything like that. When I check the ddk directory for mingw482 (provided by Qt) on my system I don't have that header either (ddk/ntddser.h). You can download individual components for MinGW such as the DDK headers and libraries which is likely all you need. Maybe grab an entire version of MinGW while you are at it.
A library is an external executable file (like a Windows DLL). The project file (pro file) can define if the compiled executable is a library or a stand alone executable.
You can add a library to another project by including a reference to it in your source code and adding the necessary directives in your project file (name and location of library, name and location of header files, etc). For example:
DEPENDPATH += ../qserialdevice/src/build/release INCLUDEPATH += ../qserialdevice/src/qserialdevice LIBS+= -L../qserialdevice/src/build/release -lqserialdevice
When the project file is processed entries will be added so the compiler knows where to find the additional files needed for the program (such as the file headers that you reference in your source code). You don't want to put references to these in the system path so this is an easy way to tell it where to look when searching for specific files or whatever. The references shown above are relative (up one folder, into 'qserialdevice', into 'src', ...).
@SGaist, it is Qt 4.8.x which didn't use QSerialPort.
@Rondog good point, I missed it. However if you clone the module from code.qt.io, there's a dedicated branch for Qt 4. Once you have built and installed it, you should be able to use it using the same technique as other modules.