PDA

View Full Version : Implement jpegsrc.v8b.tar.gz LINUX



ivanqt
29th November 2010, 19:15
Hi all,

I download lgpl qt libraries 4.7.1 for Linux/X11.

I have a source code that implement jpegsrc.v8b.tar.gz and I'd like to configure my qt to implement this library.

If I configure qt of this way, my jpegv8 library is not loaded. The system jpeg library is loaded:
./configure -prefix /home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers -release -opensource -fast -make tools -ljpeg -system-libjpeg -optimized-qmake

I know Qt loaded jpeg system library. For example:
#ldd bin/moc
linux-gate.so.1 => (0x00ddf000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x04c48000)
/lib/ld-linux.so.2 (0x0039d000)

I'd like to build and install jpegv8 in a directory and configure qt to use this jpegv8 library beside system one.

or

If I have my source code, how can I generate a Makefile to consider jpegv8 library and not generates this problem:

jpeg-dcom.o: In function read_jpeg_file
jpeg-dcom.c:(.text+0x37): undefined reference to jpeg_std_error
jpeg-dcom.c:(.text+0x80): undefined reference to jpeg_CreateDecompress
jpeg-dcom.c:(.text+0x92): undefined reference to jpeg_stdio_src
jpeg-dcom.c:(.text+0xa2): undefined reference to jpeg_read_header
jpeg-dcom.c:(.text+0x146): undefined reference to jpeg_start_decompress
jpeg-dcom.c:(.text+0x1a8): undefined reference to jpeg_read_scanlines
jpeg-dcom.c:(.text+0x1d9): undefined reference to jpeg_finish_decompress
jpeg-dcom.c:(.text+0x1e1): undefined reference to jpeg_destroy_decompress
jpeg-dcom.c:(.text+0x24a): undefined reference to jpeg_destroy_decompress
collect2: ld returned 1 exit status
make: *** mybinfile Error 1

If I modify this line in my Makefile
- LIBS=$(SUBLIBS) -L/usr/local/Trolltech/Qt-4.7.1/lib -lQtGui -L/usr/local/lib -L/usr/local/Trolltech/Qt-4.7.1/lib -L/usr/X11R6/lib -lQtNetwork -lQtCore -lpthread
- LIBS=$(SUBLIBS) -L/usr/local/Trolltech/Qt-4.7.1/lib -lQtGui -L/usr/local/lib -L/usr/local/Trolltech/Qt-4.7.1/lib -L/usr/X11R6/lib -lQtNetwork -lQtCore -lpthread -ljpeg

The problem below disappears and I my bin file is generated. At the moment of execute my bin file I get this error:


# ./mybinfile
./mybinfile: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
# ldd mybinfile
linux-gate.so.1 => (0x00912000)
libjpeg.so.8 => not found
....

ivanqt
1st December 2010, 17:02
In google I found -rpath and -rpath-link variables that can be set. Do you think this can help?

Ragards and thanks in advance...

ChrisW67
1st December 2010, 23:03
I'd compile and install the version 8b JPEG library somewhere and then try the -I and -L options to configure:


-I <string> ........ Add an explicit include path.
-L <string> ........ Add an explicit library path.

before I started editing generated Makefiles or hard coding library paths into executables (with rpath).

Of course, you could just update your system library.

At run time the shared library file must be located in the system library path (see /etc/ld.so.conf) or in the LD_LIBRARY_PATH of the running environment.

ivanqt
6th December 2010, 23:16
Hi ChrisW67,

Sorry by the inconvenience but may be more specific? I mean, provide an example.

For example at the moment of execute ./configure -I/usr/local/*.so -L/usr/local.

Do you have extra documentation about rpath?

Regards and thanks in advance
Iván Maldonado Zambrano

ChrisW67
6th December 2010, 23:43
Sorry, been for a short holiday in New Zealand

The -I option sets paths to search for include files, not a wildcard list of dynamically loaded library files. Similarly, the -L options sets paths for the linker to search when looking for library files (libjpeg.a and/or libjpeg.so) during linking.

Assuming that the updated JPEG library files are installed into /usr/local/include, /usr/local/lib etc then:


./configure -I/usr/local/include -L/usr/local/lib

should do it.

Rpath is documented in the linker manual page:

man ld
Neither of the configure options controls how the dynamically loaded library (libjpeg.so in this case) is found at runtime: rpath has some impact on this. Using rpath is frowned upon because it makes adapting your software to other environments more difficult: rpath is typically given more weight than the user's environment (LD_LIBRARY_PATH). See also http://en.wikipedia.org/wiki/Rpath_%28linking%29

ivanqt
7th December 2010, 22:58
Hi ChrisW67,

In this case, what configure option must be set?


-no-libjpeg ........ Do not compile JPEG support.
-qt-libjpeg ........ Use the libjpeg bundled with Qt.
+ -system-libjpeg .... Use libjpeg from the operating system.
See http://www.ijg.org

Regards and thanks in advance

ChrisW67
7th December 2010, 23:27
The configure script defaults to automatic detection of the presence of a system JPEG library. If you have the -I and -L options set correctly then it should find yours in preference to the vendor's.

If you really must set it manually then:

Clearly the first option is of no use.
The second one will ignore the system JPEG library and also your JPEG library and use whatever is bundled inside Qt (v8 of the library in 4.7.0).
That leaves only one option.

ivanqt
8th December 2010, 07:23
Hi ChrisW67,

I installed jpeg-8b in this directory:
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib

[root@ivan jpeg-8blib]# ls
bin include lib share

Then I created a new *.conf file (jpeg8b.conf) in ld.so.conf.d directory:
[ivan@ivan ld.so.conf.d]$ pwd
/etc/ld.so.conf.d
[ivan@ivan ld.so.conf.d]$ ls -alth
total 56K
drwxr-xr-x. 133 root root 8.0K Dec 8 00:58 ..
drwxr-xr-x. 2 root root 4.0K Dec 8 00:07 .
-rw-r--r-- 1 root root 74 Dec 8 00:07 jpeg8b.conf
-rw-r--r-- 1 root root 15 Nov 1 21:31 mysql-i386.conf
-rw-r--r-- 1 root root 25 Oct 27 11:08 xulrunner-32.conf
-r--r--r-- 1 root root 63 Oct 18 23:39 kernel-2.6.34.7-61.fc13.i686.PAE.conf
-r--r--r-- 1 root root 63 Sep 14 22:32 kernel-2.6.34.7-56.fc13.i686.PAE.conf
-r--r--r-- 1 root root 63 Sep 5 12:49 kernel-2.6.34.6-54.fc13.i686.PAE.conf
-rw-r--r-- 1 root root 15 Jul 29 08:10 opencv.conf
-rw-r--r--. 1 root root 20 Dec 22 2009 qt-i386.conf
[ivan@ivan ld.so.conf.d]$ cat jpeg8b.conf
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/lib

After that I configured my Qt like this:

./configure -prefix /home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/Trolltech/Qt-4.7.1-ljpeg -opensource -I/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/include -L/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/lib -ljpeg

At the moment of type gmake, this error appears:
gmake[1]: Entering directory `/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/src/corelib'
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTERPRETER=\"/lib/ld-linux.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/linux-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared animation/qabstractanimation.h -o .moc/release-shared/moc_qabstractanimation.cpp
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/bin/moc: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
gmake[1]: *** [.moc/release-shared/moc_qabstractanimation.cpp] Error 127
gmake[1]: Leaving directory `/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/src/corelib'
gmake: *** [sub-corelib-make_default-ordered] Error 2

Do you have any idea?

Regards and thanks in advance

ivanqt
8th December 2010, 07:24
Hi ChrisW67,

I installed jpeg-8b in this directory:
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib

[root@ivan jpeg-8blib]# ls
bin include lib share

Then I created a new *.conf file (jpeg8b.conf) in ld.so.conf.d directory:
[ivan@ivan ld.so.conf.d]$ pwd
/etc/ld.so.conf.d
[ivan@ivan ld.so.conf.d]$ ls -alth
total 56K
drwxr-xr-x. 133 root root 8.0K Dec 8 00:58 ..
drwxr-xr-x. 2 root root 4.0K Dec 8 00:07 .
-rw-r--r-- 1 root root 74 Dec 8 00:07 jpeg8b.conf
-rw-r--r-- 1 root root 15 Nov 1 21:31 mysql-i386.conf
-rw-r--r-- 1 root root 25 Oct 27 11:08 xulrunner-32.conf
-r--r--r-- 1 root root 63 Oct 18 23:39 kernel-2.6.34.7-61.fc13.i686.PAE.conf
-r--r--r-- 1 root root 63 Sep 14 22:32 kernel-2.6.34.7-56.fc13.i686.PAE.conf
-r--r--r-- 1 root root 63 Sep 5 12:49 kernel-2.6.34.6-54.fc13.i686.PAE.conf
-rw-r--r-- 1 root root 15 Jul 29 08:10 opencv.conf
-rw-r--r--. 1 root root 20 Dec 22 2009 qt-i386.conf
[ivan@ivan ld.so.conf.d]$ cat jpeg8b.conf
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/lib

After that I configured my Qt like this:

./configure -prefix /home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/Trolltech/Qt-4.7.1-ljpeg -opensource -I/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/include -L/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/jpeg-8blib/lib -ljpeg

At the moment of type gmake, this error appears:
gmake[1]: Entering directory `/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/src/corelib'
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/bin/moc -DQT_SHARED -DQT_BUILD_CORE_LIB -DQT_NO_USING_NAMESPACE -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DELF_INTERPRETER=\"/lib/ld-linux.so.2\" -DHB_EXPORT=Q_CORE_EXPORT -DQT_NO_DEBUG -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../mkspecs/linux-g++ -I. -I../../include -I../../include/QtCore -I.rcc/release-shared -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I.moc/release-shared animation/qabstractanimation.h -o .moc/release-shared/moc_qabstractanimation.cpp
/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/bin/moc: error while loading shared libraries: libjpeg.so.8: cannot open shared object file: No such file or directory
gmake[1]: *** [.moc/release-shared/moc_qabstractanimation.cpp] Error 127
gmake[1]: Leaving directory `/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/QtInstallers/qt-everywhere-opensource-src-4.7.1/src/corelib'
gmake: *** [sub-corelib-make_default-ordered] Error 2

Do you have any idea?

Regards and thanks in advance

SixDegrees
8th December 2010, 09:04
It's already been pointed out many times that this isn't a configure problem. You can play with configure until the cows come home, but if the OS can't locate your dynamic library at runtime, your application will fail.

Put your library in the same directory as your executable as a first step. If that works, adjust your LD_LIBRARY_PATH to include your "standard" location. Better yet, install the library in some standard place where the dynamic linker already expects to find libraries, like /usr/lib or some other appropriate spot.

The linker is telling you everything you need to know: it doesn't know where your library is. You have to tell it.

If you're trying to build Qt using a different jpeg library than it was coded for, you're going to fail. No amount of linker magic can overcome a foreign API.

ChrisW67
8th December 2010, 22:07
You have actually built the JPEG library, haven't you? ;)

Did you run ldconfig after playing with the global system library search path? In any case, for development purposes you are far better off leaving the system path alone and using the LD_LIBRARY_PATH environment variable (or installing Qt into a location that is already searched).

The configure command for Qt does not need the repeated -l flags you have given it.

This really is not rocket science:


#!/bin/bash
export MYPROJ=/home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject
export MYJPEG=${MYPROJ}/jpeg-8blib
export LD_LIBRARY_PATH=${MYJPEG}/lib
cd ${MYPROJ}/QtInstallers/qt-everywhere-opensource-src-4.7.1
./configure -I${MYJPEG}/include -L${MYJPEG}/lib -prefix ${MYPROJ}/Trolltech/Qt-4.7.1
make


The Qt source will happily build and run against this version of libjpeg (my system uses it globally). The version bundled inside Qt is version 8, I assume without the a and b patches. This whole exercise only has some value if Ivan wants something in the a or b patches, otherwise using the Qt bundled libjpeg would be a far easier option.

ivanqt
9th December 2010, 21:37
Hi ChrisW67,

Thanks for your support.

The last script works great. I'm using this script for linux-embedded.

At the end I installed libjpeg in /usr directory.
Example:
# ./configure -prefix /home/ivan/WinXP/Ivan_Maldonado/PeekDocuments/VideoProject/Trolltech/Qt-4.7.1-ljpeg -opensource -release -fast -system-libjpeg -ljpeg

Regards and thanks for all