Open lafleurh opened 3 months ago
Hi @lafleurh
Thanks for your feedback.
Building in msys2 environment requires a bit more configuration, and it is a different use case just building in msys2 but using the msvc
compiler, than using the msys2
mingw with msys2 backend (this blog post is about Clang, not MinGW, but it also covers the case: https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html)
In this case it seems you are building for msys2 backend with MinGW. The first important bit is that recipes in ConanCenter are tested and built with msvc
not with MinGW. Even if some users contribute some fixes to support MinGW, support in different platforms might vary, and is not guaranteed. I guess the zlib
package had to be built before, probably you used --build=missing
, but the built was not completely correct. How are you configuring the MinGW compiler? Typically it is necessary to set environment variables like CC/CXX or tools.build:compiler_executables
. Having the full log of the zlib
build from source with MinGW would be useful.
Thanks for the quick response. Yes, the build log looks OK. It is using cc/gcc installed with msys2, which is on the path. Obviously something is missing or can't be found but I don't know enough about it to understand what's going wrong. This is the run after I manually removed it from the cache.
henry.lafleur@XXX UCRT64 /c/source/examples2/tutorial/consuming_packages/simple_cmake_project
$ conan install . --output-folder=build --build=missing
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=13
os=Windows
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=13
os=Windows
======== Computing dependency graph ========
zlib/1.2.11: Not found in local cache, looking in remotes...
zlib/1.2.11: Checking remote: conancenter
zlib/1.2.11: Downloaded recipe revision fca992a7d96a1b92bd956caa8a97d18f
Graph root
conanfile.txt: /c/source/examples2/tutorial/consuming_packages/simple_cmake_project/conanfile.txt
Requirements
zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f - Downloaded (conancenter)
======== Computing necessary packages ========
Requirements
zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:74fce2c720f804facc619f996bab77ff99796c4d - Build
======== Installing packages ========
zlib/1.2.11: Sources downloaded from 'conancenter'
zlib/1.2.11: Calling source() in /home/henry.lafleur/.conan2/p/zlibdb1c5346ffee7/s/src
zlib/1.2.11: Unzipping zlib-1.2.11.tar.gz to /home/henry.lafleur/.conan2/p/zlibdb1c5346ffee7/s/src
-------- Installing package zlib/1.2.11 (1 of 1) --------
zlib/1.2.11: Building from source
zlib/1.2.11: Package zlib/1.2.11:74fce2c720f804facc619f996bab77ff99796c4d
zlib/1.2.11: Copying sources to build folder
zlib/1.2.11: Building your package in /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b
zlib/1.2.11: Calling generate()
zlib/1.2.11: Generators folder: /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release/generators
zlib/1.2.11: CMakeToolchain generated: conan_toolchain.cmake
zlib/1.2.11: CMakeToolchain generated: /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release/generators/CMakePresets.json
zlib/1.2.11: CMakeToolchain generated: /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/src/CMakeUserPresets.json
zlib/1.2.11: Generating aggregated env files
zlib/1.2.11: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
zlib/1.2.11: Calling build()
zlib/1.2.11: Apply patch (conan): separate static/shared builds, disable debug suffix, disable building examples
zlib/1.2.11: Apply patch (portability): fix condition for WIDECHAR usage
zlib/1.2.11: Running CMake.configure()
zlib/1.2.11: RUN: cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/src"
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Using Conan toolchain: C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The C compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/ucrt64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Renaming
-- C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/src/zconf.h
-- to 'zconf.h.included' because this file is included with zlib
-- but CMake generates it automatically in the build directory.
-- Configuring done (4.6s)
-- Generating done (0.0s)
-- Build files have been written to: C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release
zlib/1.2.11: Running CMake.build()
zlib/1.2.11: RUN: cmake --build "/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release" -- -j16
[ 6%] Building C object CMakeFiles/zlib.dir/adler32.c.obj
[ 12%] Building C object CMakeFiles/zlib.dir/compress.c.obj
[[ [ 31%] 31Building C object CMakeFiles/zlib.dir/crc32.c.obj%] 31%]
[Building C object CMakeFiles/zlib.dir/gzlib.c.obj 37%]Building C object CMakeFiles/zlib.dir/deflate.c.obj
Building C object CMakeFiles/zlib.dir/gzclose.c.obj
[ 50%[] 50%] Building C object CMakeFiles/zlib.dir/gzwrite.c.obj
Building C object CMakeFiles/zlib.dir/gzread.c.obj
[ 56%] Building C object CMakeFiles/zlib.dir/inflate.c.obj
[ 62%] Building C object CMakeFiles/zlib.dir/infback.c.obj
[ 68%] Building C object CMakeFiles/zlib.dir/inftrees.c.obj
[ 75%] Building C object CMakeFiles/zlib.dir/inffast.c.obj
[ 81%] Building C object CMakeFiles/zlib.dir/trees.c.obj
[[ 93%] Building C object CMakeFiles/zlib.dir/uncompr.c.obj8
7%] Building C object CMakeFiles/zlib.dir/zutil.c.obj
[100%] Linking C static library libz.a
[100%] Built target zlib
zlib/1.2.11: Package '74fce2c720f804facc619f996bab77ff99796c4d' built
zlib/1.2.11: Build folder /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release
zlib/1.2.11: Generating the package
zlib/1.2.11: Packaging in folder /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p
zlib/1.2.11: Calling package()
zlib/1.2.11: Running CMake.install()
zlib/1.2.11: RUN: cmake --install "/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/b/build/Release" --prefix "/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p"
-- Install configuration: "Release"
-- Installing: C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p/lib/libz.a
-- Installing: C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p/include/zconf.h
-- Installing: C:/msys64/home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p/include/zlib.h
zlib/1.2.11: package(): Packaged 2 '.h' files: zconf.h, zlib.h
zlib/1.2.11: package(): Packaged 1 '.a' file: libz.a
zlib/1.2.11: package(): Packaged 1 file: LICENSE
zlib/1.2.11: Created package revision ec6792d17f371577ee2e119f9972f68f
zlib/1.2.11: Package '74fce2c720f804facc619f996bab77ff99796c4d' created
zlib/1.2.11: Full package reference: zlib/1.2.11#fca992a7d96a1b92bd956caa8a97d18f:74fce2c720f804facc619f996bab77ff99796c4d#ec6792d17f371577ee2e119f9972f68f
zlib/1.2.11: Package folder /home/henry.lafleur/.conan2/p/b/zlibcafbde88a495f/p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated: 'cpp_info.names' used in: zlib/1.2.11
======== Finalizing install (deploy, generators) ========
conanfile.txt: Writing generators to /c/source/examples2/tutorial/consuming_packages/simple_cmake_project/build
conanfile.txt: Generator 'CMakeDeps' calling 'generate()'
conanfile.txt: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(ZLIB)
target_link_libraries(... ZLIB::ZLIB)
conanfile.txt: Generator 'CMakeToolchain' calling 'generate()'
conanfile.txt: CMakeToolchain generated: conan_toolchain.cmake
conanfile.txt: CMakeToolchain: Preset 'conan-release' added to CMakePresets.json.
(cmake>=3.23) cmake --preset conan-release
(cmake<3.23) cmake <path> -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release
conanfile.txt: CMakeToolchain generated: /c/source/examples2/tutorial/consuming_packages/simple_cmake_project/build/CMakePresets.json
conanfile.txt: CMakeToolchain generated: /c/source/examples2/tutorial/consuming_packages/simple_cmake_project/CMakeUserPresets.json
conanfile.txt: Generating aggregated env files
conanfile.txt: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully
Here's the info on cc:
henry.lafleur@XXX UCRT64 /c/source/examples2/tutorial/consuming_packages/simple_cmake_project
$ /c/msys64/ucrt64/bin/cc.exe --version
cc.exe (Rev3, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Thanks for the article. Based on this, I think we will switch to msvc on Windows rather than fight the uphill battle and risk compatibility issues with consuming the dll with msvc later.
I am not sure what could be failing, I have tried the following and it seems to work here:
mingw
as:
[settings]
os=Windows
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.exception=seh
arch=x86_64
build_type=Release
[tool_requires] mingw-builds/12.2.0
- ``$ conan install . -of=build --build=missing -pr=mingw``
- ``$ build/conanbuild.bat``
- ``$ cmake --preset conan-release``
- ``$ cmake --build --preset conan-release``
I am using mingw as a ``tool_requires`` to simplify things for me, but it would be equivalent running with a system installed mingw (it might need to add some configuration to the profile, like ``[buildenv]``). Several notes:
- Note that I am not running inside the ``msys2/mingw`` terminal, I am running from a regular terminal
- The activation of the ``build/conanbuild.bat`` script is necessary in my case, because the ``mingw-builds/12.2.0`` tool-require is defining some environment variables that might be needed for the local build with the following ``cmake`` commands.
- In theory it should be more correct to also set the ``os.subsystem`` setting, and ucrt64 is not listed there yet, but it could be added in ``settings_user.yml``. It will only affect the ``package_id`` as it would allow to build different binaries without overlap for the different subsystems.
- I haven't tried with a real ``ucrt64`` but I believe it should work the same.
> Based on this, I think we will switch to msvc on Windows rather than fight the uphill battle and risk compatibility issues with consuming the dll with msvc later.
I think this is recommended, yes. Specially recalling my comment above that some recipes in ConanCenter might have different support for mingw, in general the support for ``msvc`` in ConanCenter would be orders of magnitude better.
Regarding this ticket, as you wish, feel free to close it if not really interested in investigating what would be the issue, or leave it open and keep having a look. Don't hesitate to create new tickets for any other further question that you might have. Thanks for the feedback!
I'm trying to run the example app, https://docs.conan.io/2/tutorial/consuming_packages/build_simple_cmake_project.html, with the Windows MSYS2 UCRT64 environment, and I get to the cmake step and get an error message. Everything works up until this step. The only thing I did differently was install cmake with pacman using the ucrt_x86_64 package and changed the OS in the default profile to Windows.
This is what I get:
UCRT64 /c/source/examples2/tutorial/consuming_packages/simple_cmake_project $ cmake.exe .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -- Using Conan toolchain: C:/source/examples2/tutorial/consuming_packages/simple_cmake_project/build/conan_toolchain.cmake -- Conan toolchain: Defining architecture flag: -m64 -- Conan toolchain: C++ Standard 17 with extensions ON -- Conan: Target declared 'ZLIB::ZLIB' CMake Error at build/cmakedeps_macros.cmake:67 (message): Library 'z' not found in package. If 'z' is a system library, declare it with 'cpp_info.system_libs' property Call Stack (most recent call first): build/ZLIB-Target-release.cmake:23 (conan_package_library_targets) build/ZLIBTargets.cmake:24 (include) build/ZLIBConfig.cmake:16 (include) CMakeLists.txt:4 (find_package)
-- Configuring incomplete, errors occurred!
Here is my conan default profile
[settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=13 os=Windows
(for some reason, I have to use cmake.exe instead of cmake)