Skip to content

Properly lookup .lib files on command line on MS/Windows. #11906

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

Closed
Bigcheese opened this issue Dec 11, 2011 · 9 comments
Closed

Properly lookup .lib files on command line on MS/Windows. #11906

Bigcheese opened this issue Dec 11, 2011 · 9 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'

Comments

@Bigcheese
Copy link
Contributor

Bugzilla Link 11534
Resolution FIXED
Resolved on Nov 06, 2014 10:36
Version trunk
OS Windows NT
Blocks llvm/llvm-bugzilla-archive#13707
CC @tritao,@Meinersbur,@rafaelauler,@rnk

Extended Description

Given:
$clang++ file.cpp kernel32.lib
Clang currently prints:
clang++: error: no such file or directory: 'kernel32.lib'

It should look up the library in the same manner as cl.exe.

@Bigcheese
Copy link
Contributor Author

assigned to @Bigcheese

@llvmbot
Copy link
Member

llvmbot commented Dec 11, 2011

FYI, mingw-gcc can accept foo.lib as -lfoo

@llvmbot
Copy link
Member

llvmbot commented Oct 12, 2012

Hello Michael and Nakamura,

I'am new to llvm/clang and I have the same issue.

I have recently compiled the llvm/clang source with vc++, and try to do
the example from "get_started page" (t.c example).

I use the linker from vc, and I have the issue with libcmt and kernel32.

For now I do clang -c t.c/link -out:t.exe -defaultlib:libcmt -nologo /LIBPATH: /LIBPATH: t.o
and that work, maybe there are another manner to do.

I saw two options with clang,
-Wl, Pass the comma separated arguments in to the linker
-Xlinker Pass to the linker

to pass argument to the linker, but it seem that doesn't work (or maybe just for gcc ?), what does this two options must be do ?

@Bigcheese
Copy link
Contributor Author

Hello Michael and Nakamura,

I'am new to llvm/clang and I have the same issue.

I have recently compiled the llvm/clang source with vc++, and try to do
the example from "get_started page" (t.c example).

I use the linker from vc, and I have the issue with libcmt and kernel32.

For now I do clang -c t.c/link -out:t.exe -defaultlib:libcmt -nologo
/LIBPATH: /LIBPATH: t.o
and that work, maybe there are another manner to do.

Clang does -defaultlib:libcmt, which is enough for hello world.

I saw two options with clang,
-Wl, Pass the comma separated arguments in to the linker
-Xlinker Pass to the linker

to pass argument to the linker, but it seem that doesn't work (or maybe just
for gcc ?), what does this two options must be do ?

They don't work because I never hooked them up. See https://github.com/Bigcheese/clang/blob/cmake-revision/lib/Driver/Tools.cpp#L5373 for where that needs to be added.

@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2012

Hello Michael and Nakamura,

I'am new to llvm/clang and I have the same issue.

I have recently compiled the llvm/clang source with vc++, and try to do
the example from "get_started page" (t.c example).

I use the linker from vc, and I have the issue with libcmt and kernel32.

For now I do clang -c t.c/link -out:t.exe -defaultlib:libcmt -nologo
/LIBPATH: /LIBPATH: t.o
and that work, maybe there are another manner to do.

Clang does -defaultlib:libcmt, which is enough for hello world.

Ok, thank you I didn't know.

I saw two options with clang,
-Wl, Pass the comma separated arguments in to the linker
-Xlinker Pass to the linker

to pass argument to the linker, but it seem that doesn't work (or maybe just
for gcc ?), what does this two options must be do ?

They don't work because I never hooked them up. See
https://github.com/Bigcheese/clang/blob/cmake-revision/lib/Driver/Tools.cpp#L5373
for where that needs to be added.

Ok, I will see this file, and the clang technical documentation, to see how I can add this new feature.

Thank you

@Meinersbur
Copy link
Member

clang -target "x86_64-pc-win32"

doesn't even find the right libcmt.lib, because %LIBPATH% points to C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib where the 32-bit libs are. The correct libcmt.lib is C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64\libcmt.lib

If running inside "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\vcvars64.bat", which sets the right %LIBPATH%, it works fine (minus exception handling).

Note that also the path to link.exe should change to "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\link.exe" and add /MACHINE:X64 to the cmdline. But within vcvars64.bat, it works either way. Therefore one idea is to setup the environment using vcvars*.bat instead that clang finds the correct parameters itself.

@rafaelauler
Copy link
Contributor

Shouldn't this bug be closed? clang-cl already handles .lib files.

@rnk
Copy link
Collaborator

rnk commented Nov 6, 2014

Shouldn't this bug be closed? clang-cl already handles .lib files.

Yep.

@tritao
Copy link
Mannequin

tritao mannequin commented Nov 26, 2021

mentioned in issue llvm/llvm-bugzilla-archive#13707

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

No branches or pull requests

5 participants