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

CMake <3.12 fails on Windows with 'Object library target "libcurl_object" may not link to anything.' error #16375

Closed
markp-iot opened this issue Feb 17, 2025 · 5 comments
Assignees
Labels

Comments

@markp-iot
Copy link

markp-iot commented Feb 17, 2025

I did this

With the deprecation of winbuild I'm trying to build on Windows using cmake.
I'm using a back level VS 2017 :

** Visual Studio 2017 Developer Command Prompt v15.6.4
** Copyright (c) 2017 Microsoft Corporation

which includes cmake 3.10, and I'm hitting an error :

CMake Error at lib/CMakeLists.txt:110 (target_link_libraries):
  Object library target "libcurl_object" may not link to anything.

This fails for CMake 3.10.3, and 3.11.4, but it works for CMake 3.12.0 and later.

I am running commands:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" x86
mkdir ..\curl-build
cd ..\curl-build
cmake  -A Win32 -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DENABLE_IPV6=ON -DCURL_WINDOWS_SSPI=NO -DCURL_USE_LIBSSH2=OFF -DUSE_NGHTTP2=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_ZLIB=OFF ..\curl-8.12.1

But this also fails for a 64 bit make (omitting the -A Win32).

The output from a failing (3.11.4) cmake command is :

-- Building for: Visual Studio 15 2017
-- Using CMake version 3.11.4
-- curl version=[8.12.1]
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.16.27053.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- CMake platform flags: WIN32 MSVC-1916
-- Performing Test HAVE_WIN32_WINNT
-- Performing Test HAVE_WIN32_WINNT - Success
-- Found _WIN32_WINNT=0x0a00
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Could NOT find Brotli (missing: BROTLI_INCLUDE_DIR BROTLIDEC_LIBRARY BROTLICOMMON_LIBRARY)
-- Could NOT find Zstd (missing: ZSTD_INCLUDE_DIR ZSTD_LIBRARY)
-- Check size of size_t
-- Check size of size_t - done
-- Check size of ssize_t
-- Check size of ssize_t - failed
-- Check size of long long
-- Check size of long long - done
-- Check size of long
-- Check size of long - done
-- Check size of int
-- Check size of int - done
-- Check size of __int64
-- Check size of __int64 - done
-- Check size of time_t
-- Check size of time_t - done
-- Check size of ADDRESS_FAMILY
-- Check size of ADDRESS_FAMILY - done
-- Check size of off_t
-- Check size of off_t - done
-- Check size of curl_off_t
-- Check size of curl_off_t - done
-- Check size of curl_socket_t
-- Check size of curl_socket_t - done
CMake Error at lib/CMakeLists.txt:110 (target_link_libraries):
  Object library target "libcurl_object" may not link to anything.


-- Configuring incomplete, errors occurred!
See also "C:/Users/Administrator/broot/curl-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Administrator/broot/curl-build/CMakeFiles/CMakeError.log".

The error files are attached.

The output from a successful (3.12.0) cmake command is :

-- Building for: Visual Studio 15 2017
-- Using CMake version 3.12.0
-- curl version=[8.12.1]
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.16.27053.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMake platform flags: WIN32 MSVC-1916
-- Performing Test HAVE_WIN32_WINNT
-- Performing Test HAVE_WIN32_WINNT - Success
-- Found _WIN32_WINNT=0x0a00
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Could NOT find Brotli (missing: BROTLI_INCLUDE_DIR BROTLIDEC_LIBRARY BROTLICOMMON_LIBRARY)
-- Could NOT find Zstd (missing: ZSTD_INCLUDE_DIR ZSTD_LIBRARY)
-- Check size of size_t
-- Check size of size_t - done
-- Check size of ssize_t
-- Check size of ssize_t - failed
-- Check size of long long
-- Check size of long long - done
-- Check size of long
-- Check size of long - done
-- Check size of int
-- Check size of int - done
-- Check size of __int64
-- Check size of __int64 - done
-- Check size of time_t
-- Check size of time_t - done
-- Check size of ADDRESS_FAMILY
-- Check size of ADDRESS_FAMILY - done
-- Check size of off_t
-- Check size of off_t - done
-- Check size of curl_off_t
-- Check size of curl_off_t - done
-- Check size of curl_socket_t
-- Check size of curl_socket_t - done
-- Protocols: dict file ftp gopher http imap ipfs ipns ldap ldaps mqtt pop3 rtsp smb smtp telnet tftp ws
-- Features: AsynchDNS IPv6 Largefile NTLM UnixSockets alt-svc threadsafe
-- Enabled SSL backends:
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Administrator/broot/curl-build

CMakeOutput.log
CMakeError.log

I expected the following

CMakeLists.txt says

make_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)

...so I expected CMake to succeed on CMake 3.10 and 3.11

Is target_link_libraries() depending on a feature which is only available in CMake 3.12 and later?

curl/libcurl version

curl 8.12.1

operating system

Windows 10 Professional
** Visual Studio 2017 Developer Command Prompt v15.6.4
CMake < 3.12

@vszakats
Copy link
Member

vszakats commented Feb 18, 2025

Thanks for you report and finding the cutoff CMake version.

The oldest CI tested with Windows is 3.16.2. For Linux it's 3.7.
Windows builds have the SHARE_LIB_OBJECT feature enabled by default.
CMake complains about the interim target needed for this feature. It seems 3.12
added support for Object Libraries.
This information is missing from the documentation, and only visible in the
release notes: https://cmake.org/cmake/help/latest/release/3.12.html.

Does -DSHARE_LIB_OBJECT=OFF fix the issue for you?

@vszakats vszakats added the cmake label Feb 18, 2025
vszakats added a commit to vszakats/curl that referenced this issue Feb 18, 2025
This feature requires Object Libraries which is supported by CMake 3.12
and newer: https://cmake.org/cmake/help/latest/release/3.12.html

Ignore this option for older CMake versions.

Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries

Reported-by: markp-iot on Github
Fixes curl#16375
vszakats added a commit to vszakats/curl that referenced this issue Feb 18, 2025
This feature requires Object Libraries which is supported by CMake 3.12
and newer: https://cmake.org/cmake/help/latest/release/3.12.html

Ignore this option for older CMake versions.

Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries

Reported-by: markp-iot on Github
Fixes curl#16375
vszakats added a commit to vszakats/curl that referenced this issue Feb 18, 2025
This feature requires Object Libraries which is supported by CMake 3.12
and newer: https://cmake.org/cmake/help/latest/release/3.12.html

Ignore this option for older CMake versions.

Ref: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#object-libraries

Reported-by: markp-iot on Github
Fixes curl#16375
@vszakats vszakats self-assigned this Feb 18, 2025
@mark-phillips-ibm
Copy link

mark-phillips-ibm commented Feb 18, 2025

Viktor, many thanks for the quick response. I tried -DSHARE_LIB_OBJECT=OFF and that does allow CMake to complete successfully :

-- Building for: Visual Studio 15 2017
-- Using CMake version 3.12.18081601-MSVC_2
-- curl version=[8.12.1]
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19045.
    . . .
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Administrator/broot/curl-build

I also checked out your changes and re-ran with the same old version of CMake but without -DSHARE_LIB_OBJECT=OFF, and that worked too, so the new defaults look good.

Thanks again for your help in resolving this.

@vszakats
Copy link
Member

@mark-phillips-ibm Thanks for your tests and feedback! I'm glad it works. Do you have a preference which user ID (or name) to include for you in the Reported-by: line?

@mark-phillips-ibm
Copy link

HI Viktor, you're welcome - I don't really mind - either id or just my name - Mark Phillips is fine. Thanks again!

@vszakats
Copy link
Member

Thanks Mark, the fix is merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants