Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Can we ask VCPKG to build cmake instead of downloading it? #4501

Closed
pmoulon opened this issue Oct 18, 2018 · 10 comments
Closed

Can we ask VCPKG to build cmake instead of downloading it? #4501

pmoulon opened this issue Oct 18, 2018 · 10 comments
Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed

Comments

@pmoulon
Copy link

pmoulon commented Oct 18, 2018

I'm trying to run VCPKG under an alpine docker image.
I got error like

Error relocating /vcpkg/downloads/tools/cmake-3.11.4-linux/cmake-3.11.4-Linux-x86_64/bin/cmake: gnu_dev_minor: symbol not found
...
unsupported relocation type 6
unsupported relocation type 5

In order to avoid to use the default download location, I would like to tell VCPKG to just build cmake and use it. Can we do that?

@pmoulon pmoulon changed the title Can we ask VCPKG to build cmake instead off downloaded it? Can we ask VCPKG to build cmake instead of downloading it? Oct 18, 2018
@pmoulon
Copy link
Author

pmoulon commented Dec 5, 2018

Any answer from the community?
@alexkaratarakis
@ras0219-msft

@NancyLi1013 NancyLi1013 added the category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed label Jan 23, 2019
@0ca
Copy link

0ca commented Apr 16, 2019

Any update on this? Another option is to download a cmake statically compiled.

@0ca
Copy link

0ca commented Apr 16, 2019

I compiled cmake from source code on alpine:

wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz
tar xf cmake-3.14.0.tar.gz
cd cmake-3.14.0/
./configure --prefix=cmake-3.14.0-Linux-x86_64/
make
make install

And replaced that folder by the one downloaded by vcpkg, I also installed libc6-compat for the ninja binary to work:

apk add libc6-compat

And then vcpkg compiles!

The problem now it's that when I run it I get this:

./vcpkg install sqlite3
Error: invalid triplet: x64-linux-musl
Available architecture triplets:
  arm-uwp
  arm-windows
  arm64-uwp
  arm64-windows
  x64-linux
  x64-osx
  x64-uwp
  x64-windows
  x64-windows-static
  x86-uwp
  x86-windows
  x86-windows-static

I tried ./vcpkg install sqlite3 --triplet x64-linux but then I got errors downloading the source code, and that doesn't make sense:

-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3270200.zip... Failed. Status: 1;"Unsupported protocol"
CMake Error at scripts/cmake/vcpkg_download_distfile.cmake:172 (message):

      Failed to download file.
      If you use a proxy, please set the HTTPS_PROXY and HTTP_PROXY environment
      variables to "https://user:password@your-proxy-ip-address:port/".
      Otherwise, please submit an issue at https://github.com/Microsoft/vcpkg/issues

Call Stack (most recent call first):
  ports/sqlite3/portfile.cmake:6 (vcpkg_download_distfile)
  scripts/ports.cmake:71 (include)


Error: Building package sqlite3:x64-linux failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: sqlite3:x64-linux
  Vcpkg version: 2018.11.23-unknownhash

Maybe it's because some errors with libc6-compat?

@pmoulon
Copy link
Author

pmoulon commented Apr 16, 2019

Thank you for having run the experiment.
I think he would be better to let VCPKG to simply download CMAKE source and build it as an option.
This way, depending on the platform, GCC would be a requirement for Linux and VCPKG could be used on more distrib...

It is also sad to do not have any feedback from the VCPKG team (@grdowns)...

@0ca
Copy link

0ca commented Apr 17, 2019

What I would do it's to generate a statically linked cmake instead of downloading the release version from here:
https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0-Darwin-x86_64.tar.gz

Btw the error happened because I compiled cmake without openssl, I modify the compilation to use curl for the cmake downloads (I couldn't figure out how to add the openssl support to cmake).

So the steps are the following:

# Necessary for the ninja compiled binary
apk add libc6-compat
# We compiled cmake from source
cd ~
wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz
tar xf cmake-3.14.0.tar.gz
cd cmake-3.14.0/
apk add openssl-dev
apk add zlib-dev
apk add curl-dev
./configure --prefix=cmake-3.14.0-Linux-x86_64/ --system-curl
make
make install
# We replaced the download cmake binary with ours
cp -r ~/cmake-3.14.0/cmake-3.14.0-Linux-x86_64 /vcpkg/downloads/tools/cmake-3.14.0-linux/

And then you can compile a library (specifying the arch x64-linux):

/vcpkg # ./vcpkg install sqlite3 --triplet x64-linux
The following packages will be built and installed:
    sqlite3[core]:x64-linux
Starting package 1/1: sqlite3:x64-linux
Building package sqlite3[core]:x64-linux...
-- Downloading https://sqlite.org/2019/sqlite-amalgamation-3270200.zip...
-- Extracting source /vcpkg/downloads/sqlite-amalgamation-3270200.zip
-- Using source at /vcpkg/buildtrees/sqlite3/src/3270200-2078ef6d88
-- 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: 44.9 s

Total elapsed time: 44.9 s

The package sqlite3:x64-linux provides CMake targets:

    find_package(sqlite3 CONFIG REQUIRED)
    target_link_libraries(main PRIVATE sqlite3)

@pmoulon
Copy link
Author

pmoulon commented Apr 17, 2019

Thank you @0ca for the demo. Appreciated.
Would it be better if VCPKG would provide this natively, so either distribution you have you would be able to use a build CMake rather a pre-built version?

@0ca
Copy link

0ca commented Apr 17, 2019

Building cmake from source takes some time (iirc around 5 mins).

In theory with alpine and musl you can build a static binary that can run in any linux with the same architecture. But yeah, if you want also to support different architectures the way to go is to compile cmake from source code.

I wonder why vcpkg decided to used precompiled binaries instead of installing dependencies with a package manager like apt. It would need first to identify what package manager is available but after that the installation would be very straightforward.

@illera88
Copy link
Contributor

illera88 commented Jul 2, 2019

Hi there,

I found a way to make it work. It's not documented and I had to find it checking on the source code but it works like a charm and it's simple and "officially supported":

apk add libc6-compat cmake ninja
./bootstrap-vcpkg.sh --useSystemBinaries
VCPKG_FORCE_SYSTEM_BINARIES=1 ./vcpkg install sqlite3 --triplet x64-linux

You can export VCPKG_FORCE_SYSTEM_BINARIES to the environment variables so you don't have to prepend it all the time.

I think this will be enough to close the issue.

Hope that helps

Cheers

@pmoulon
Copy link
Author

pmoulon commented Jul 3, 2019

Thanks, that's great. So we need first to setup cmake and then use the hidden option. Am I right?

@illera88
Copy link
Contributor

illera88 commented Jul 3, 2019 via email

@LilyWangL LilyWangL reopened this Jul 26, 2019
@microsoft microsoft locked and limited conversation to collaborators May 7, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
category:vcpkg-feature The issue is a new capability of the tool that doesn’t already exist and we haven’t committed
Projects
None yet
Development

No branches or pull requests

6 participants