Project

General

Profile

Newbie - build/link problem

Added by hugh dixon almost 11 years ago

Hi,
I'm reasonably experienced with C/C++ on MSWindows but have found a problem using exiv2 in a QT project on Mandriva Linux. (An environment in which I do not have much knowledge)
I have added exiv2 to my qt project, and have copied the first few lines of sample code from exifprint.cpp.
Stepping through the code everything appears to work until it reaches the exifData::count function. The problem appears to be in the iterator, where it seems to access a bad pointer.

I suspect there must be something wrong with the way I have set the project up, or I do not have some other required package installed.
I am hoping someone may have seen this before and can point me in the direction of a fix.

With thanks

H


Replies (11)

RE: Newbie - build/link problem - Added by Andreas Huggel almost 11 years ago

Stepping through the code

If you can debug it, you must have successfully compiled and linked your program.
Can show the Exiv2 related code?

RE: Newbie - build/link problem - Added by Robin Mills almost 11 years ago

Hugh

I've just tried that on using QtCreator 2.0.1 which uses Qt 4.7.1 on Ubuntu 10.10. Worked effortlessly for me. I used the project wizard to create a command-line program and pasted in the code from exiv2/samples/exifprint.cpp. I added LIBS += -L/usr/local/lib -lexiv2 to the .pro file. It built, linked and ran first time.

How are you building and linking the code? Are you using QtCreator and qmake? I don't know if you've downloaded or built the exiv2 libraries from source. I have the libraries built from source.

If you're still stuck, zip up your project and send it to me and I'll investigate on Wednesday (I'm in California - so I'm off to bed now).

Robin

RE: Newbie - build/link problem (code) - Added by hugh dixon almost 11 years ago

The code that causes the problem is:

void exifGUI::on_readFile_clicked() {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(ui->fileName->text().toStdString());
Exiv2::Image* iNum = image.get();
image->readMetadata();
Exiv2::ExifData &exifData = iNum->exifData();
if (exifData.empty()) {
std::cout << "no good";
}

It dies in the iterator in the exifData.empty90 function.

RE: Newbie - build/link problem - Added by hugh dixon almost 11 years ago

Robin,
I have set up a console app and it will not compile.
I will investigate this further. I believe there is a problem with my installation.

Thanks all for the fast replys

Hugh

RE: Newbie - build/link problem - Added by Robin Mills almost 11 years ago

Hugh

The command-line exifprint.cpp code passes argv1 to open. Can you try:

Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(ui->fileName->text().toAscii());

Robin

RE: Newbie - build/link problem - Added by hugh dixon almost 11 years ago

Hi,
Sorry to have been off line for so long, but have been looking at options.
It appears the mandriva version of exiv2 isv 0.19 and does not include the file exiv2.hpp
I think I was running/linking against different versions (0.21 and 0.19)
I think I have now sorted out version and am using 0.21.1.
I now get a link error as below:

*************
make: Entering directory `/home/hugh/code/exifConsole-build-desktop'
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_PHONON_LIB -DQT_XMLPATTERNS_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib/qt4/mkspecs/linux-g++ -I../exifConsole -I/usr/lib/qt4/include/QtCore -I/usr/lib/qt4/include/QtGui -I/usr/lib/qt4/include/QtXml -I/usr/lib/qt4/include/QtXmlPatterns -I/usr/lib/qt4/include/phonon -I/usr/lib/qt4/include -I/usr/local/include/exiv2 -I/usr/lib/qt4/include/phonon_compat -I. -I../exifConsole -I. -o main.o ../exifConsole/main.cpp
g++ -Wl,--as-needed -Wl,--no-undefined -Wl,-z,relro -Wl,-O1 -Wl,--build-id -o exifConsole main.o -L/usr/lib -L/usr/local/lib -lexiv2 -lphonon -lQtXmlPatterns -L/usr/lib -lQtNetwork -lQtXml -lQtGui -lQtCore -lpthread
main.o: In function `BasicError<std::string>':
make: Leaving directory `/home/hugh/code/exifConsole-build-desktop'
/usr/local/include/exiv2/error.hpp:268: undefined reference to `Exiv2::BasicError<char>::setMsg()'
collect2: ld returned 1 exit status
make: *** [exifConsole] Error 1
The process "/usr/bin/make" exited with code %2.

nm on the lib gives:

**
00102c10 T ZN5Exiv210AsciiValueC2Ev
001064a0 T _ZN5Exiv210AsciiValueD0Ev
001064e0 T _ZN5Exiv210AsciiValueD1Ev
00106510 T _ZN5Exiv210AsciiValueD2Ev
0005eef0 T _ZN5Exiv210BasicErrorIcE6setMsgEv
00055e00 t _ZN5Exiv210BasicErrorIcEC1Ei
0005d6a0 t _ZN5Exiv210BasicErrorIcEC1ISsEEiRKT

00118630 t ZN5Exiv210BasicErrorIcEC1ISsPKcEEiRKT_RKT0
00034710 t ZN5Exiv210BasicErrorIcEC1ISsSsEEiRKT_RKT0
00118710 t ZN5Exiv210BasicErrorIcEC1ISsmEEiRKT_RKT0
00033470 t _ZN5Exiv210BasicErrorIcED0Ev
00033740 t _ZN5Exiv210BasicErrorIcED1Ev

so setMsg is there. What I am wondering about is "What is a charT" and where is this defined? Am I mixing ASCII and unicode?

Can you help again please?

Thanks,
Hugh

RE: Newbie - build/link problem - Added by Robin Mills almost 11 years ago

Hugh

Did you install the library after you built it? sudo make install ? Your library seems to be OK:

1194 /home/rmills $ nm -g /usr/local/lib/libexiv2.so.10.0.1 | grep setMsg
0005dac0 T _ZN5Exiv210BasicErrorIcE6setMsgEv
1195 /home/rmills $ c++filt _ZN5Exiv210BasicErrorIcE6setMsgEv
Exiv2::BasicError<char>::setMsg()
1196 /home/rmills $

I attach a Qt project using the code from exifprint. I've added a line of code to report the library version.

1181 /home/rmills/Projects/exifprint-build-desktop $ exifprint ~/R.jpg | grep version
package version = exiv2 0.21.1
1182 /home/rmills/Projects/exifprint-build-desktop $

Here are the libraries which I have build (from the 0.21.1 archive on the downloads page).
1190 /home/rmills $ ls alt /usr/local/lib/*exiv*
-rw-r--r-
1 root root 3695494 2011-02-15 17:24 /usr/local/lib/libexiv2.a
rw-r--r- 1 root root 1020 2011-02-15 17:24 /usr/local/lib/libexiv2.la
lrwxrwxrwx 1 root root 18 2011-02-15 17:24 /usr/local/lib/libexiv2.so > libexiv2.so.10.0.1
lrwxrwxrwx 1 root root 18 2011-02-15 17:24 /usr/local/lib/libexiv2.so.10 -> libexiv2.so.10.0.1
-rw-r--r-
1 root root 2228257 2011-02-15 17:24 /usr/local/lib/libexiv2.so.10.0.1
1191 /home/rmills $ ^C

If you're still stuck, please zip and send me your code:

Robin

RE: Newbie - build/link problem - Added by hugh dixon almost 11 years ago

Hi,
Yes I ran make install as root, and I can see no errors (I still have the terminal open)
I have unzipped your sample and I get the same link error with it as I had previously with my other sample code.
I have not included my code sample, as I am convinced the problem is with my installation.
The qt environment shows EXV_PACKAGE_STRING as exiv2 0.21.1

ls l in /usr/local/lib gives:
total 7152
-rw-r--r-
1 root root 288751 2011-02-12 19:32 blah.txt
rwxrwxrwx 1 root root 598970 2011-01-16 18:38 libexif.a*
-rwxrwxrwx 1 root root 951 2011-01-16 18:38 libexif.la*
lrwxrwxrwx 1 root root 17 2011-01-16 18:38 libexif.so -> libexif.so.12.3.2*
lrwxrwxrwx 1 root root 17 2011-01-16 18:38 libexif.so.12 -> libexif.so.12.3.2*
-rwxrwxrwx 1 root root 397262 2011-01-16 18:38 libexif.so.12.3.2*
-rw-r--r-
1 root root 3761088 2011-02-16 11:21 libexiv2.a
rw-r--r- 1 root root 1018 2011-02-16 11:21 libexiv2.la
lrwxrwxrwx 1 root root 18 2011-02-16 11:21 libexiv2.so > libexiv2.so.10.0.1
lrwxrwxrwx 1 root root 18 2011-02-16 11:21 libexiv2.so.10 -> libexiv2.so.10.0.1
-rw-r--r-
1 root root 2254919 2011-02-16 11:21 libexiv2.so.10.0.1
drwxrwxrwx 2 root root 4096 2011-02-16 11:21 pkgconfig/

I use to have regular problems with linker errors on strings using different string types, and still feel that is the problem here.

Thanks again for all the help
Hugh

RE: Newbie - build/link problem - Added by Robin Mills almost 11 years ago

Hugh

I don't know what's wrong. I've done away with QtCreator and boiled this down to little script "builder.sh":

#!/bin/bash
CODE=/home/rmills/Projects/exifprint
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../exifprint -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I"$CODE" "$CODE/main.cpp" -o main.o
g++ -o exifprint main.o -L/usr/lib -L/usr/local/lib -lexiv2 -lQtCore -lpthread

Ignore the browser folding the code, you should have 4 lines which start: #! , CODE=, g++ -c , g++ -o

Here's what happens when I run it.

1349 /home/rmills/temp/hugh $ chmod +x builder.sh
1350 /home/rmills/temp/hugh $ ./builder.sh
1351 /home/rmills/temp/hugh $ ./exifprint ~/R.jpg | egrep -e version -e Date
package version = exiv2 0.21.1
Exif.Image.DateTime 0x0132 Ascii 20 2010:09:05 11:52:15
Exif.Photo.DateTimeOriginal 0x9003 Ascii 20 2010:09:05 11:52:15
Exif.Photo.DateTimeDigitized 0x9004 Ascii 20 2010:09:05 11:52:15
1352 /home/rmills/temp/hugh $

Obviously, you'll need to set CODE for your environment. main.cpp is the one I posted before in the exifprint.pro project.

If your unable to get this to work, I suggest you ask on a forum which deals with Mandriva. For example: LinuxQuestions.

Robin

RE: Newbie - build/link problem - Added by Andreas Huggel almost 11 years ago

Hugh,

Could it be that you have another, older, libexiv2 on your system a, e.g., in /usr/lib and gcc links with that instead of /usr/local/lib/libexiv2* ?

Andreas

RE: Newbie - build/link problem - Added by hugh dixon over 10 years ago

yes!!!

I have found libexiv2.so.6.0.0 in /usr/lib.
The above builder.sh does not work, but if I put

g++ -o exifprint main.o -L/usr/local/lib -L/usr/lib -lexiv2 -lQtCore -lpthread

it is fine.

Thank you all for your patience!!!
Hugh

    (1-11/11)