Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Broken libtoolize #215

Closed
Algunenano opened this issue Apr 14, 2020 · 6 comments
Closed

Broken libtoolize #215

Algunenano opened this issue Apr 14, 2020 · 6 comments

Comments

@Algunenano
Copy link

Algunenano commented Apr 14, 2020

After #207, the Postgis build is broken because it's failing to find 'lib/libSFCGAL.la' which doesn't exist.

If we check libSFCGAL.la we see this:

# cat /usr/local/lib/libSFCGAL.la
# /src/SFCGAL/cmake-build/libSFCGAL.la - a libtool library file
# Generated by CMake 3.16.3 (like GNU libtool)

# Please DO NOT delete this file!
# It is necessary for linking the library with libtool.

# The name that we can dlopen(3).
dlname='libSFCGAL.so'

# Names of this library.
library_names='libSFCGAL.so.0.0.0 libSFCGAL.so.0 libSFCGAL.so'

# The name of the static archive.
old_library=''

# Libraries that this one depends upon.
dependency_libs=''

# Names of additional weak libraries provided by this library
weak_library_names=

# Version information for /src/SFCGAL/cmake-build/libSFCGAL.la.
current=0
age=0
revision=0

# Is this an already installed library?
installed=yes

# Should we warn about portability when linking against -modules?
shouldnotlink=yes

# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''

# Directory that this library needs to be installed in:
libdir='lib'

Notice the libdir='lib' which is incorrect.

Then when GDAL links against this it gets:

# Libraries that this one depends upon.
dependency_libs=' -ljson-c -L/usr/local/lib lib/libSFCGAL.la /usr/lib/x86_64-linux-gnu/libsqlite3.la -ljpeg /usr/local/lib/libproj.la /usr/lib/x86_64-linux-gnu/libsqlite3.la -ltiff /usr/lib/x86_64-linux-gnu/libcurl.la -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'

Here we can see it's linking to lib/libSFCGAL.la.

This ends up in Postgis build where it fails:

/bin/bash ../../libtool --mode=link gcc -std=gnu99 -g -O2 -mtune=generic -fno-omit-frame-pointer -Werror -Wall -Wextra -Wformat -Werror=format-security -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-unknown-warning-option -Wno-cast-function-type -fno-math-errno -fno-signed-zeros  -fPIC -DPIC -I../rt_core -I../../liblwgeom -I/usr/local/include -I/usr/local/include -I/usr/local/include   -I/usr/local/include ../rt_core/librtcore.a raster2pgsql.o -Wl,-Bsymbolic-functions -Wl,-z,relro -lm -L/usr/local/lib -lgdal  -L/usr/local/lib -lgeos_c  -lc -static ../../liblwgeom/liblwgeom.la  -o raster2pgsql
libtool:   error: cannot find the library 'lib/libSFCGAL.la' or unhandled argument 'lib/libSFCGAL.la'
make[2]: *** [Makefile:91: raster2pgsql] Error 1
make[2]: Leaving directory '/src/postgis/raster/loader'

Editing the resulting libgdal.la to use /usr/local/lib/libSFCGAL.la instead fixes it, but I don't know where that comes from.

My knowledge about cmake is limited, but shouldn't this use CMAKE_INSTALL_FULL_LIBDIR instead?

Changing the following:

diff --git a/cmake/Modules/Libtoolize.cmake b/cmake/Modules/Libtoolize.cmake
index 52bb160..1a3f796 100644
--- a/cmake/Modules/Libtoolize.cmake
+++ b/cmake/Modules/Libtoolize.cmake
@@ -1,3 +1,5 @@
+include(GNUInstallDirs)
+
 MACRO(GET_TARGET_PROPERTY_WITH_DEFAULT _variable _target _property _default_value)
    GET_TARGET_PROPERTY (${_variable} ${_target} ${_property})
    IF (${_variable} MATCHES NOTFOUND)
@@ -44,6 +46,6 @@ MACRO(CREATE_LIBTOOL_FILE _target)
    FILE(APPEND ${_laname} "dlopen='${_target_dlopen}'\n")
    FILE(APPEND ${_laname} "dlpreopen='${_target_dlpreopen}'\n\n")
    FILE(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
-   FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_LIBDIR}'\n")
-   INSTALL( FILES ${_laname} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+   FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_FULL_LIBDIR}'\n")
+   INSTALL( FILES ${_laname} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 ENDMACRO(CREATE_LIBTOOL_FILE)

Seems to solve the issue for me.

@lbartoletti
Copy link
Contributor

@Algunenano @mhugo
I need to modernize this file to address this issue #185 as well.

But I wonder if it's really necessary. Is the control file really useful on your distribution? sfcgal-config should do the job.

@Algunenano
Copy link
Author

The problem in this case comes from the transitive dependency:

  • Postgis -> sfcgal works fine, as it uses sfcgal-config
  • Postgis -> gdal -> sfcgal fails, as it uses the available libtool file. I think this would be ok if the file doesn't exists (in my work pc I don't have any issues since I don't install libtool files or static libraries).

@lbartoletti
Copy link
Contributor

Postgis -> gdal (with sfcgal option enabled?) -> sfcgal

I think it's not a problem if we remove this file. I'll try on my machine too.

@lbartoletti
Copy link
Contributor

On FreeBSD I don't use this file.

@Algunenano
Copy link
Author

Postgis -> gdal (with sfcgal option enabled?) -> sfcgal

Yes, the issue only happens when gdal was compiled with sfcgal enabled.

lbartoletti added a commit to lbartoletti/SFCGAL that referenced this issue Apr 22, 2020
@mhugo mhugo closed this as completed in a9dd7e5 Apr 24, 2020
@Algunenano
Copy link
Author

I confirm that the Postgis build was fixed by #223.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants