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

Linker error when compiling with -cc clang on Windows #20724

Closed
zeozeozeo opened this issue Feb 3, 2024 · 1 comment · Fixed by #20767
Closed

Linker error when compiling with -cc clang on Windows #20724

zeozeozeo opened this issue Feb 3, 2024 · 1 comment · Fixed by #20767
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS.

Comments

@zeozeozeo
Copy link
Contributor

zeozeozeo commented Feb 3, 2024

Describe the bug

V doesn't link with user32 on Windows, so the MessageBoxA call in gcboehm is an unresolved symbol.

Reproduction Steps

Compile this with v -cc clang . on Windows:

fn main() {
}

Expected Behavior

No linker errors

Current Behavior

...
22 warnings generated.
LINK : warning LNK4044: unrecognized option '/stack=16777216'; ignored
4dff8b4b7f125d28de505b053831e68b.module.builtin.o : error LNK2019: unresolved external symbol __imp_MessageBoxA referenced in function GC_copy_bl
C:\Users\user\Desktop\Code\tests\test.exe : fatal error LNK1120: 1 unresolved externals
clang: error: linker command failed with exit code 1120 (use -v to see invocation)
builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Possible Solution

Insert a #flag -luser32 when compiling on Windows in vlib/builtin/builtin_d_gcboehm.c.v.

Additional Information/Context

Works with v -cflags "-luser32" -cc clang .

V version

V 0.4.4 abd2b64

Environment details (OS name and version, etc.)

V 0.4.4 abd2b64

C:\Users\user\Desktop\Code\leaflang>v doctor
V full version: V 0.4.4 5306469.abd2b64
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 20 cpus, 64bit, little endian,

getwd: C:\Users\user\Desktop\Code\leaflang
vexe: C:\Users\user\Desktop\Code\v\v.exe
vexe mtime: 2024-02-03 20:04:45

vroot: OK, value: C:\Users\user\Desktop\Code\v
VMODULES: OK, value: C:\Users\user\.vmodules
VTMP: OK, value: C:\Users\user\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.1
Git vroot status: weekly.2024.05-20-gabd2b647
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 a39eb79b

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@zeozeozeo zeozeozeo added the Bug This tag is applied to issues which reports bugs. label Feb 3, 2024
@felipensp felipensp added the OS: Windows Bugs/feature requests, that are specific to Windows OS. label Feb 9, 2024
@felipensp
Copy link
Member

Can you provide the PR? @zeozeozeo

zeozeozeo added a commit to zeozeozeo/v that referenced this issue Feb 9, 2024
Before this commit, V didn't link with user32 on Windows for compilers
other than tcc, so the MessageBoxA call in gcboehm was an unresolved
symbol.
This fixes vlang#20724.
spytheman pushed a commit that referenced this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants