/usr/lib/libgdal.a cannot be linked into any program

Bug #1956840 reported by Michael Salib
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gdal (Ubuntu)
New
Undecided
Unassigned

Bug Description

libgdal-dev includes a static library at /usr/lib/libgdal.a. But this
library is broken: there is no configuration which allows you to
actually link a program against it. Therefore, it should be
removed. Right now, it only serves to waste people's time as they try
to statically link against a broken library.

Here's a small testcase. Consider broken.c:

#include <stdio.h>
#include <gdal.h>

int main(int argc, char *argv[]) {
    printf("%s\n", GDALVersionInfo("RELEASE_NAME"));
    return(0);
}

This is the simplest C program that can link against libgdal. You can
build and run it easily:

gcc -o broken broken.c `gdal-config --cflags` `gdal-config --libs`
./broken

which happily prints 3.2.2. That program is fine! But note that it is
dynamically linked:

ldd ./broken|wc -l

indicates that it is linked against 116 shared object libraries.

What if we want to statically link against libgdal.a? We proceed as
before, but this time we add the output of `gdal-config --dep-libs` to
include the static library dependencies

gcc -o broken broken.c `gdal-config --cflags` -Wl,-Bstatic `gdal-config --libs` `gdal-config --dep-libs`

And now we get this error message:

/usr/bin/ld: cannot find -lheif
/usr/bin/ld: cannot find -larmadillo
/usr/bin/ld: cannot find -lpoppler
/usr/bin/ld: cannot find -lqhull
/usr/bin/ld: cannot find -lkmlbase
/usr/bin/ld: cannot find -lkmldom
/usr/bin/ld: cannot find -lkmlengine
/usr/bin/ld: cannot find -lkmlxsd
/usr/bin/ld: cannot find -lkmlregionator
/usr/bin/ld: cannot find -lopenjp2
/usr/bin/ld: cannot find -lnetcdf
/usr/bin/ld: cannot find -logdi
/usr/bin/ld: cannot find -lcharls
collect2: error: ld returned 1 exit status

This actually makes sense: in the GDAL build process, the static and
shared libraries are built together from the exact same
configuration. They have the same dependencies. But that very large
dependency set includes a bunch of libraries for which no static
library is available. There is no libarmadillo.a or libpoppler.a
available in any package of the distribution for example. So there's
no way you could ever statically link against libgdal.a which depends
on those libraries.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.