xmake
xmake copied to clipboard
Custom rules not linking obj files in VS generator
Xmake Version
v2.8.5+HEAD.debbd3ac3
Operating System Version and Architecture
Windows 11
Describe Bug
When using a custom rule with batchcmds to compile files the obj files are not linked in the state library.
WIth the repro project:
xmake
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.37.32825
[ 22%]: compiling.test lib.test
[ 22%]: compiling.release main.cpp
[ 44%]: compiling.release dummy.cpp
[ 55%]: archiving.release libhello.lib
[ 77%]: linking.release hello.exe
[100%]: build ok, spent 0.344s
With the vs project:
Build started...
1>------ Build started: Project: libhello, Configuration: release x64 ------
1>lib.cpp
1>dummy.cpp
1>libhello.vcxproj -> F:\Dev\repro\build\windows\x64\release\libhello.lib
2>------ Build started: Project: hello, Configuration: release x64 ------
2>main.cpp
2>main.obj : error LNK2019: unresolved external symbol "int __cdecl test_func(int,int)" (?test_func@@YAHHH@Z) referenced in function main
2>..\..\build\windows\x64\release\hello.exe : fatal error LNK1120: 1 unresolved externals
2>Done building project "hello.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 1:35 PM and took 00.622 seconds ==========
Expected Behavior
Added obj files from batchcmds are included in link phase using the vs
project generator.
Project Configuration
Additional Information and Error Logs
NA
why do not use vsxmake generator? xmake project -k vsxmake
Although vs generator also supports custom scripts, it has some limitations and is not as well supported as vsxmake.
For example, right now it doesn't support adding object only files to vs projects.
For a couple reasons:
- Building is slower with vsxmake
- Cleaning my solution takes almost 2 minutes
Everytime I give vsxmake a try again because I encounter an issue with the vs generator, there is way more friction and difficulties compared to the vs generator. As it is I can't use vsxmake, I can't justify 2 minutes to clean my solution and 3x longer compile times.
For a couple reasons:
- Building is slower with vsxmake
- Cleaning my solution takes almost 2 minutes
Everytime I give vsxmake a try again because I encounter an issue with the vs generator, there is way more friction and difficulties compared to the vs generator. As it is I can't use vsxmake, I can't justify 2 minutes to clean my solution and 3x longer compile times.
Calling xmake to build a project shouldn't be this slow. Is it also slow if you run the xmake command directly to build?
Adding a bit of context here, building/cleaning is slower for @maximegmd because he's building/cleaning the whole solution. Making VS call xmake config and xmake clean on every target. It's not slow for a single target.
I think we can improve the vsxmake generator to work a bit like Unreal Engine Visual Studio projects.