Having trouble linking after new install of fltk and os

17 views
Skip to first unread message

david allen

unread,
Jun 29, 2021, 2:05:10 PM6/29/21
to fltk.general
My build structure looks like this
src:   many *.cpp *.h pairs
build: library containing compiled versions of everything in src
apps:  a few .cpp files, each containing a main function. Uses library in build, cairo, and gsl.

My system
  Operating System: Linux Mint 20.1
            Kernel: Linux 5.4.0-77-generic
      Architecture: x86-64

cmake install of fltk
    cmake -G"Unix Makefiles" -DOPTION_CAIRO:BOOL=ON -D CMAKE_BUILD_TYPE=Debug ..

Everything seems to be fine until linking one of the programs in apps. The stderr output follows. One curious thing is the ".cxx.o" extension. Suggestions much appreciated.

/usr/bin/ld: /usr/local/lib/libfltk_images.a(Fl_JPEG_Image.cxx.o): in function `jpeg_mem_src(jpeg_decompress_struct*, unsigned char const*)':
/home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:198: undefined reference to `jpeg_resync_to_restart'
/usr/bin/ld: /usr/local/lib/libfltk_images.a(Fl_JPEG_Image.cxx.o): in function `Fl_JPEG_Image::load_jpg_(char const*, char const*, unsigned char const*)':
/home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:253: undefined reference to `jpeg_std_error'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:273: undefined reference to `jpeg_finish_decompress'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:275: undefined reference to `jpeg_destroy_decompress'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:298: undefined reference to `jpeg_CreateDecompress'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:300: undefined reference to `jpeg_stdio_src'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:304: undefined reference to `jpeg_read_header'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:311: undefined reference to `jpeg_calc_output_dimensions'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:321: undefined reference to `jpeg_start_decompress'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:327: undefined reference to `jpeg_read_scanlines'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:330: undefined reference to `jpeg_finish_decompress'
/usr/bin/ld: /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:331: undefined reference to `jpeg_destroy_decompress'
collect2: error: ld returned 1 exit status
make: *** [Makefile:53: apps/ui] Error 1

Ian MacArthur

unread,
Jun 29, 2021, 2:56:37 PM6/29/21
to Fltk General
On 29 Jun 2021, at 19:05, david allen wrote:
>
> One curious thing is the ".cxx.o" extension.

Though cmake does have something of a penchant for doing that (making output filenames by just appending the extension onto the full name, rather than replacing the extension) so that may be entirely normal.

I’ve seen cmake do this is a variety of different builds that all basically worked fine...


> Suggestions much appreciated.
>
> /usr/bin/ld: /usr/local/lib/libfltk_images.a(Fl_JPEG_Image.cxx.o): in function `jpeg_mem_src(jpeg_decompress_struct*, unsigned char const*)':
> /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:198: undefined reference to `jpeg_resync_to_restart'
> /usr/bin/ld: /usr/local/lib/libfltk_images.a(Fl_JPEG_Image.cxx.o): in function `Fl_JPEG_Image::load_jpg_(char const*, char const*, unsigned char const*)':
> /home/david/fltk-repository/fltk/src/Fl_JPEG_Image.cxx:253: undefined reference to `jpeg_std_error’


These look (at least to me) very much like a link-order problem - you need to check the link order and ensure that libjpeg is being linked *after* libfltk_images or the linker may not be able to resolve the symbols (or alternately, put the libs into a group where they will be (re-)searched repeatedly until all the symbols are resolved.)


david allen

unread,
Jun 29, 2021, 5:27:57 PM6/29/21
to fltk.general
In searching for when libjpeg was linked, i found it was not installed. my bad, but you solved my problem indirectly. Thanks!
Reply all
Reply to author
Forward
0 new messages