Build problem

Hi,
I'm currently switching to github branch libraw 0.21-stable and tried to compile a more recent version of libraw. Unfortunately, running make after ./configure, I'm getting below error on macos Sonoma. What is needed to fix this?
Best,
Thilo

macbook:LibRaw user$ make
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh '/Users/tbauer/git/LibRaw/missing' aclocal-1.16 -I m4
/Users/tbauer/git/LibRaw/missing: line 81: aclocal-1.16: command not found
WARNING: 'aclocal-1.16' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:

It also requires GNU Autoconf, GNU m4 and Perl in order to run:

make: *** [aclocal.m4] Error 127

Forums: 

You need to either install

You need to either install autotools or just use make -f Makefile.dist
(adjust makefile to meet your needs: JPEG comression support, etc)

-- Alex Tutubalin @LibRaw LLC

Hi Alex,

Hi Alex,

Again, thanks for your quick support. I realized, that I had to update the whole brew installation on my mac and also install and upgrade a lot more tools and libraries, like automake or pkg-config, which is mentioned in an earlier post.

Also I had to install libraries, like jasper, or zlib. From a perspective of such an upgraded full fledged development machine, it is hard to judge, what libraries need to be provided with libraw bundled with an app on a plain macos end-user installation.

All dependencies (additional libraries) that are now compiled with libraw obviously do not exist on a barebone macos installation, esp. without additional development tools like XCode and additional add-ons installed using homebrew installation manager.

Is there a list of libraries (DLLs, share libs) that need to be provided together with any application that relies on libraw and not running in a full fledged development machine environment?

It would be a nightmare for a developer of collecting complaints from end-users that quickly refuse to use your app because its not running on a real world mac. :-)

Thanks,

Thilo

With default/unchanged

With default/unchanged Makefile.dist LibRaw requires zlib only (present in base macOS).

All additional dependencies (libjpeg, RawSpeed, Adobe DNG SDK) are optional and disabled by default.

-- Alex Tutubalin @LibRaw LLC

Thanks again. I could solve

Thanks again. I could solve the compile problems. Now, I'm getting a lot of undefined symbols when trying to link the library against my app. Most of them sound like the optional packages have been compiled into the library, now missing their references when linking against the static library for branch "LibRaw 0.21-stable", which sounds weird.

ld: Undefined symbols:
  LibRaw::open_file(char const*), referenced from:
      _Java_net_bwmc_libraw_LibRawImageLoader_loadRawImage in LibRawImageLoader.o

I tried to resolve this, by rolling back to version 0.20 and rebuild the library for this version, which previously worked. However, the list of undefined references I get while linking is even longer. Now, it sounds like optional libraries haven't been detected as optional when switching to branch "LibRaw 0.20-stable" and rebuilding after 'make clean'.

ld: Undefined symbols:
  LibRaw::open_file(char const*), referenced from:
      _Java_net_bwmc_libraw_LibRawImageLoader_loadRawImage in LibRawImageLoader.o
  _jpeg_CreateDecompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
  _jpeg_abort_decompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
  _jpeg_destroy_decompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
  _jpeg_finish_decompress, referenced from:
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
  ...

I followed the instructions how to compile by executing these commands:

autoreconf --install
./configure
make

Also I tried 'make clean' and rebuild from scratch and removed many files manually, with no success.

Any suggestion how to solve this?

Undefined symbols: LibRaw:

Undefined symbols: LibRaw::open_file means "You've forgot to link with libraw library"

The second group of errors means: you've build libraw with JPEG decompression support but forgot to add libjpeg to your linker input.

-- Alex Tutubalin @LibRaw LLC

The makefile for creation and

The makefile for creation and linking did not change. This is how linking of the source code is defined:

$(TARGET_LIB): $(SOURCES) $(OBJS) $(LIBRAW_STATIC_LIB) Makefile
    $(CXX) $(LFLAGS) $(TARGET) $(OBJ_VECTOR) $(OBJ_COMPLEX) $(OBJ_WRAPPER)  $(LIBS)

This actually runs following command to link the collected object files (mixed C/C++) with static library libraw and create a dynamic library as target

    c++ -dynamiclib -o libSomeDynamicLib.jnilib [lot of object files]  -L"../LibRaw/lib/" -lraw

So the process of linking takes place, but the linker complains it cannot find the symbols in the created binary of 'libraw.a' at this stage. As if libraw binaries and the compiled sources from the project created different object binaries on the same machine and architecture (target machine currently is an Intel type MacBook Pro, x86_64), with all *.o files and libraries, or at least they do seem to have different method signatures.

Also I do not understand, why code segments are compiled into libraw, like DNG ore Kodak related stuff, if this is optional.

I tried to apply same compiler binaries and options to compile other projects *.cpp resources, but linking all created binaries against libraw still fails.

Again, I checked LibRaw's collected output of './configure', but cannot get insights why the binaries cannot be linked together:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether sleep supports fractional seconds... yes
checking filesystem timestamp resolution... 2
checking whether build environment is sane... yes
checking for a race-free mkdir -p... mkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking xargs -n works... yes
checking build system type... x86_64-apple-darwin23.6.0
checking host system type... x86_64-apple-darwin23.6.0
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C++... yes
checking whether g++ accepts -g... yes
checking for g++ option to enable C++11 features... -std=gnu++11
checking whether make supports the include directive... yes (GNU style)
checking dependency style of g++ -std=gnu++11... gcc3
checking for gcc... gcc
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786432
checking how to convert x86_64-apple-darwin23.6.0 file names to x86_64-apple-darwin23.6.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin23.6.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for file... file
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ranlib... ranlib
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... ld: warning: -single_module is obsolete
no
checking for -no_fixup_chains linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin23.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for ld used by g++ -std=gnu++11... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking whether the g++ -std=gnu++11 linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking for g++ -std=gnu++11 option to produce PIC... -fno-common -DPIC
checking if g++ -std=gnu++11 PIC flag -fno-common -DPIC works... yes
checking if g++ -std=gnu++11 static flag -static works... no
checking if g++ -std=gnu++11 supports -c -o file.o... yes
checking if g++ -std=gnu++11 supports -c -o file.o... (cached) yes
checking whether the g++ -std=gnu++11 linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin23.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking for OpenMP flag of C compiler... unknown
configure: WARNING: OpenMP support cannot be enabled because your system doesn't support it.
checking for jpeg_mem_src in -ljpeg... yes
checking for jpeglib.h... yes
checking for jas_init in -ljasper... no
configure: WARNING: libjasper not found
checking for pkg-config... /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for zlib... yes
checking for lcms2... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libraw.pc
config.status: creating libraw_r.pc
config.status: executing depfiles commands
config.status: executing libtool commands

This is the (sample) output during compilation of the sources of libraw:

libtool: compile:  g++ -std=gnu++11 -DPACKAGE_NAME=\"LibRaw\" -DPACKAGE_TARNAME=\"libraw\" -DPACKAGE_VERSION=\"0.21.3\" "-DPACKAGE_STRING=\"LibRaw 0.21.3\"" -DPACKAGE_BUGREPORT=\"info@libraw.org\" -DPACKAGE_URL=\"http://www.libraw.org\" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_JPEGLIB_H=1 -I. -DUSE_JPEG -DUSE_JPEG8 -DUSE_ZLIB -I/usr/local/Cellar/little-cms2/2.16/include -DUSE_LCMS2 -g -O2 -MT src/decoders/decoders_libraw.lo -MD -MP -MF src/decoders/.deps/decoders_libraw.Tpo -c src/decoders/decoders_libraw.cpp  -fno-common -DPIC -o src/decoders/.libs/decoders_libraw.o

Sorry, but your huge quotes

Sorry, but your huge quotes don't tell me anything at all, since all this happens within your build system, which I know nothing about.

Two short questions:
1) Do you build LibRaw via make -f Makefile.dist or via ./configure?
2) (in both cases): Does the LibRaw build result in compiled examples or not? (these examples are in ...LibRaw/bin/ folder if you're using provided Makefile.dist. They may be located somewhere else when configure is used)

-- Alex Tutubalin @LibRaw LLC

According to libraw

According to libraw documentation, it has been built like

autoreconf --install
./configure
make install

Library binaries are created and placed in subdirectory 'lib' of the project repository and also placed at location '/usr/local/lib'.

Examples are also created in directory 'bin' of the libraw project repository.

/usr/local/lib/libraw.23.dylib
/usr/local/lib/libraw_r.23.dylib
/usr/local/lib/libraw.a
/usr/local/lib/libraw_r.a
/usr/local/lib/libraw.dylib
/usr/local/lib/libraw_r.dylib
/usr/local/lib/libraw.la
/usr/local/lib/libraw_r.la

Great.

Great.

Please link your binary the same way as LibRaw's examples.

-- Alex Tutubalin @LibRaw LLC

After reverse engineering of

After reverse engineering of 'libtool' and inspecting the output of the build, I found the samples link against the shared library using a deprecated options '-Wl,-bind_at_load'.

ld: warning: -bind_at_load is deprecated on macOS

In my case I need to link my shared library against the static library 'libraw.a' and also avoid additional DLLs must be packed in addition to the dynamic library of libraw.

Could it be configure did something wrong and symbols are no longer exported during build process of libraw?

I still do not understand why the linker complains about undefined symbols of DNG or Kodak parts of the library, that should be incorporated as optional.

  _jpeg_CreateDecompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
  _jpeg_abort_decompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
  _jpeg_destroy_decompress, referenced from:
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::lossy_dng_load_raw() in libraw.a[9](dng.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)
      LibRaw::kodak_jpeg_load_raw() in libraw.a[13](kodak_decoders.o)

I don't think that the task

I don't think that the task of supporting our library is to teach anyone the linking options in their system.

If both the shared and static libraries are in the same directory, which you pass to the linker via the -L option, then it is not surprising that it chooses the shared one from the two possible libraries. Perhaps your linker has an option "choose from two - the static version" but again I don't think that the LibRaw forum is the right place to discuss macOS's ld options.

Other possible solutions (besides of linker option 'prefer static') are to move the static version to a separate directory or, conversely, remove the dynamic one from the directory passed to the linker. Also, configure can only create a static library without a dynamic one (again, I hope that we will not discuss configure options in our forum)

Regarding your second question (which I already answered above): you've build LibRaw with JPEG decompression support, you need to add libjpeg to your application linking input (since you say that the examples build successfully: configure/libtool already do that)

-- Alex Tutubalin @LibRaw LLC

Hi Alex,

Hi Alex,

the difference between a static library and a dynamic(ally linked) library is well known to me. This is not my concern.

I'm trying to understand what is different before and after pulling a new version from github, because from one day to the other our own application can no longer be linked against libraw, but results in errors due to 'undefined symbols', when trying to link against a new build of libraw. This typically occurs, when symbols are not flagged to be exported at compile time, or when the signature of methods in libraries do not match due to different naming conventions.

So I'm trying to understand the problem of 'undefined symbols' from the newly built libraw, esp. a missing main entry point 'LibRaw::open_file', which the linker complains 'undefined symbol' now in the static libraw.

According to your suggestion, I checked the locations where both, dynamic and static verisons of libraw reside after build:

The directory 'lib' in the code repository of libraw is created during the build process of libraw. There is no dynamic library version of libraw created and placed in this directory. In fact, the build process creates another hidden subdirectory, where both the static and dynamic libraries are compiled and linked. These then are placed at different locations during 'make install'.

I also tried to remove the created shared library twin of libraw from the system, with no success. The linker still complains about 'undefined symbols'.

An explicit path is set to this directory via option '-L' pointing to the directory 'lib' of the code repository, when linking our code to the static libraw.a. So the linker typically should not fetch a different version from any different location.

What I do not understand: The way we use libraw didn't change since months, as the Makefile to compile our own wrapper library didn't change, as well.

I checked the status of our work, how it was on the specific developer machine before and after pulling the recent version of libraw, by playing back a full back up of the operating system. Three days ago, before pulling the current work from github, there was such no problem of having undefined symbols when linking against the static version of libraw. Now the same makefile and build process can no longer link against a newer build of libraw.

No clue, what is wrong, except, we pulled a new version of the code repository of libraw from github.

Best,

Thilo

AFAIK, .a file (static

AFAIK, .a file (static library) is just an 'ar' archive of .o (object) files, so 'export/import' is not relevant for such an archive.

-- Alex Tutubalin @LibRaw LLC

I checked the contents of

I checked the contents of libraw.a using nm. In fact, nm did not list any symbols, but errors of missing "dynamic symbol tables". That's why...

nm -D lib/libraw.a
 
libraw_c_api.o:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: error: libraw_c_api.o: File format has no dynamic symbol table
 
libraw_datastream.o:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: error: libraw_datastream.o: File format has no dynamic symbol table
...

So there must be something wrong with the automated configure and build.

I would also be interested to

I would also be interested to know why the examples from the library link successfully (as far as I understood from your answer)

My recommendation to use the SAME options for linking as in the examples remains in force.

-- Alex Tutubalin @LibRaw LLC

Also your previous reply (

Also your previous reply ( https://www.libraw.org/comment/6846#comment-6846 ) lists both .a and .dylib files in /usr/local/lib while you're refering ./lib folder in your last reply.

I recommend removing all library instances from everywhere and starting from scratch to make sure there is ONE instance of the library binary in single preferred format (static one, I think) you are linking to, not several different ones in different folders.

-- Alex Tutubalin @LibRaw LLC

So we are closer to the root

So we are closer to the root cause. Listing all symbols nm and trying to find 'open_file' via grep reports a different signature for class LibRaw 'LibRaw::open_file', than the wrapper library and linker expects.

The linker expected a symbol 'LibRaw::open_file', while the compiled binary of the static library libraw.a has a different signature. Obviously, 'configure' might create confusion about the tools and proper options detected to compile and link the binaries for libraw, which will result in a completely different signature of the C++ class method. I need to see, what the specific root cause for macos will be in this case.

MacBook-Pro:LibRaw user$ nm -a lib/libraw.a | grep open_file
                 U __ZN6LibRaw9open_fileEPKc
0000000000000110 T _libraw_open_file
lib/libraw.a:x3f_parse_process.o: no symbols
lib/libraw.a:x3f_utils_patched.o: no symbols
0000000000000070 T __ZN6LibRaw9open_fileEPKc

The _libraw_open_file is from

The _libraw_open_file is from LibRaw C API
The __ZN6LibRaw9open_fileEPKc is C++ name mangled LibRaw::open_file(char const*), you may use nm with -C option to see the demangled name.

-- Alex Tutubalin @LibRaw LLC