Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Compilation Error , Can't find lib file.
I have got a qt project from web, and I'm trying to work on it, but when i compile it I get an error " Can't find file -lz "
In the pro file I can see "-lz" is being used as below.
LIBS += -lz
Commenting out the above line, makes the project to compile but I find issues in running the project,
Can some one explain me what exactly the above statement is trying to do, and how this issue can be solved.
I'm using qt 4.7.0 on win7 64bit os.
Thanks in advance.
HuXiKa last edited by
You have to add another line to your .pro file:
LIBS += -Lpath_of_the_directory_which_contains_your_lib
Or, if you don't want to use static linking, check out "QLibrary":http://doc.trolltech.com/latest/qlibrary.html.
the statement should adds a library "z" for the linking process. This statement is valid for unix. Which compiler are using?
An addition to the post.
You should have a look to the "qmake libs parameter":http://doc.qt.nokia.com/latest/qmake-variable-reference.html#libs
It expalins in "length" the parameter.
HuXiKa is right that you might need to add the path to the library to the LIBS statement. However, this might depend on the compiler you are using.
I found that the code related to "z" library is found in qt installation directory.
Now could you please tell me how do I need to modify "LIBS += -lz" line in pro, to use the library from the above specified path..
I tried lot of options but nothing is working out.
and regarding the compiler, I’m using qt 4.7.0 on win7 64bit os. then this must be using Mingw
Also to give you some more information, the pro file has following statements .
LIBS += -lz
INCLUDEPATH += c:\development\zlib-1.2.3
LIBS += -Lc:\development\zlib-1.2.3
Kindly help on this.
I am not sure what sequence you might require in the pro file. However, typically you see the path infront of the lib.
INCLUDEPATH += c:/development/zlib-1.2.3
LIBS += -Lc:/development/zlib-1.2.3
LIBS += -lz
I have changed your backward slash into the forward version. Windows can handle both, but the forward version is a little easier to handle.
The actual path of the library has to be included. I am not sure why you have chosen a different path from "C:/Qt/2010.05/qt/src/3rdparty/zlib" in your example.
The statement INCLUDEPATH is required for finding the includes.
The origin of your problem is that you are trying to use a library where you do not have the library yet. All the path' are showing to a src directory. I have checked my installation (4.7.0 on win7 64 bit). I cannot find zlib readily compiled for linking. You need to do so. Check the readme file and others in the directory. This should provide you with the necessary details.
Finally a recommendation to use the newest version of Qt. Download the most recent version 4.7.3.
the name should look like this: http://get.qt.nokia.com/qt/source/qt-win-opensource-4.7.3-mingw.exe or similar depending on what options you are choosing.
Hi koahnig and HuXiKa,
Thanks a lot for your suggestions, I tried those, but not arriving at the solution.
Ok, what I'm really working on is this "https://sourceforge.net/projects/umplayer/develop" a qt based media player with many unique features.
As i said earlier I’m using qt 4.7.0 on win7 64bit os.
Can you please, if possible get this project and compile it on windows OS, so that you would get what exactly the problems that I'm facing in getting this project compiled.
I hope for a positive reply.
for curiosity I had a look to your link supplied. It does not lead anywhere.
It returns with:
@This page has been deprecated and is now controlled by the consume team.@
Did you try to compile the 3rd party zlib?
Since it is not part of Qt everybody will run into the problem as you did. The lib is simply not available.
Try to compile it. However, you are on your own there. I cannot give support, since I have not done a compilation of Qt's 3rd party SW before.
So again, did you try to compile the 3rd party lib?
Sorry the link mentioned above is redirecting to wrong location, you can use the below link.
Click on " Code -> SVN " it will take you to a new page where you can see the location from where you can get the code.
As you have mentioned the lib files are not readily available for 3rd party components, we need to build it manually, I checked that option also, the project needs to be compiled with visual studio. I'm trying out this now.
Meanwhile if you come across any solutions, please guide me.
I hope you are using the same compiler throughout your project. Mixing different compilers will certainly NOT help.
Best regards, Koahnig
I just saw that you can add zlib support while compiling a version of Qt for your platform.
You need to use the parameter "-qt-zlib" in the configure command. That might be the saver option for you to compile zlib.