Skip to content

MSVC builds fail with #pkgconfig: gcc-style -l/-L flags treated as inputs (e.g., -lintl → intl.obj) #26628

Description

@quaesitor-scientiam

Describe the bug

When compiling with -cc msvc, V’s internal #pkgconfig emits gcc-style flags (-I/-L/-l). MSVC ignores -L and treats -lfoo as an input file,

Reproduction Steps

  1. Ensure vcpkg libs (e.g., pango, freetype, glib) are installed.

  2. Build a module that uses #pkgconfig (e.g., vglyph from vmodules).

  3. Compile with MSVC:

    v -cc msvc -o clicks.exe C:\Users\john3.vmodules\gui\examples\clicks.v

Actual Result
MSVC warnings and link failure:

cl : warning D9002 : ignoring unknown option '-L...'
cl : warning D9024 : unrecognized source file type 'intl', object file assumed
LINK : fatal error LNK1104: cannot open file 'intl.obj'

Expected Behavior

MSVC build should succeed; pkgconfig-derived flags should be converted to MSVC-style /I, /LIBPATH:, and foo.lib.

Current Behavior

MSVC warnings and link failure:

cl : warning D9002 : ignoring unknown option '-L...'
cl : warning D9024 : unrecognized source file type 'intl', object file assumed
LINK : fatal error LNK1104: cannot open file 'intl.obj'

Possible Solution

When -cc msvc is selected, translate pkgconfig output flags before passing to the C compiler:

  • -Ipath → /Ipath
  • -Lpath → /LIBPATH:path
  • -lfoo → foo.lib

This should be applied only for MSVC and not affect gcc/clang.

Additional Context
Attempting to override PKG_CONFIG is not effective because V uses its internal pkgconfig implementation for #pkgconfig, which always emits
gcc-style flags.

Additional Information/Context

No response

V version

V version: V 0.5.0 aca3797

Environment details (OS name and version, etc.)

|V full version      |V 0.5.0 c34ea2be9dba47a93aa206326aac3aa2b7365a77.aca3797
|:-------------------|:-------------------
|OS                  |windows, Microsoft Windows 11 Pro 26200 64-bit
|Processor           |24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
|Memory              |82.77GB/127.92GB
|                    |
|V executable        |S:\repo\vlang\v.exe
|V last modified time|2026-02-19 14:28:41
|                    |
|V home dir          |OK, value: S:\repo\vlang
|VMODULES            |OK, value: C:\Users\john3\.vmodules
|VTMP                |OK, value: S:\temp\v_0
|Current working dir |OK, value: S:\repo\vlang
|                    |
|env VFLAGS          |"-cc clang"
|Git version         |git version 2.52.0.windows.1
|V git status        |weekly.2026.08-10-gaca3797f
|.git/config present |true
|                    |
|cc version          |cc (x86_64-posix-seh-rev0, Built by MinGW-Builds project) 15.2.0
|gcc version         |gcc (x86_64-posix-seh-rev0, Built by MinGW-Builds project) 15.2.0
|clang version       |clang version 21.1.7 (https://github.com/llvm/llvm-project.git 292dc2b86f66e39f4b85ec8b185fd8b60f5213ce)
|msvc version        |N/A
|tcc version         |tcc version 0.9.27 (x86_64 Windows)
|tcc git status      |thirdparty-windows-amd64 b425ac82
|emcc version        |N/A
|glibc version       |N/A

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions