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

llvm toolchain - vcpkg integration - lld-linker error #4359

Closed
Neumann-A opened this issue Sep 27, 2018 · 22 comments
Closed

llvm toolchain - vcpkg integration - lld-linker error #4359

Neumann-A opened this issue Sep 27, 2018 · 22 comments

Comments

@Neumann-A
Copy link
Contributor

Using the lld-linker I get the following error:

1>lld-link.exe : error : could not open C:\Sources\Extern\vcpkg\installed\x64-windows-static\lib*.lib: invalid argument

apparently the lld-linker does not like to include libraries by wildcards.

The problem lies within:
\scripts\buildsystems\msbuild\vcpkg.targets
line 62 & 63

where
%(AdditionalDependencies);$(VcpkgRoot)debug\lib*.lib
%(AdditionalDependencies);$(VcpkgRoot)lib*.lib
is defined.

So it would be very nice if vcpkg would add and extra item for itself to the project configuration (like the llvm toolchain) so that I can easily change the values of $(VcpkgAutoLink), $(VcpkgTriplet), $(VcpkgEnabled) and maybe even $(VcpkgRoot).

@degski
Copy link

degski commented Sep 29, 2018

@Neumann-A lld-link has an option /lib which supposedly makes lld-link behave as lib. I don't know what that entails, because /lib has to be the first command option passed, which seems to be hard to achieve from the VC-IDE, maybe you're able to work it out.

Neumann-A added a commit to Neumann-A/vcpkg that referenced this issue Oct 26, 2018
…oolset.

(e.g. cmake -G "VS" -TLLVM fails to even find compiler due to linker issues)
fixes microsoft#4359 but might have side effects for that toolset.
(e.g. not automatically adding dependencies)
ras0219-msft pushed a commit that referenced this issue Nov 9, 2018
* make user wide integration not burn everything if LLVM is used as a toolset.
(e.g. cmake -G "VS" -TLLVM fails to even find compiler due to linker issues)
fixes #4359 but might have side effects for that toolset.
(e.g. not automatically adding dependencies)

* remove whitespaces

* [vcpkg-integrate] Conform to MSBuild conventions for comparisons
dantti pushed a commit to dantti/vcpkg that referenced this issue Nov 9, 2018
* make user wide integration not burn everything if LLVM is used as a toolset.
(e.g. cmake -G "VS" -TLLVM fails to even find compiler due to linker issues)
fixes microsoft#4359 but might have side effects for that toolset.
(e.g. not automatically adding dependencies)

* remove whitespaces

* [vcpkg-integrate] Conform to MSBuild conventions for comparisons
@degski
Copy link

degski commented Nov 10, 2018

The LLVM Compiler Toolchain Plugin fixes the use of lld from the VS2017-IDE.

@Neumann-A
Copy link
Contributor Author

@degski:
I am using the LLVM Toolchain Plugin from VS 2017 and lld chokes on how vcpkg autolinks if integration is installed.
Thats why #4573 simply disables autolinking if lld is used.

@degski
Copy link

degski commented Nov 12, 2018

@Neumann-A Sorry, I did not realize you were working on this. I guess that's not yet merged into master or what are the magic spells to end up with the vcpkg integration [as shown on your screenshot]?

As to the wild-card issue, maybe it's an idea to report that on the clang dev list, as link.exe compatibility (for lld-link.exe) is AFAIK an objective.

@Neumann-A
Copy link
Contributor Author

@degski
Copy link

degski commented Nov 12, 2018

@Neumann-A I see.

@szabolcshorvath-craft
Copy link

Why is this issue closed? It's mid 2021 and still I get the same message:

1> lld-link : error : could not open 'C:\Users\szabolcs\vcpkg\scripts\buildsystems\msbuild......\installed\x64-windows\debug\lib*.lib': invalid argument

Environment:
Windows10, VS2019, C++, newly created Command Line Application project, Platform Toolset: llvm (clang-cl), vcpkg integration installed

Even though this issue may have been solved already, it's not clear for me, what to do to resolve this error.
Or should I open another issue for this?

@Neumann-A
Copy link
Contributor Author

Why is this issue closed? It's mid 2021 and still I get the same message:

old integration installed? Remove it and reinstall it. This issue was also mainly for the toolset called LLVM which was installed by LLVM itself. The ClangCL toolset which gets installed by VS itself is probably not handled correctly.

you may be able to adjust the check in

<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true'">false</VcpkgAutoLink>

In the ClangCL toolset I have seen the boolean ClangClMode in ClCompile

<VcpkgAutoLink Condition="'$(UseLldLink)' == 'true' or '%(ClCompile.ClangClMode)' == 'true'">false</VcpkgAutoLink>

@szabolcshorvath-craft
Copy link

Thank you for the quick response! It's a new integration because a recent upgrade of vcpkg deleted all my previously installed packages, so I've decided to make a clean start over. But just to be sure, now I've reinstalled the integration and the problem still remains. Indeed, I'm using the LLVM platform toolset installed by VS itself. Also thank you for the tip, I will look into if I could adjust that check!

@tommitytom
Copy link

tommitytom commented Aug 15, 2021

I'm getting this error on one of my AppVeyor builds too - google led me here. Unsure whether it is an issue with how I've set up the CI, or whether it's how they create the CI image. The project I'm building only contains a single .cpp file. Log here if its of any use: https://ci.appveyor.com/api/buildjobs/yh8sm1bnq63a8kcd/log

Edit: Appears to be the same issue as #15623

@Ou7law007
Copy link

How is this not solved yet? Having to disable auto link and manually link libs is not practical!

@snealbli
Copy link

snealbli commented Dec 1, 2021

I am also having this problem, identical to #4359 (comment)

Is there a solution?

@drywolf
Copy link

drywolf commented Dec 12, 2021

@ras0219-msft Looks like the temporary fix done in #4573 is no longer working ?
I am also getting the same error as mentioned by OP:

1>lld-link : error : could not open 'C:\code\vcpkg\installed\\x64-windows\debug\lib\*.lib': invalid argument

VS 2019 (16.11.7)

@gurachan
Copy link

this still an issue until this day .. xD omg..

@pudding186
Copy link

this error because you integrate vcpkg to Visual Studio , run command "vcpkg integrate remove" then everything is OK

@gurachan
Copy link

gurachan commented Jun 6, 2022

this error because you integrate vcpkg to Visual Studio , run command "vcpkg integrate remove" then everything is OK

but thats a feature xD removing a feature its a not a fix. its a temp solution u have to import manually the include and libs if u dont integrate it..

@M0n7y5
Copy link

M0n7y5 commented Nov 27, 2022

So its a still an issue ...

@RT2Code
Copy link
Contributor

RT2Code commented Dec 19, 2022

I too can't build my projects with Clang without disabling the autolink feature. Is supporting both at the same time planned? It would be great, because the autolink feature is really convenient on projects with many dependencies. I think this issue should be reopened.

@dtroitskiy
Copy link

Just encountered it too.

@stxticOVFL
Copy link

this error because you integrate vcpkg to Visual Studio , run command "vcpkg integrate remove" then everything is OK

Issue is still present, this "fix" still works.

@walbourn
Copy link
Member

walbourn commented May 4, 2023

#31239

@reupen
Copy link

reupen commented May 11, 2023

Hi,

I just as a note for others, I have using link.exe with Clang as a workaround for this by specifying /p:PlatformToolset=ClangCL;LinkToolExe=link.exe. This stopped working following #31239.

It's easily fixed though as specifying VcpkgAutoLink=true (/p:PlatformToolset=ClangCL;LinkToolExe=link.exe;VcpkgAutoLink=true) gets things working again.

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