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

x64-debug has link error, x64-Release build success #143

Open
huiseliming opened this issue Aug 7, 2020 · 13 comments
Open

x64-debug has link error, x64-Release build success #143

huiseliming opened this issue Aug 7, 2020 · 13 comments
Assignees
Milestone

Comments

@huiseliming
Copy link

In Windows using CMake

F:\vcpkg>vcpkg version
skyr-url install by vcpkg
Vcpkg package management program version 2020.02.04-nohash

See LICENSE.txt for license information.

windows\debug\lib\libcrypto.lib F:\vcpkg\installed\x64-windows\debug\lib\fmtd.lib F:\vcpkg\installed\x64-windows\lib\skyr-url.lib F:\vcpkg\installed\x64-windows\debug\lib\gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:tests\CMakeFiles\tests.dir/intermediate.manifest tests\CMakeFiles\tests.dir/manifest.res" failed (exit code 1319) with the following output:
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url_search_parameters.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url_search_parameters.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(ipv4_address.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(ipv4_address.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(ipv6_address.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(ipv6_address.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(domain.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(domain.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(parse.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(parse.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(punycode.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(punycode.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(idna.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(idna.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url_parser_context.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(url_parser_context.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(host.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\skyr-url.lib(host.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in GreyDawnNetworkTest.cpp.obj
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
G:\GreyDawnModule\GreyDawnNetwork\out\build\x64-Debug\bin\tests.exe : fatal error LNK1319: 20 mismatches detected
ninja: build stopped: subcommand failed.

Build All failed.

@github-actions
Copy link

github-actions bot commented Aug 7, 2020

Thanks for using the library and creating an issue report!

@glynos glynos self-assigned this Aug 7, 2020
@glynos glynos added this to the v2.0 milestone Aug 7, 2020
@coreprocess
Copy link

@huiseliming here is what you can add right after the find_package call to make it work:

# Import target "skyr::skyr-url" for configuration "Debug"
set_property(TARGET skyr::skyr-url APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(skyr::skyr-url PROPERTIES
  IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
  IMPORTED_LOCATION_DEBUG "${VCPKG_ROOT}/installed/x64-windows/debug/lib/skyr-urld.lib"
)

@glynos
Copy link
Member

glynos commented Aug 11, 2020

Thanks for the response, @Core-Process

It's not easy for me to test using this library on Windows using the package manager. Do you think it's sufficient to add this as a comment in the README file, or can I add that somewhere in the install set up?

@shrinktofit
Copy link

@Core-Process ${VCPKG_ROOT} is empty on VS2019

@emmenlau
Copy link

I'm sorry to jump into this thread but I think think this is not an issue of url. The build log shows a mismatch of Visual Studio setting _ITERATOR_DEBUG_LEVEL. This can happen for example if you use the project https://github.com/xtensor-stack/xtensor, that requires _ITERATOR_DEBUG_LEVEL=0. The clean solution is to compile all your projects with the same setting for _ITERATOR_DEBUG_LEVEL. This may be achieved inside vcpkg, or possibly by setting CPPFLAGS="/D_ITERATOR_DEBUG_LEVEL=0" before building the first package.

I do not think there is anything this package here can (or should) do.

@coreprocess
Copy link

@emmenlau if that is true, why is it going away with the simple snippet above? :-)

@coreprocess
Copy link

@glynos Its like the debug configuration is not exported properly. I am not a vcpkg expert, therefore unfortunately I have no idea what you would have to do differently.

@emmenlau
Copy link

emmenlau commented Mar 31, 2021

@emmenlau if that is true, why is it going away with the simple snippet above? :-)

Without reading the snippet above I would assume that this would be a possible solution to the problem. But in my humble opinion its not the clean solution.

Giving flags like _ITERATOR_DEBUG_LEVEL=0 (or similar flags, like /arch:AVX2 or /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS etcetc) can, and should be, completely in users hands. I.e. with a cmake-based build, set the variables CFLAGS and/or CXXFLAGS accordingly, they will be respected by all cmake projects (unless the project explicitly removes flags, which is highly unlikely and probably an error).

On a related note, we build literally hundreds of packages with cmake (and even a few other build systems like Perl for OpenSSL) on many platforms, including MSVC with both the Visual Studio Compiler and the Clang compiler. On MSVC we use _ITERATOR_DEBUG_LEVEL=0 amongst other flags for all packages, otherwise they are binary incompatible. None of the packages does anything special to respect or support this setting.

This works with url (amongst many others) without problems.

@coreprocess
Copy link

@emmenlau The snippet just makes sure that it links to "skyr-urld.lib" and not "skyr-url.lib" for DEBUG builds. And it fixes the problem here. Maybe it is something that needs to be fixed in this library? ;-)

@emmenlau
Copy link

@coreprocess Maybe I'm missing something but can you say why current url would not already link "skyr-urld.lib"?

I see in my windows build:

#> grep -Irn "urld" lib/cmake/skyr-url
lib/cmake/skyr-url/skyr-url-targets-debug.cmake:12:  IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/skyr-urld.lib"
lib/cmake/skyr-url/skyr-url-targets-debug.cmake:16:list(APPEND _IMPORT_CHECK_FILES_FOR_skyr::skyr-url "${_IMPORT_PREFIX}/lib/skyr-urld.lib" )

Why do you think cmake would not link urld? At least in "plain" cmake this just works.

@coreprocess
Copy link

@emmenlau Interesting, that skyr-url-targets-debug.cmake does not get generated here. At least that is a lead we can have a look at.

@emmenlau
Copy link

@coreprocess Yes maybe there is really something fundamentally different in how vcpkg builds or uses cmake. Thanks for following this up!

@glynos
Copy link
Member

glynos commented Apr 1, 2021

Thanks for following up! I'm not ignoring this thread, but I don't know yet how to apply a fix here, or if it's something to do with the configuration of vcpkg. I will take a look.

GerHobbelt pushed a commit to GerHobbelt/url that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants