You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run mcpp build to fetch and build with the new dependency.
in:
mcpp build
out:
Resolving toolchain
Resolved llvm@20.1.7 → @mcpp/registry/data/xpkgs/xim-x-llvm/20.1.7/bin/clang++.exe
Updating package index (auto-refresh)
Downloading mcpplibs.gtest v1.15.2
Downloading compat.gtest v1.15.2
Downloading compat:compat.gtest@1.15.2
Inferred sources [src/**/*.{cppm,cpp,cc,c}]
Compiling add v0.1.0 (.)
Compiling gtest v1.15.2
error: build failed
gtest_main.o : error LNK2005: main already defined in main.o
bin\hello.exe : fatal error LNK1169: one or more multiply defined symbols found
clang++: error: linker command failed with exit code 1169 (use -v to see invocation)
Activity
Sunrisepeak commentedon Jun 25, 2026
如果只是 tests 下面用的, 可以放到
[dev-dependencies]下面. mcpp build 是不构建 tests的. mcpp test 会自动识别mcpp/mcpp.toml
Lines 45 to 47 in 453faba
docs: finalize gtest_main fix design (src=feature / dev=detection / a…
feat: feature-gated dep sources + `mcpp add --dev` — fix #168 gtest_m…
Sunrisepeak commentedon Jun 25, 2026
已在 mcpp 0.0.65 修复(已发布:
xlings install mcpp@0.0.65 -y)。根因
mcpp add gtest把 gtest 写进[dependencies](常规依赖),mcpp build时 gtest 的gtest_main.cc(自带main)被链进应用,与应用自身main冲突 →LNK2005 / duplicate symbol: main。修复:通用「feature 门控源」
gtest_main.cc归入mainfeature,默认不链:gtest = "1.15.2"→ 只链框架,不再撞 main(app 自带 main 也安全);TEST宏、不写 main)→gtest = { version = "1.15.2", features = ["main"] }。[mcpp].features.<名>.sources),非 gtest 特例;旧 mcpp 兼容(行为不变)。另外
mcpp add --dev gtest(写入[dev-dependencies]),由mcpp test消费 ——mcpp test对「带/不带 main 的测试」均自动处理。设计详见仓库
.agents/docs/2026-06-25-gtest-main-feature-and-add-dev-design.md。fix(build): feature sources 在 `mcpp test` 下不编译 (0.0.94) (#218)