gcc -x c does link with -ljpeg, gcc -x c++ does not

Stefan Hetzl shetzl@chello.at
Fri Mar 28 09:58:00 GMT 2003


Hi,

I want to compile and link a small program (c code) that uses libjpeg. When I 
invoke "gcc -x c -v readcoeff.c -ljpeg" everything works fine, but invoking 
"gcc -x c++ -v readcoeff.c -ljpeg" gives "undefined reference..."-error 
messages for every function from libjpeg (see the attached outputs).

Any Ideas what could be causing this ?

Thanks,
Stefan Hetzl
-------------- next part --------------
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i486-suse-linux
Thread model: posix
gcc version 3.2
 /usr/lib/gcc-lib/i486-suse-linux/3.2/cc1 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i486__ readcoeff.c -quiet -dumpbase readcoeff.c -version -o /tmp/ccd7hPJ0.s
GNU CPP version 3.2 (cpplib) (i386 Linux/ELF)
GNU C version 3.2 (i486-suse-linux)
	compiled by GNU C version 3.2.
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i486-suse-linux/3.2/include
 /usr/i486-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/as -V -Qy -o /tmp/cc8DQBrU.o /tmp/ccd7hPJ0.s
GNU assembler version 2.12.90.0.15 (i486-suse-linux) using BFD version 2.12.90.0.15 20020717 (SuSE)
 /usr/lib/gcc-lib/i486-suse-linux/3.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i486-suse-linux/3.2/crtbegin.o -L/usr/lib/gcc-lib/i486-suse-linux/3.2 -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/lib -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../.. /tmp/cc8DQBrU.o -ljpeg -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i486-suse-linux/3.2/crtend.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crtn.o
-------------- next part --------------
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i486-suse-linux
Thread model: posix
gcc version 3.2
 /usr/lib/gcc-lib/i486-suse-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i486__ readcoeff.c -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase readcoeff.c -version -o /tmp/ccCizZoj.s
GNU CPP version 3.2 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2 (i486-suse-linux)
	compiled by GNU C version 3.2.
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++
 /usr/include/g++/i486-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/i486-suse-linux/3.2/include
 /usr/i486-suse-linux/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/bin/as -V -Qy -o /tmp/ccnuNkQl.o /tmp/ccCizZoj.s
GNU assembler version 2.12.90.0.15 (i486-suse-linux) using BFD version 2.12.90.0.15 20020717 (SuSE)
 /usr/lib/gcc-lib/i486-suse-linux/3.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i486-suse-linux/3.2/crtbegin.o -L/usr/lib/gcc-lib/i486-suse-linux/3.2 -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../../../i486-suse-linux/lib -L/usr/lib/gcc-lib/i486-suse-linux/3.2/../../.. /tmp/ccnuNkQl.o -ljpeg -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i486-suse-linux/3.2/crtend.o /usr/lib/gcc-lib/i486-suse-linux/3.2/../../../crtn.o
/tmp/ccnuNkQl.o: In function `main':
/tmp/ccnuNkQl.o(.text+0x4e): undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
/tmp/ccnuNkQl.o(.text+0x6d): undefined reference to `jpeg_CreateDecompress(jpeg_decompress_struct*, int, unsigned)'
/tmp/ccnuNkQl.o(.text+0xd4): undefined reference to `jpeg_stdio_src(jpeg_decompress_struct*, _IO_FILE*)'
/tmp/ccnuNkQl.o(.text+0xe8): undefined reference to `jpeg_read_header(jpeg_decompress_struct*, int)'
/tmp/ccnuNkQl.o(.text+0xfa): undefined reference to `jpeg_read_coefficients(jpeg_decompress_struct*)'
/tmp/ccnuNkQl.o(.text+0x1ab): undefined reference to `jpeg_destroy_decompress(jpeg_decompress_struct*)'
/tmp/ccnuNkQl.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


More information about the Gcc-help mailing list