Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gdal builds, but no instructions for how to link it are given #8377

Closed
lakinwecker opened this issue Sep 27, 2019 · 10 comments
Closed

Gdal builds, but no instructions for how to link it are given #8377

lakinwecker opened this issue Sep 27, 2019 · 10 comments
Assignees
Labels
category:question This issue is a question

Comments

@lakinwecker
Copy link
Contributor

GDAL builds, but no instructions on how to link are provided
When you build gdal on linux (or windows) you are not given any further instructions on how to use it or link with it. Considering that gdal links with quite a few different libraries, it's difficult to know which ones to link with and how. Some of them are static libraries inside of the vcpkg installed directory.

Considering that I need to build this and link against this library on both windows and linux in the upcoming weeks, I'd be happy to work on this. I'm not really sure where to start though. gdal isn't CMake based, but it does seem to provide some amount of pkg-config information. What is the usual process for ports that are not cmake based?

Environment

  • OS: Linux
  • Compiler: g++/clang

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install gdal
  2. See lack of build instructions

Expected behavior
A clear and concise description of how to link with gdal.

Failure logs

➜ ./vcpkg install gdal
Warning: Different source is available for vcpkg (2019.8.27 -> 2019.6.26). Use .\bootstrap-vcpkg.bat to update.
The following packages will be built and installed:
    gdal[core]:x64-linux
  * sqlite3[core]:x64-linux
Additional packages (*) will be modified to complete this operation.
Starting package 1/2: sqlite3:x64-linux
Building package sqlite3[core]:x64-linux...
-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3280000.zip...
-- Extracting source /home/lakin/software/vcpkg/downloads/sqlite-amalgamation-3280000.zip
-- Using source at /home/lakin/software/vcpkg/buildtrees/sqlite3/src/3280000-19670be87f
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package sqlite3[core]:x64-linux... done
Installing package sqlite3[core]:x64-linux...
Installing package sqlite3[core]:x64-linux... done
Elapsed time for package sqlite3:x64-linux: 40.37 s
Starting package 2/2: gdal:x64-linux
Building package gdal[core]:x64-linux...
Warning: abi keys are missing values:
    libwebp
    libxml2

-- Using cached /home/lakin/software/vcpkg/downloads/gdal241.zip
-- Extracting source /home/lakin/software/vcpkg/downloads/gdal241.zip
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0001-Fix-debug-crt-flags.patch
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0002-Fix-static-build.patch
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0003-Fix-std-fabs.patch
-- Extracting source /home/lakin/software/vcpkg/downloads/gdal241.zip
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0001-Fix-debug-crt-flags.patch
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0002-Fix-static-build.patch
-- Applying patch /home/lakin/software/vcpkg/ports/gdal/0003-Fix-std-fabs.patch
-- Configuring x64-linux-rel
-- Building x64-linux-rel
-- Installing x64-linux-rel
-- Installing x64-linux-rel done
-- Configuring x64-linux-dbg
-- Building x64-linux-dbg
-- Installing x64-linux-dbg
-- Installing x64-linux-dbg done
-- Performing post-build validation
-- Performing post-build validation done
Building package gdal[core]:x64-linux... done
Installing package gdal[core]:x64-linux...
Installing package gdal[core]:x64-linux... done
Elapsed time for package gdal:x64-linux: 1.111 h

Total elapsed time: 1.122 h

Additional context
None.

@vicroms
Copy link
Member

vicroms commented Sep 27, 2019

Hi @lakinwecker

There's a FindGDAL module shipped with CMake, which will define target GDAL::GDAL.

find_package(GDAL REQUIRED)
target_link_libraries(mytarget PRIVATE GDAL::GDAL)

@lakinwecker
Copy link
Contributor Author

Thanks for that. Should this package print that out at the end of the installation process?

I'm still running in to some linking issues after including the above, but I will file those as a separate issue once I have confirmed it's not something wrong with my environment.

@lakinwecker
Copy link
Contributor Author

lakinwecker commented Sep 29, 2019

In addition, in order to get this to link, I have to add:

find_package(OpenSSL REQUIRED)
set(LIBRARIES ${LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)

Without this, I get:

/usr/bin/ld: /home/lakin/software/vcpkg/installed/x64-linux/lib/libcurl.a(openssl.c.o): undefined reference to symbol 'ASN1_TIME_print@@OPENSSL_1_1_0'
/usr/bin/ld: /usr/lib/libcrypto.so.1.1: error adding symbols: DSO missing from command line
```

Because it tries to link to my local crypto library.

@cbezault
Copy link
Contributor

Are you using the most recent version of our curl port? I could have sworn I fixed that issue...

@lakinwecker
Copy link
Contributor Author

AFAIK, I am. I pulled from master today and updated everything. Is there some output I can provide to prove it?

@cbezault
Copy link
Contributor

No I believe you. It just means I missed something.

@lakinwecker
Copy link
Contributor Author

Well, I'm happy to test stuff. Feel free to ping me if you want me to test out any PRs, etc.

@am2222
Copy link
Contributor

am2222 commented Oct 13, 2019

@lakinwecker How I can find GDAL_INCLUDE_DIRS and GDAL_LIBRARIES variables without using FindGDAL module in CMAKE? I want to manually link this library to my build command line

@PhoebeHui PhoebeHui added the category:question This issue is a question label Apr 1, 2021
@PhoebeHui
Copy link
Contributor

Currently the usage file was provided for gdal, you can use it as following.

The package GDAL provides CMake targets:

    find_package(GDAL REQUIRED)
    target_include_directories(main PRIVATE ${GDAL_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${GDAL_LIBRARIES})

@dg0yt
Copy link
Contributor

dg0yt commented May 26, 2021

For Linux, gdal is completely broken, #9068. I'm working on it, but there is no point in relying on pkgconfig or cmake files as long as there is no control about dependencies from the system used when building port gdal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

7 participants