I have a small C++ program that works correctly when it is dynamically linked with Qt-4.4.3. However, when it is statically linked with Qt-4.4.3 it fails to load the image from a file into a QImage object.

I am also using the open source Exiv2 library to access the image's header data.

Given and image filename the program first opens and reads the metadata with the following line (where filename is a QString):

Qt Code:
  1. _imageMetaData = Exiv2::ImageFactory::open(filename.toStdString());
To copy to clipboard, switch view to plain text mode 

Then sometime later is actually reads the image data with this line:

Qt Code:
  1. // Load image from file into _currentImage.
  2. if (!_currentImage.load(filename)) {
  3. std::cout << "\nFailed to load image from file" << std::endl;
  4. }
To copy to clipboard, switch view to plain text mode 


I have linked the program to Qt-4.4.3 both dynamically with Qmake and with a simplified makefile and statically with Qmake and a simplified makefile. The results were the same (the statically linked versions do not load the image). I have installed both a dynamically linked version of Qt-4.4.3 (/usr/local/Trolltech/Qt-4.4.3) and a statically linked version (/usr/local/Trolltech/Qt-4.4.3-Static). Also, I set PATH to the statically linked version's bin directory before invoking qmake.

Any thoughts or other experiments I can try? The .pro and makefile files follow.

Thanks for your help,

badjer1024

This is the .pro file:

Qt Code:
  1. TEMPLATE = app
  2. TARGET =
  3. DEPENDPATH += .
  4. INCLUDEPATH += .
  5. LIBS += -lexiv2
  6. # Input
  7. HEADERS += iMage_filearea.hpp \
  8. iMage_imagearea.hpp \
  9. iMage_imageheader.hpp \
  10. iMage_orientationdialog.hpp \
  11. iMage_picturearea.hpp \
  12. iMage_workarea.hpp
  13. SOURCES += iMage_filearea.cpp \
  14. iMage_imagearea.cpp \
  15. iMage_imageheader.cpp \
  16. iMage_main.cpp \
  17. iMage_orientationdialog.cpp \
  18. iMage_picturearea.cpp \
  19. iMage_workarea.cpp
To copy to clipboard, switch view to plain text mode 

and this is plagerized makefile:

Qt Code:
  1. ####### Compiler, tools and options
  2.  
  3.  
  4. DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
  5.  
  6. CXX = g++
  7. CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
  8.  
  9. INCPATH = -I/usr/local/Trolltech/Qt-4.4.3-Static/include \
  10. -I/usr/local/Trolltech/Qt-4.4.3-Static/include/QtCore \
  11. -I/usr/local/Trolltech/Qt-4.4.3-Static/include/QtGui
  12.  
  13. LINK = g++
  14. LFLAGS = -pthread
  15.  
  16. LIBS = -L/usr/X11R6/lib -L/usr/local/Trolltech/Qt-4.4.3-Static/lib \
  17. -Wl,-Bstatic -lexiv2 -lQtGui -lQtCore \
  18. -Wl,-Bdynamic -lpng -lSM -lICE -lXi -lXrender \
  19. -lXrandr -lfreetype -lfontconfig -lXext -lX11 -lz -lm \
  20. -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
  21.  
  22. DEL_FILE = rm -f
  23.  
  24.  
  25. ####### Files
  26.  
  27. SOURCES = iMage_filearea.cpp \
  28. iMage_imagearea.cpp \
  29. iMage_imageheader.cpp \
  30. iMage_main.cpp \
  31. iMage_orientationdialog.cpp \
  32. iMage_picturearea.cpp \
  33. iMage_workarea.cpp \
  34. moc_iMage_filearea.cpp \
  35. moc_iMage_imagearea.cpp \
  36. moc_iMage_orientationdialog.cpp \
  37. moc_iMage_workarea.cpp
  38.  
  39. OBJECTS = iMage_filearea.o \
  40. iMage_imagearea.o \
  41. iMage_imageheader.o \
  42. iMage_main.o \
  43. iMage_orientationdialog.o \
  44. iMage_picturearea.o \
  45. iMage_workarea.o \
  46. moc_iMage_filearea.o \
  47. moc_iMage_imagearea.o \
  48. moc_iMage_orientationdialog.o \
  49. moc_iMage_workarea.o
  50.  
  51. TARGET = iMage
  52.  
  53.  
  54. ####### Build rules
  55.  
  56. all: Makefile $(TARGET)
  57.  
  58. clean:
  59. -$(DEL_FILE) $(OBJECTS)
  60. -$(DEL_FILE) *~ core *.core
  61.  
  62. ####### Link
  63.  
  64. $(TARGET): $(OBJECTS)
  65. $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
  66.  
  67.  
  68. ####### Compile
  69.  
  70. iMage_filearea.o: iMage_filearea.cpp iMage_filearea.hpp
  71. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_filearea.o iMage_filearea.cpp
  72.  
  73. iMage_imagearea.o: iMage_imagearea.cpp iMage_imagearea.hpp \
  74. iMage_workarea.hpp \
  75. iMage_imageheader.hpp \
  76. iMage_orientationdialog.hpp \
  77. iMage_picturearea.hpp
  78. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_imagearea.o iMage_imagearea.cpp
  79.  
  80. iMage_imageheader.o: iMage_imageheader.cpp iMage_imageheader.hpp \
  81. iMage_orientationdialog.hpp
  82. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_imageheader.o iMage_imageheader.cpp
  83.  
  84. iMage_main.o: iMage_main.cpp iMage_workarea.hpp
  85. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_main.o iMage_main.cpp
  86.  
  87. iMage_orientationdialog.o: iMage_orientationdialog.cpp iMage_orientationdialog.hpp
  88. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_orientationdialog.o iMage_orientationdialog.cpp
  89.  
  90. iMage_picturearea.o: iMage_picturearea.cpp iMage_picturearea.hpp
  91. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_picturearea.o iMage_picturearea.cpp
  92.  
  93. iMage_workarea.o: iMage_workarea.cpp iMage_workarea.hpp \
  94. iMage_filearea.hpp \
  95. iMage_imagearea.hpp \
  96. iMage_imageheader.hpp \
  97. iMage_orientationdialog.hpp \
  98. iMage_picturearea.hpp
  99. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o iMage_workarea.o iMage_workarea.cpp
  100.  
  101. moc_iMage_filearea.o: moc_iMage_filearea.cpp
  102. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_iMage_filearea.o moc_iMage_filearea.cpp
  103.  
  104. moc_iMage_imagearea.o: moc_iMage_imagearea.cpp
  105. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_iMage_imagearea.o moc_iMage_imagearea.cpp
  106.  
  107. moc_iMage_orientationdialog.o: moc_iMage_orientationdialog.cpp
  108. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_iMage_orientationdialog.o moc_iMage_orientationdialog.cpp
  109.  
  110. moc_iMage_workarea.o: moc_iMage_workarea.cpp
  111. $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_iMage_workarea.o moc_iMage_workarea.cpp
  112.  
  113. ######## End of Makefile
To copy to clipboard, switch view to plain text mode