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

Fix msvc-wine with cmake package #5871

Merged
merged 1 commit into from
Nov 23, 2024
Merged

Conversation

star-hengxing
Copy link
Contributor

#4501 (comment)

  • Force to use ninja.
  • Workaround for cmake msvc ar.

@@ -642,6 +642,9 @@ function _get_configs_for_cross(package, configs, opt)
envs.CMAKE_CXX_COMPILER = _translate_bin_path(package:build_getenv("cxx"))
envs.CMAKE_ASM_COMPILER = _translate_bin_path(package:build_getenv("as"))
envs.CMAKE_AR = _translate_bin_path(package:build_getenv("ar"))
if package:is_plat("windows") and is_host("linux") then
envs.CMAKE_AR = path.join(path.directory(envs.CMAKE_CXX_COMPILER), "lib.exe")
end
Copy link
Contributor Author

@star-hengxing star-hengxing Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能改 CMAKE_STATIC_LINKER_FLAGS 更好?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该得用 link.exe -lib 吧 你试试

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

FAILED: libusb-1.0.lib
: && /home/star/msvc/bin/x64/link.exe /nologo -lib -lib /out:libusb-1.0.lib CMakeFiles/usb-1.0.dir/libusb/core.c.obj CMakeFiles/usb-1.0.dir/libusb/descriptor.c.obj CMakeFiles/usb-1.0.dir/libusb/hotplug.c.obj CMakeFiles/usb-1.0.dir/libusb/io.c.obj CMakeFiles/usb-1.0.dir/libusb/strerror.c.obj CMakeFiles/usb-1.0.dir/libusb/sync.c.obj CMakeFiles/usb-1.0.dir/libusb/os/events_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/threads_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_common.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_usbdk.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_winusb.c.obj CMakeFiles/usb-1.0.dir/libusb/libusb-1.0.rc.res && :
LINK : warning LNK4044: unrecognized option '/lib'; ignored
LINK : warning LNK4044: unrecognized option '/lib'; ignored
LINK : fatal error LNK1561: entry point must be defined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该得用 link.exe -lib 吧 你试试

"/home/star/msvc/bin/x64/link.exe -lib" /nologo  /out:libusb-1.0.lib CMakeFiles/usb-1.0.dir/libusb/core.c.obj CMakeFiles/usb-1.0.dir/libusb/descriptor.c.obj CMakeFiles/usb-1.0.dir/libusb/hotplug.c.obj CMakeFiles/usb-1.0.dir/libusb/io.c.obj CMakeFiles/usb-1.0.dir/libusb/strerror.c.obj CMakeFiles/usb-1.0.dir/libusb/sync.c.obj CMakeFiles/usb-1.0.dir/libusb/os/events_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/threads_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_common.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_usbdk.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_winusb.c.obj CMakeFiles/usb-1.0.dir/libusb/libusb-1.0.rc.res && :
/bin/sh: 1: /home/star/msvc/bin/x64/link.exe -lib: not found

Copy link
Member

@waruqi waruqi Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能是多加了个双引号的问题,你得 ar 设置成 link.exe ,-lib 挪到 flags 里去

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

FAILED: libusb-1.0.lib
: && /home/star/msvc/bin/x64/link.exe /nologo -lib -lib /out:libusb-1.0.lib CMakeFiles/usb-1.0.dir/libusb/core.c.obj CMakeFiles/usb-1.0.dir/libusb/descriptor.c.obj CMakeFiles/usb-1.0.dir/libusb/hotplug.c.obj CMakeFiles/usb-1.0.dir/libusb/io.c.obj CMakeFiles/usb-1.0.dir/libusb/strerror.c.obj CMakeFiles/usb-1.0.dir/libusb/sync.c.obj CMakeFiles/usb-1.0.dir/libusb/os/events_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/threads_windows.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_common.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_usbdk.c.obj CMakeFiles/usb-1.0.dir/libusb/os/windows_winusb.c.obj CMakeFiles/usb-1.0.dir/libusb/libusb-1.0.rc.res && :
LINK : warning LNK4044: unrecognized option '/lib'; ignored
LINK : warning LNK4044: unrecognized option '/lib'; ignored
LINK : fatal error LNK1561: entry point must be defined

这个就是用 CMAKE_STATIC_LINKER_FLAGS 的结果。
貌似只能改成 lib.exe 了,不过有点 hardcode 了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_host("linux") 这个判断可以删除,在 host windows 交叉编译 target windows arm64 也出现了这个问题。

@waruqi waruqi merged commit f412067 into xmake-io:dev Nov 23, 2024
19 checks passed
@star-hengxing star-hengxing deleted the msvc-wine branch November 23, 2024 13:00
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

Successfully merging this pull request may close these issues.

2 participants