Link with specific library
I have posted on QtCentre forum a problem, but it seems that no one has answered this question, so I'll post here too, hoping that someone has an idea.
I have my application linked with latest version of GDAL, which don't have the same libpng version as Qt. My application project looks like:
QT -= core gui
GDALDIR = LIBS/GDAL/gdal-1.8
LIBS = -L$$GDALLIBDIR -lGDAL
When I try to open png file, libnpg say that it's linked with a newer version. Indeed when I debugged my application, it use the libpng open file function from Qt/3dparty/png instead from my GDAL library. On windows platform works just fine.
Can someone explain how to solve this problem ?
Just make sure that both libraries use the same version of libpng. You will need to up-/downgrade one of the two libraries.
Thank for your answer.
Ok, I'll try to do this. But my puzzlement remains the same. If my project have LIBS = -lGDAL, why QtCreator link my application with libpng from Qt/3dparty/png instead of libpng sources from GDAL, and this only happens in Ubuntu, but in windows work perfectly.
I'd guess you'll have to recompile one the both.
I recompiled all the files in GDAL ( but forget about GDAL, I'm almost sure that the same thing will happen if I want to use libpng only, other version, older than Qt/3dparty/png ).
Also I use QtSDK version 4.7.0, that comes with QtCreator 2.0.1, so libpng is already linked in libQtGui4.so.
But note that my project has QT -= core gui, I do not use anything from QtGUI, but my app insists to link with libpng from libQtGui4(d).a
Also may be the same problem with this ? : "(first note)":http://www.qtcentre.org/threads/39047-Linking-to-specific-PNG-JPEG-and-TIFF-libraries-when-building-Qt
If libpng is linked statically, it's a compiler issue. If it's linked dynamically, it's a problem of the library loader.
Anyways, the differences seem to be incompatible, so in my opinion you will have to recompile one to use the libpng of the other.
What do you mean with
bq. but my app insists to link with libpng from libQtGui4(d).a
If you don't link against QtGui, no symbols from that lib are imported in your app. Do you mean "libpng.a from the directory where libQtGui lives"? The latter can be avoided by using the full pathname to libpng.a.
libpng is linked statically.
What I wanted to say is: if I call for example "png_create_read_struct" function which resides in libpng library, debug my application, step into "png_create_read_struct" function, I expect debugger to go in "pngpread.c" file from my libpng, but the debugger shows, is "pngread.c" from qt/src/3rdparty/libpng. From what I understand, by default, Qt supports png read/write linked in QtGui, so this is my puzzle.