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

Fail to compilation: duplicate section `***' has different size #150

Closed
stuartZhang opened this issue Jun 8, 2021 · 29 comments
Closed

Fail to compilation: duplicate section `***' has different size #150

stuartZhang opened this issue Jun 8, 2021 · 29 comments

Comments

@stuartZhang
Copy link

stuartZhang commented Jun 8, 2021

(1) My OS: windows 10 x64

(2) My package management: MSYS2

(3) The installed libraries related to QT include:

local/mingw-w64-i686-qbs 1.18.0-2
    Qt Build Suite (mingw-w64)
local/mingw-w64-i686-qt-creator 4.14.2-1
    Cross-platform IDE (mingw-w64)
local/mingw-w64-i686-qt5 5.15.2-8 (mingw-w64-i686-qt mingw-w64-i686-qt5)
    A cross-platform application and UI framework (mingw-w64)
local/mingw-w64-i686-qt5-static 5.15.2-2 (mingw-w64-i686-qt-static mingw-w64-i686-qt5-static)
    A cross-platform application and UI framework (mingw-w64-static)
local/mingw-w64-i686-qtbinpatcher 2.2.0-4
    Patcher for Qt libraries (mingw-w64)
local/mingw-w64-x86_64-qbs 1.18.0-2
    Qt Build Suite (mingw-w64)
local/mingw-w64-x86_64-qt-creator 4.14.2-1
    Cross-platform IDE (mingw-w64)
local/mingw-w64-x86_64-qt5 5.15.2-8 (mingw-w64-x86_64-qt mingw-w64-x86_64-qt5)
    A cross-platform application and UI framework (mingw-w64)
local/mingw-w64-x86_64-qt5-static 5.15.2-2 (mingw-w64-x86_64-qt-static mingw-w64-x86_64-qt5-static)
    A cross-platform application and UI framework (mingw-w64-static)
local/mingw-w64-x86_64-qtbinpatcher 2.2.0-4
    Patcher for Qt libraries (mingw-w64)

(4) The installed libraries related to libcrypt include:

local/libcrypt 2.1-3 (libraries)
    Encryption/Decryption library
local/libcrypt-devel 2.1-3 (development)
    Libcrypt headers and libraries
local/libgcrypt 1.9.2-1 (libraries)
    General purpose cryptographic library based on the code from GnuPG
local/libgpg-error 1.42-1 (libraries)
    Support library for libgcrypt
local/libhogweed 3.7.2-1 (libraries)
    A low-level cryptographic library
local/libnettle 3.7.2-1 (libraries)
    A low-level cryptographic library
local/libxxhash 0.8.0-1 (libraries)
    Extremely fast non-cryptographic hash algorithm
local/mingw-w64-i686-libgcrypt 1.9.2-2
    General purpose cryptographic library based on the code from GnuPG (mingw-w64)
local/mingw-w64-i686-libgpg-error 1.42-1
    Support library for libgcrypt (mingw-w64)
local/mingw-w64-x86_64-libdvdcss 1.4.2-1
    Portable abstraction library for DVD decryption (mingw-w64)
local/mingw-w64-x86_64-libgcrypt 1.9.2-2
    General purpose cryptographic library based on the code from GnuPG (mingw-w64)
local/mingw-w64-x86_64-libgpg-error 1.42-1
    Support library for libgcrypt (mingw-w64)
local/mingw-w64-x86_64-nettle 3.7.2-1
    A low-level cryptographic library (mingw-w64)
local/mingw-w64-x86_64-xxhash 0.8.0-1
    Extremely fast non-cryptographic hash algorithm (mingw-w64)
local/nettle 3.7.2-1 (net-utils)
    A low-level cryptographic library
local/xxhash 0.8.0-1
    Extremely fast non-cryptographic hash algorithm

(5) When I executes the command cargo run -p todos in mingw64.exe, the following error is shown:

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.10dsjum8pcrztsh7.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.12o9lrwmspc88xdd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.14q3crp5axgi1c0k.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.160zd0vuj5j8476n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1a5q71sm873kabcb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1axxkyz3td4u420v.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1bpsvay1zd3gmyxi.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1cldh9q9b8e81daw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1f95wj6p76k5qs74.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1js4h6h69ydy71bb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1ldkfd71voahqcyu.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1o0jgq7jtr0p9nk.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1pwg26nlvkaspc1p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1rgal1zmhvwv76no.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1rl96vgwtxc7v6pb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1so53f56acdpasyd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1tbxrd4ctbnwekf.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.20pljcdyyejw3ekv.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.21uoc3wyd1fstgjy.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.238c90tmezz6m2mj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.263z2ubuorpjr1vf.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.26cb5xz16t4pbzpg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dgausbqdsn60u8p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dktrbi4g35dnykr.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dxoaxuc712dt5r0.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2g9w0mb8syq9ihb6.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2i9eo5am386raogg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2in9iff9qv0lpf2f.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2isagcy4996lriqo.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2jnagg4gz56nyn8d.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2mzfx8uol7k854t3.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2q4f8m64fxnolx79.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2ss8t8zkooexm9qb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2t1vn3dsrpk1mexr.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2vcedks0835xzjjx.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2y8l2ml17ckxhvdd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.308n6xvt606ex5i9.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.31h6nbvhsu0o3jsg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.31i7xbrt2as5fmq4.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.38q0a3gi2eqpcr86.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3acfkqvngljpixqj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3bz5jm22pgs1lqc1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3cuznll17iombe9c.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3gesf84x1i55jxhp.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3gjzrfnqmgfzjrqm.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3kb83mh5dtvcg66p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3ohbfns4gk2j5yzn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3tfa441drqfuewjd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3tn72xpkp33ln9ze.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3vbvmvki2ovd47ey.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3vq9o1tjpchr84gg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3xl41wd24k1c1qn1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3ybobfoypattqvkh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3yna42bmogvo07dv.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.413qajnq2htatfb4.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.41ggz430cny5xk4z.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.41qi3z847vpxgi7v.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.43jhiw4qsqetri2j.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.44negdatoahn2frh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.467fjx0vw20fv4sw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.471uvbl12lfeo4ge.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ckhhjkfl6lvxuv6.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4cxnsdgabd95vp3g.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4d7bm26p81mnk6c2.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4filed7q0lvpjw13.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4j7fho4vpa8jip0c.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4jx2nf0q9gyswxcw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4lz9bq4wr62mzupc.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4n09xa3v3d7shue1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4pgaci2hyv33jmiy.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ubwvh1kbbk29ayn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ukeubhx2eveechk.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4wtvpirxzxy589en.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4x7mf0rn498uob5b.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4xq3c3ya176bwjlp.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ze7hsxqikpbvh3x.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.566d1kvmvkhqwjbn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.56jc5vu5k0fa2j3m.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.581fx88f2mjlmoeh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5a4aiyyfanfsog2n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5aazdkg54u4n2g55.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5awne1m6x70ngtgx.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5bb4cm4h6pvtfk9.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5bqn1ohj8z3jfxtc.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5dcniekge0wyy1ke.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5gey0b062knimwhg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.7gl138rnfon4617.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.ae6jx9fkbo7j209.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.aldb6jsiuuqpu6n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.el0vzpduhwyp57g.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.fe0arpx95g7xqza.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.h4z23b54bndbv09.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.oxnb8auker3jv9n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.pdg1j5ns006octh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.ph307haryfqr5l1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.qh1hdtknk2hcykj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.vi6pmax54gmn1wh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.x66noukoj7872xp.rcgu.o" "-o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.exe" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.hh09vytktfj4qaj.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\build\\qmetaobject-11ec537bbf8b6b87\\out" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\build\\qttypes-dd4c082e42378ffe\\out" "-L" "H:/symbol_link_source/msys64/mingw64/lib" "-L" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libqmetaobject-e284a3ee801d53d3.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\liblog-f685979e2ab1ba7b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libcfg_if-b273423f0756ca72.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libqttypes-929376424a1dde2b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libcpp-d5f17c73b9ae0b1b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\liblazy_static-f392f42a3d2e534b.rlib" "-Wl,--start-group" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-94f60f405c1748af.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-f56d3aec7c2576d9.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-8e553c585536bfaf.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-3a82c272c5de0489.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-ef04c21117777245.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-b3ae962defb8b363.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-b441247297fa184b.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-19bb25a86d3a5b92.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-d7957714cc30050c.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-abd7bd18212580be.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-80187982c9cf70bf.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4172a25dd8c4f2de.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-27282989cc5b80d2.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-2f52c7ac303d5565.rlib" "-Wl,--end-group" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-2b00c29940bf9d8a.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lstdc++" "-lmsvcrtd" "-lQt5Cored" "-lQt5Guid" "-lQt5Widgetsd" "-lQt5Quickd" "-lQt5Qmld" "-ladvapi32" "-lws2_32" "-luserenv" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: H:\github_projects\qt_rs_todos\target\debug\deps\libqttypes-929376424a1dde2b.rlib(cpp_closures.o): duplicate section `.data$_ZN7rustcpp8metadataE[_ZN7rustcpp8metadataE]' has different size
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrtd
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lQt5Cored
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lQt5Guid
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lQt5Widgetsd
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lQt5Quickd
          H:/symbol_link_source/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lQt5Qmld
          collect2.exe: error: ld returned 1 exit status

Do you give me a few of suggestions for how to compile the project? Maybe, are there certain libraries I missed in my local MSYS2? Or I shoundn't utilize MSYS2?

@ogoffart
Copy link
Member

ogoffart commented Jun 8, 2021

Looks like the same issue as #35 which was fixed long ago

Note that the fix for that bug https://github.com/mystor/rust-cpp/pull/54/files does

#ifdef _WIN64
    __declspec (selectany)
#elif __GNUC__
    __attribute__((weak))
#endif

But i guess in this case both _WIN64 and __GNUC__ are defined? maybe both __declspec (selectany)
and __attribute__((weak)) should be specified? or only __attribute__((weak)) instead of __declspec (selectany)

I know nothing about MSYS2 so i don't know if it is related.

@ogoffart
Copy link
Member

ogoffart commented Jun 8, 2021

I wonder if instead of using a weak symbol for the metadata, we couldn't just give it a unique name.

@ratijas
Copy link
Collaborator

ratijas commented Jun 8, 2021

Thanks for the awesome detailed bug report, @stuartZhang!

Personally, I've only used MSYS2 for a short period of time, and it was one hell of a laggy experience (due to hundreds of forks under the hood, which Windows kernel didn't like), but otherwise somehow worked for me to get a decent shell, package management, and python workspace in a UNIX-way. Now that there is WSL and WSL2, I don't know if MSYS2 is relevant anymore, but I also haven't tried neither of them; so it's up to you to figure out if you will try to switch.

Other than that, I am excited to say that I am currently writing a commercial project with bits of CMake, Qt, Rust, qmetaobject-rs for Windows (but it's really cross-platform, so I mainly develop on a more comfortable Linux). So far it's working alright, using either MinGW-gcc or MSVC kits. I only had to specify some global PATHs to Qt tools on Windows, otherwise qttypes sub-crate fails to find Qt directory.

So, I'd definitely recommend going the "easy way" first. And if/when you feel confident enough — try the MSYS2 or other alternative workflows.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 9, 2021

Thanks for the awesome detailed bug report, @stuartZhang!

Personally, I've only used MSYS2 for a short period of time, and it was one hell of a laggy experience (due to hundreds of forks under the hood, which Windows kernel didn't like), but otherwise somehow worked for me to get a decent shell, package management, and python workspace in a UNIX-way. Now that there is WSL and WSL2, I don't know if MSYS2 is relevant anymore, but I also haven't tried neither of them; so it's up to you to figure out if you will try to switch.

Other than that, I am excited to say that I am currently writing a commercial project with bits of CMake, Qt, Rust, qmetaobject-rs for Windows (but it's really cross-platform, so I mainly develop on a more comfortable Linux). So far it's working alright, using either MinGW-gcc or MSVC kits. I only had to specify some global PATHs to Qt tools on Windows, otherwise qttypes sub-crate fails to find Qt directory.

So, I'd definitely recommend going the "easy way" first. And if/when you feel confident enough — try the MSYS2 or other alternative workflows.

Is there any of Wiki pages about how to set up the DEV environment in Windows OS? Perhaps, the Wiki page makes my effort of practicing "qmetaobject-rs" painless.

Once my individual demo becomes successful, I shall definitely promote your commercial solution to my team leads.

@stuartZhang
Copy link
Author

Looks like the same issue as #35 which was fixed long ago

Note that the fix for that bug https://github.com/mystor/rust-cpp/pull/54/files does

#ifdef _WIN64
    __declspec (selectany)
#elif __GNUC__
    __attribute__((weak))
#endif

But i guess in this case both _WIN64 and __GNUC__ are defined? maybe both __declspec (selectany)
and __attribute__((weak)) should be specified? or only __attribute__((weak)) instead of __declspec (selectany)

I know nothing about MSYS2 so i don't know if it is related.

According to the article https://www.msys2.org/wiki/Porting/, there is a platform-check flag (e.g. _WIN64) provided by MSYS2.

image

@stuartZhang
Copy link
Author

@ratijas Yesterday, I consulted the Wiki page https://wiki.qt.io/MSYS2 to set up the MSYS2 + QT development environment.

@stuartZhang
Copy link
Author

Last night, I have consulted the Wiki page https://wiki.qt.io/MinGW and followed the below steps:

  1. Download and install Qt Oline installer to the folder "F:\Qt"

  2. Add the Qt components

    image

  3. Download and decompress x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z to the folder "H:\symbol_link_source\mingw64_qt"

    image

  4. Add both the directories "F:\Qt\5.12.11\mingw73_64\bin" and "H:\symbol_link_source\mingw64_qt\bin" to the environment variable %PATH%

  5. Go to the project root directory

  6. run the command "cargo build"

  7. The below familiar error is still shown

    error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
    |
    = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "-L" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.10dsjum8pcrztsh7.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.12o9lrwmspc88xdd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.14q3crp5axgi1c0k.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.160zd0vuj5j8476n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1a5q71sm873kabcb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1axxkyz3td4u420v.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1bpsvay1zd3gmyxi.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1cldh9q9b8e81daw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1f95wj6p76k5qs74.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1js4h6h69ydy71bb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1ldkfd71voahqcyu.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1o0jgq7jtr0p9nk.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1pwg26nlvkaspc1p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1rgal1zmhvwv76no.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1rl96vgwtxc7v6pb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1so53f56acdpasyd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.1tbxrd4ctbnwekf.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.20pljcdyyejw3ekv.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.21uoc3wyd1fstgjy.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.238c90tmezz6m2mj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.263z2ubuorpjr1vf.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.26cb5xz16t4pbzpg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dgausbqdsn60u8p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dktrbi4g35dnykr.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2dxoaxuc712dt5r0.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2g9w0mb8syq9ihb6.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2i9eo5am386raogg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2in9iff9qv0lpf2f.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2isagcy4996lriqo.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2jnagg4gz56nyn8d.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2mzfx8uol7k854t3.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2q4f8m64fxnolx79.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2ss8t8zkooexm9qb.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2t1vn3dsrpk1mexr.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2vcedks0835xzjjx.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.2y8l2ml17ckxhvdd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.308n6xvt606ex5i9.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.31h6nbvhsu0o3jsg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.31i7xbrt2as5fmq4.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.38q0a3gi2eqpcr86.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3acfkqvngljpixqj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3bz5jm22pgs1lqc1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3cuznll17iombe9c.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3gesf84x1i55jxhp.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3gjzrfnqmgfzjrqm.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3kb83mh5dtvcg66p.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3ohbfns4gk2j5yzn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3tfa441drqfuewjd.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3tn72xpkp33ln9ze.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3vbvmvki2ovd47ey.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3vq9o1tjpchr84gg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3xl41wd24k1c1qn1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3ybobfoypattqvkh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.3yna42bmogvo07dv.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.413qajnq2htatfb4.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.41ggz430cny5xk4z.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.41qi3z847vpxgi7v.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.43jhiw4qsqetri2j.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.44negdatoahn2frh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.467fjx0vw20fv4sw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.471uvbl12lfeo4ge.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ckhhjkfl6lvxuv6.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4cxnsdgabd95vp3g.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4d7bm26p81mnk6c2.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4filed7q0lvpjw13.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4j7fho4vpa8jip0c.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4jx2nf0q9gyswxcw.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4lz9bq4wr62mzupc.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4n09xa3v3d7shue1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4pgaci2hyv33jmiy.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ubwvh1kbbk29ayn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ukeubhx2eveechk.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4wtvpirxzxy589en.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4x7mf0rn498uob5b.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4xq3c3ya176bwjlp.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.4ze7hsxqikpbvh3x.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.566d1kvmvkhqwjbn.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.56jc5vu5k0fa2j3m.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.581fx88f2mjlmoeh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5a4aiyyfanfsog2n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5aazdkg54u4n2g55.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5awne1m6x70ngtgx.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5bb4cm4h6pvtfk9.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5bqn1ohj8z3jfxtc.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5dcniekge0wyy1ke.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.5gey0b062knimwhg.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.7gl138rnfon4617.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.ae6jx9fkbo7j209.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.aldb6jsiuuqpu6n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.el0vzpduhwyp57g.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.fe0arpx95g7xqza.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.h4z23b54bndbv09.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.oxnb8auker3jv9n.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.pdg1j5ns006octh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.ph307haryfqr5l1.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.qh1hdtknk2hcykj.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.vi6pmax54gmn1wh.rcgu.o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.x66noukoj7872xp.rcgu.o" "-o" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.exe" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\todos-e0d45e23c7d9727d.hh09vytktfj4qaj.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\build\\qmetaobject-11ec537bbf8b6b87\\out" "-L" "H:\\github_projects\\qt_rs_todos\\target\\debug\\build\\qttypes-dd4c082e42378ffe\\out" "-L" "F:/Qt/5.12.11/mingw73_64/lib" "-L" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libqmetaobject-e284a3ee801d53d3.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\liblog-f685979e2ab1ba7b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libcfg_if-b273423f0756ca72.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libqttypes-929376424a1dde2b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\libcpp-d5f17c73b9ae0b1b.rlib" "H:\\github_projects\\qt_rs_todos\\target\\debug\\deps\\liblazy_static-f392f42a3d2e534b.rlib" "-Wl,--start-group" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-94f60f405c1748af.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-f56d3aec7c2576d9.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-8e553c585536bfaf.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-3a82c272c5de0489.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-ef04c21117777245.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-b3ae962defb8b363.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-b441247297fa184b.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-19bb25a86d3a5b92.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-d7957714cc30050c.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-abd7bd18212580be.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-80187982c9cf70bf.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4172a25dd8c4f2de.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-27282989cc5b80d2.rlib" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-2f52c7ac303d5565.rlib" "-Wl,--end-group" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-2b00c29940bf9d8a.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lstdc++" "-lmsvcrtd" "-lQt5Cored" "-lQt5Guid" "-lQt5Widgetsd" "-lQt5Quickd" "-lQt5Qmld" "-ladvapi32" "-lws2_32" "-luserenv" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "H:\\symbol_link_source\\.rustup\\toolchains\\nightly-2021-03-25-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
    = note: H:\github_projects\qt_rs_todos\target\debug\deps\libqttypes-929376424a1dde2b.rlib(cpp_closures.o): duplicate section `.data$_ZN7rustcpp8metadataE[_ZN7rustcpp8metadataE]' has different size
            H:/symbol_link_source/mingw64_qt/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrtd
            collect2.exe: error: ld returned 1 exit status
    
    
    error: aborting due to previous error; 1 warning emitted
    
    error: could not compile `todos`

@ogoffart @ratijas In this case, I gave up MSYS2 and merely used MinGW-gcc and the official Qt installation.

@ogoffart
Copy link
Member

The problem here is in the cpp crate, it is used several time in several dependent crates (qttypes, qmetaobject, and maybe more)
but they all create the metadata symbol.
It is supposed to be defined as week because of the logic in
https://github.com/mystor/rust-cpp/blob/bfea72fb179185a7599afd0ac1ed8a9d14ea7ff0/cpp_build/src/lib.rs#L367-L373

But apparently this doesn't work. Maybe because these define are not set, or maybe we need to have both.

@stuartZhang
Copy link
Author

Perhaps, the fault is fixed in Qt 6.x. I shall install and link Qt 6.0 and retry to cargo build again in this evening. @ogoffart

@ogoffart
Copy link
Member

Unlikely.

duplicate section `.data$_ZN7rustcpp8metadataE[_ZN7rustcpp8metadataE]' has different size

This is a problem in the cpp crate, not in Qt.

cannot find -lmsvcrtd

This is even another problem i don't know what causes that.

@stuartZhang
Copy link
Author

@ogoffart In this evening, I shall attempt the combination of MSVC + QT. Perhaps, the fault originates from the mingw gcc.

@stuartZhang
Copy link
Author

@ogoffart Are there any of DLL dependencies whose names conflict with the built-in DLL files in Win32?

I have ever run across the analogous situation, when playing with [Gnome.GTK3 + Rust] (i.e. gtk-rs). In that case, the [zlib1.dll] was shadowed by c:\windows\system32\zlib1.dll. Due to the Windows-specific Safe DLL Search Mode, the zlib1.dll that I really expect can't always loaded.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 12, 2021

@ogoffart I have just made an experiment, following the below steps:

  1. Go to the directory "C:\Users\StuartZhang.cargo\registry\src" in which the downloaded crates dependencies reside.

  2. Find out the folder "cpp_build-0.5.6"

  3. Modify the rs file "src\lib.rs" (i.e. C:\Users\StuartZhang.cargo\registry\src\github.com-1ecc6299db9ec823\cpp_build-0.5.6\src\lib.rs)

    MetaData
    #ifdef __GNUC__
        __attribute__((weak))
    #elif _WIN32
        __declspec (selectany)
    #endif

    Here, I reversed the order of both if branches. That's to say, GNU takes precedence over WIN32.

  4. Go to the root folder of the example "todos"

  5. run cargo build

And then, the different error logs appeared as such:

  = note: H:\github_projects\qt_rs_todos\target\debug\deps\libqttypes-929376424a1dde2b.rlib(cpp_closures.o):cpp_closures.cpp:(.data$_ZN7rustcpp8metadataE+0x0): multiple definition of `.weak._ZN7rustcpp8metadataE._ZnwyPv'
          H:\github_projects\qt_rs_todos\target\debug\deps\libqmetaobject-e284a3ee801d53d3.rlib(cpp_closures.o):cpp_closures.cpp:(.data$_ZN7rustcpp8metadataE+0x0): first defined here
          H:/symbol_link_source/mingw64_qt/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrtd

In this case, the weak for GNU took effect (because of the log multiple definition of .weak._ZN7rustcpp8metadataE._ZnwyPv'), even though the build still failed.

As for the build error multiple definition of .weak._ZN7rustcpp8metadataE._ZnwyPv', I have discovered a post -
https://stackoverflow.com/questions/17646959/multple-c-files-causes-multiple-definition-error

I'm not aware of whether it's helpful for my issue or not?

I really want to enjoy the qmetaobject-rs in my windows box.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 20, 2021

@ratijas @ogoffart

Recently, I have just established a Virtual Machine [Ubuntu-20.04] where the compilation and running against the crate's todos example is perfect.

image

However, the target platform of my GUI application distribution is Windows-serial operation system. As a result, I had to also installed the following facilities for the cross compilation towards Windows 10 x64:

  1. sudo apt-get install mingw-w64
  2. rustup target add x86_64-pc-windows-gnu

After running the command cargo build --target=x86_64-pc-windows-gnu in the Ubuntu platform, I have been stuck in the same compilation error again. The cross compilation from Ubuntu to Windows can't bypass the issue.

  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.10mltcu9pb9c7e3l.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.133jram0m8w05lp1.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.14xp32555id1w02i.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.15g2g9v8xk37tmm9.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.17wa992qd7rpq9c4.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1aayaqhggwun1vty.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1daz30caeji31ba5.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1dpc4lujkexwq0bo.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1g2dnow4k8lh7hpj.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1ivx85qyrtfi2rtb.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1j771cbspeqhxqsc.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1lfw5jnuz83g7bgi.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1lxk25rytehzu2cy.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1p8yuale2rn9k8su.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1xp6o1dyditbr171.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1yikl52zhsq3488h.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.1z5dd3nsbpkqkdwq.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.20boff7lcbkd3jqn.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.21meir0y95tk1kli.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.22dnp93ky4vfrotj.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.234cs4gyga4irnfh.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2469ev27mb8e9cip.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.26veq5pxhixvtvev.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.26yc0vwy08ojr5h5.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.28g4zo3bok1bu35k.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.29xnrrebhyl2otph.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2cbkdkiuxj9lt155.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2e5gnv8p3uovhsat.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2h0a2v3vucb51tko.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2h0fwrn4w08dce3e.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2igfywaploxggy5d.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2l1o1zpxujmft308.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2py73lg8bhbp6w6p.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2r2cvvsf3nbldic3.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2sgq85w6jnubhr2l.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2sr5ut5rjamisghk.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2u4tbqy90b2um6ta.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2u9ie7k9wwzds0yv.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2zc3k3wel0kfu0ad.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.2zkpszmx8scwzi8u.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.356msce961xawqwi.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3bkx1cv6nv5ngdvn.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3d1us48cob9tb9wy.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3fxnhww7azx2w3u4.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3geb4sgm4nry2io.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3gustcaoloog1i22.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3icr8mwwrk4zf59c.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3ih0xvtzocqcjd6z.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3jpfcbf80nb6t06.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3krmbm0pqaue2fat.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3l7c469yd57undhy.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3mfzm5vjk80i56i5.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3pmc2re77niuo6ub.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3rkv824cj4qhibee.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3vucpd7nyibgk28d.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3wi24l82rtb6oylq.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.3wp8rwl1o5s7l8tp.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.41jqqd1gmkunat1t.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4287xozvzd65esh5.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.428a32x2sl84ok6q.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.46p4pk2l9la6j5wo.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.47928j8jrfeqacej.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.48uukgcghtn7p23h.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.49vhq9bc5quilhuz.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.49y35tun5ih4h5ll.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4a87b83xfpvbdjkz.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4d2253n8e8aink1p.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4ep3d2tjiym0fzh9.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4kw92510eyl3uooh.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4ltxg9ai5ief38lh.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4oqewgt0zj4dg9pd.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4pnm9g5j273g69op.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4pzb8xujy3788u1b.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4reklngfsvakxbmo.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4we16zt3ju0tgkgu.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4xwwm3u9zisebtj1.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4ymybixobwv39cyq.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.507xj6ifucqvl89g.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.546txn8flfvm6do.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.54kmciv7w5njm8y1.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.57qzouqjggu5dtho.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.5bnadevzd9erfqbu.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.5dk2ka6dbcmq1hhz.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.68dwk74i2nuorkn.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.a0rjqharki1lmkb.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.azjtwhkhzfgby8r.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.gvhaoosdbx9e5w9.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.h774pp6pu45rbr7.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.k1w54vfqtiknb4x.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.kegpiupnkixh7g8.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.ktrlsfcwnryeh9d.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.q3wau5ph9vz5g8o.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.q4ohyerl9qq586t.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.r000sdebr9dy96.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.r8kykln9jbdwc0g.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.rpitnjoderushkn.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.t4nt259sw8u1amo.rcgu.o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.xxq5j2tygopy1ab.rcgu.o" "-o" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.exe" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/todos-adb0e55ffe4809d3.4cu6npwbyv3oupxb.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps" "-L" "/mnt/h/github_projects/qt_rs_todos/target/debug/deps" "-L" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/build/qmetaobject-38e5bdad6fab85ee/out" "-L" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/build/qttypes-dd67352d82aa8f8f/out" "-L" "/home/stuart_zhang/Qt/5.12.11/gcc_64/lib" "-L" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-Wl,-Bstatic" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/libqmetaobject-3fd7179cda5fff18.rlib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/liblog-fad33701974adcb6.rlib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/libcfg_if-635d706ee5ef74ec.rlib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/libqttypes-3e40e5c454c5d489.rlib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/libcpp-e4c4df13ab703395.rlib" "/mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/liblazy_static-d6afe40954d6ad8a.rlib" "-Wl,--start-group" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-94f60f405c1748af.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libpanic_unwind-f56d3aec7c2576d9.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libobject-8e553c585536bfaf.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libaddr2line-3a82c272c5de0489.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libgimli-ef04c21117777245.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_demangle-b3ae962defb8b363.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libhashbrown-b441247297fa184b.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_alloc-19bb25a86d3a5b92.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libunwind-d7957714cc30050c.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcfg_if-abd7bd18212580be.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-80187982c9cf70bf.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-4172a25dd8c4f2de.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_core-27282989cc5b80d2.rlib" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-2f52c7ac303d5565.rlib" "-Wl,--end-group" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcompiler_builtins-2b00c29940bf9d8a.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lstdc++" "-lQt5Core" "-lQt5Gui" "-lQt5Widgets" "-lQt5Quick" "-lQt5Qml" "-ladvapi32" "-lws2_32" "-luserenv" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "/home/stuart_zhang/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsend.o"
  = note: /mnt/h/github_projects/qt_rs_todos/target/x86_64-pc-windows-gnu/debug/deps/libqttypes-3e40e5c454c5d489.rlib(cpp_closures.o): duplicate section `.data$_ZN7rustcpp8metadataE[_ZN7rustcpp8metadataE]' has different size
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lQt5Core
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lQt5Gui
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lQt5Widgets
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lQt5Quick
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lQt5Qml
          collect2: error: ld returned 1 exit status

I'd like to say that the Windows-serial operation system is ubiquitous and significant for any GUI toolkit. I anticipate that the issue will be resolved in future.

@ratijas
Copy link
Collaborator

ratijas commented Jun 21, 2021

Well, in case of cross-compilation from Ubuntu to Windows (mingw-w64) you are probably missing migw-w64 compiled Qt libraries, right? At least that's what error message says ("cannot find -lQt5Core" etc.). Have you installed required target's Qt libraries through Qt online installer? And don't forget to use its environment, like correct PATH for bundled tools (including qmake).

In case on Windows 64 to Windows 32 builds, I just installed through Qt online installer only required parts: Qt libs for mingw-32, CMake, Ninja, and ofc Qt Creator itself. Then I pushed paths to installed tools to the System/User's global PATH environment variable (because I don't care about other platforms, but normally you'd use some kind of bat for setting env similar to what qtenv2.bat does), and 2000 hours later it "just about" worked.

@stuartZhang
Copy link
Author

@ratijas the root reason of the compiling failure is as below:

image

It's analogous with the situation in the Windows platform.

@ratijas
Copy link
Collaborator

ratijas commented Jun 22, 2021

By the way, are you still using rust nightly toolchain from 2021-03-25? What about latest nightly or stable branch?

ogoffart added a commit to mystor/rust-cpp that referenced this issue Jun 22, 2021
To avoid duplicated metadata

This should help for woboq/qmetaobject-rs#150
@ogoffart
Copy link
Member

Commit mystor/rust-cpp@9433d1b should fix the duplicated rustcpp::metadata error.

Also, when cross compiling, one must make sure that one use the target Qt and not the host Qt: So for that you can set the QT_INCLUDE_PATH and QT_LIBRARY_PATH env variable when building

@stuartZhang
Copy link
Author

stuartZhang commented Jun 23, 2021

By the way, are you still using rust nightly toolchain from 2021-03-25? What about latest nightly or stable branch?

I put to use the rustup toolchain nightly-2021-03-25-x86_64-unknown-linux-gnu. I have ever encountered another error, when the latest nightly toolchain was taken advantage of.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 23, 2021

Commit mystor/rust-cpp@9433d1b should fix the duplicated rustcpp::metadata error.

Also, when cross compiling, one must make sure that one use the target Qt and not the host Qt: So for that you can set the QT_INCLUDE_PATH and QT_LIBRARY_PATH env variable when building

Great! Thanks. I am going to try it. Moreover, I have a question:

  • Do both QT_INCLUDE_PATH and QT_LIBRARY_PATH take precedence over both PATH and LD_LIBRARY_PATH?

De facto, I have already utilized both PATH and LD_LIBRARY_PATH against the host Qt:

export PATH="$HOME/Qt/5.12.11/gcc_64/bin:$PATH";
export LD_LIBRARY_PATH="$HOME/Qt/5.12.11/gcc_64/lib:$LD_LIBRARY_PATH";

@ratijas
Copy link
Collaborator

ratijas commented Jun 24, 2021

Interestingly enough, I have just encountered the same issue with a duplicate section. It is Windows-specific, and does not affect Linux builds (which is my main workstation, hence I didn't notice right away). Happened when building a static lib for later linking via CMake to other libs and executables.

I figured out, it doesn't happen with old qmetaobject v0.1.4. Probably because back then it was not split in different crates, thus it didn't have a duplicating section from separately compiled and linked object code?

Patch on cpp family of crates works like magic, so I suggest publishing new version to crates.io ASAP

[patch.crates-io]
cpp        = { path = "../rust-cpp/cpp" }
cpp_common = { path = "../rust-cpp/cpp_common" }
cpp_macros = { path = "../rust-cpp/cpp_macros" }
cpp_build  = { path = "../rust-cpp/cpp_build" }

But even after that, I'm now hit by a different one. Similar to yours, @stuartZhang , l started having problems while locating Qt libraries. And they got this weird d letter at the end of their names.

  = note: C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lmsvcrtd
          C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Cored
          C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Guid
          C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Widgetsd
          C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Quickd
          C:/Qt/Tools/mingw810_32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lQt5Qmld
          collect2.exe: error: ld returned 1 exit status

Something definitely went south in Windows land.

@ratijas
Copy link
Collaborator

ratijas commented Jun 24, 2021

cargo:rustc-link-lib=msvcrtd
cargo:rustc-link-search=C:/Qt/5.15.2/mingw81_32/lib
cargo:rustc-link-lib=Qt5Cored
cargo:rustc-link-lib=Qt5Guid
cargo:rustc-link-lib=Qt5Widgetsd
cargo:rustc-link-lib=Qt5Quickd
cargo:rustc-link-lib=Qt5Qmld

these lines are coming from qttypes build script output.

The letter d, in turn, is coming from these lines of qttypes/build.rs:

    let debug = std::env::var("DEBUG").ok().map_or(false, |s| s == "true");
    let windows_dbg_suffix = if debug && cfg!(target_os = "windows") {
        println!("cargo:rustc-link-lib=msvcrtd");
        "d"
    } else {
        ""
    };

It's supposed to use debug builds of libs, which I apparently didn't care to download.

Indeed, when compiling with cargo build --release flag, everything is alright and back to normal. Patching those "d"s away from the script fixes debug build as well.

  • I guess, Qt*d libs can be installed via Qt Online Installer / Maintenance Tool, but I don't see any such option in the list of available components. See below
  • But what about msvcrtd? Sounds like it should be shipped with Windows SDK or build tools or something, I don't know. Google has a lot of opinion on this matter, maybe worth checking out.
  • Also, why should it attempt to link with MSVC runtime at all, if I build with MinGW?

Just out of curiosity, I've installed Qt 5.15.2 for MSCV 2019, and... boom! Here they are, right in the C:\Qt\5.15.2\msvc2019\lib. Note those *.lib, *.prl, *d.lib and *d.prl quads per each lib.

Directory content
C:\QT\5.15.2\MSVC2019\LIB
│   libEGL.lib
│   libEGL.prl
│   libEGLd.lib
│   libEGLd.prl
│   libGLESv2.lib
│   libGLESv2.prl
│   libGLESv2d.lib
│   libGLESv2d.prl
│   Qt53DAnimation.lib
│   Qt53DAnimation.prl
│   Qt53DAnimationd.lib
│   Qt53DAnimationd.prl
│   Qt53DCore.lib
│   Qt53DCore.prl
│   Qt53DCored.lib
│   Qt53DCored.prl
│   Qt53DExtras.lib
│   Qt53DExtras.prl
│   Qt53DExtrasd.lib
│   Qt53DExtrasd.prl
│   Qt53DInput.lib
│   Qt53DInput.prl
│   Qt53DInputd.lib
│   Qt53DInputd.prl
│   Qt53DLogic.lib
│   Qt53DLogic.prl
│   Qt53DLogicd.lib
│   Qt53DLogicd.prl
│   Qt53DQuick.lib
│   Qt53DQuick.prl
│   Qt53DQuickAnimation.lib
│   Qt53DQuickAnimation.prl
│   Qt53DQuickAnimationd.lib
│   Qt53DQuickAnimationd.prl
│   Qt53DQuickd.lib
│   Qt53DQuickd.prl
│   Qt53DQuickExtras.lib
│   Qt53DQuickExtras.prl
│   Qt53DQuickExtrasd.lib
│   Qt53DQuickExtrasd.prl
│   Qt53DQuickInput.lib
│   Qt53DQuickInput.prl
│   Qt53DQuickInputd.lib
│   Qt53DQuickInputd.prl
│   Qt53DQuickRender.lib
│   Qt53DQuickRender.prl
│   Qt53DQuickRenderd.lib
│   Qt53DQuickRenderd.prl
│   Qt53DQuickScene2D.lib
│   Qt53DQuickScene2D.prl
│   Qt53DQuickScene2Dd.lib
│   Qt53DQuickScene2Dd.prl
│   Qt53DRender.lib
│   Qt53DRender.prl
│   Qt53DRenderd.lib
│   Qt53DRenderd.prl
│   Qt5AccessibilitySupport.lib
│   Qt5AccessibilitySupport.prl
│   Qt5AccessibilitySupportd.lib
│   Qt5AccessibilitySupportd.prl
│   Qt5AxBase.lib
│   Qt5AxBase.prl
│   Qt5AxBased.lib
│   Qt5AxBased.prl
│   Qt5AxContainer.lib
│   Qt5AxContainer.prl
│   Qt5AxContainerd.lib
│   Qt5AxContainerd.prl
│   Qt5AxServer.lib
│   Qt5AxServer.prl
│   Qt5AxServerd.lib
│   Qt5AxServerd.prl
│   Qt5Bluetooth.lib
│   Qt5Bluetooth.prl
│   Qt5Bluetoothd.lib
│   Qt5Bluetoothd.prl
│   Qt5Bootstrap.lib
│   Qt5Bootstrap.prl
│   Qt5Concurrent.lib
│   Qt5Concurrent.prl
│   Qt5Concurrentd.lib
│   Qt5Concurrentd.prl
│   Qt5Core.lib
│   Qt5Core.prl
│   Qt5Cored.lib
│   Qt5Cored.prl
│   Qt5DBus.lib
│   Qt5DBus.prl
│   Qt5DBusd.lib
│   Qt5DBusd.prl
│   Qt5Designer.lib
│   Qt5Designer.prl
│   Qt5DesignerComponents.lib
│   Qt5DesignerComponents.prl
│   Qt5DesignerComponentsd.lib
│   Qt5DesignerComponentsd.prl
│   Qt5Designerd.lib
│   Qt5Designerd.prl
│   Qt5DeviceDiscoverySupport.lib
│   Qt5DeviceDiscoverySupport.prl
│   Qt5DeviceDiscoverySupportd.lib
│   Qt5DeviceDiscoverySupportd.prl
│   Qt5EdidSupport.lib
│   Qt5EdidSupport.prl
│   Qt5EdidSupportd.lib
│   Qt5EdidSupportd.prl
│   Qt5EglSupport.lib
│   Qt5EglSupport.prl
│   Qt5EglSupportd.lib
│   Qt5EglSupportd.prl
│   Qt5EventDispatcherSupport.lib
│   Qt5EventDispatcherSupport.prl
│   Qt5EventDispatcherSupportd.lib
│   Qt5EventDispatcherSupportd.prl
│   Qt5FbSupport.lib
│   Qt5FbSupport.prl
│   Qt5FbSupportd.lib
│   Qt5FbSupportd.prl
│   Qt5FontDatabaseSupport.lib
│   Qt5FontDatabaseSupport.prl
│   Qt5FontDatabaseSupportd.lib
│   Qt5FontDatabaseSupportd.prl
│   Qt5Gamepad.lib
│   Qt5Gamepad.prl
│   Qt5Gamepadd.lib
│   Qt5Gamepadd.prl
│   Qt5Gui.lib
│   Qt5Gui.prl
│   Qt5Guid.lib
│   Qt5Guid.prl
│   Qt5Help.lib
│   Qt5Help.prl
│   Qt5Helpd.lib
│   Qt5Helpd.prl
│   Qt5Location.lib
│   Qt5Location.prl
│   Qt5Locationd.lib
│   Qt5Locationd.prl
│   Qt5Multimedia.lib
│   Qt5Multimedia.prl
│   Qt5Multimediad.lib
│   Qt5Multimediad.prl
│   Qt5MultimediaQuick.lib
│   Qt5MultimediaQuick.prl
│   Qt5MultimediaQuickd.lib
│   Qt5MultimediaQuickd.prl
│   Qt5MultimediaWidgets.lib
│   Qt5MultimediaWidgets.prl
│   Qt5MultimediaWidgetsd.lib
│   Qt5MultimediaWidgetsd.prl
│   Qt5Network.lib
│   Qt5Network.prl
│   Qt5NetworkAuth.lib
│   Qt5NetworkAuth.prl
│   Qt5NetworkAuthd.lib
│   Qt5NetworkAuthd.prl
│   Qt5Networkd.lib
│   Qt5Networkd.prl
│   Qt5Nfc.lib
│   Qt5Nfc.prl
│   Qt5Nfcd.lib
│   Qt5Nfcd.prl
│   Qt5OpenGL.lib
│   Qt5OpenGL.prl
│   Qt5OpenGLd.lib
│   Qt5OpenGLd.prl
│   Qt5OpenGLExtensions.lib
│   Qt5OpenGLExtensions.prl
│   Qt5OpenGLExtensionsd.lib
│   Qt5OpenGLExtensionsd.prl
│   Qt5PacketProtocol.lib
│   Qt5PacketProtocol.prl
│   Qt5PacketProtocold.lib
│   Qt5PacketProtocold.prl
│   Qt5PlatformCompositorSupport.lib
│   Qt5PlatformCompositorSupport.prl
│   Qt5PlatformCompositorSupportd.lib
│   Qt5PlatformCompositorSupportd.prl
│   Qt5Positioning.lib
│   Qt5Positioning.prl
│   Qt5Positioningd.lib
│   Qt5Positioningd.prl
│   Qt5PositioningQuick.lib
│   Qt5PositioningQuick.prl
│   Qt5PositioningQuickd.lib
│   Qt5PositioningQuickd.prl
│   Qt5PrintSupport.lib
│   Qt5PrintSupport.prl
│   Qt5PrintSupportd.lib
│   Qt5PrintSupportd.prl
│   Qt5Qml.lib
│   Qt5Qml.prl
│   Qt5Qmld.lib
│   Qt5Qmld.prl
│   Qt5QmlDebug.lib
│   Qt5QmlDebug.prl
│   Qt5QmlDebugd.lib
│   Qt5QmlDebugd.prl
│   Qt5QmlDevTools.lib
│   Qt5QmlDevTools.prl
│   Qt5QmlModels.lib
│   Qt5QmlModels.prl
│   Qt5QmlModelsd.lib
│   Qt5QmlModelsd.prl
│   Qt5QmlWorkerScript.lib
│   Qt5QmlWorkerScript.prl
│   Qt5QmlWorkerScriptd.lib
│   Qt5QmlWorkerScriptd.prl
│   Qt5Quick.lib
│   Qt5Quick.prl
│   Qt5QuickControls2.lib
│   Qt5QuickControls2.prl
│   Qt5QuickControls2d.lib
│   Qt5QuickControls2d.prl
│   Qt5Quickd.lib
│   Qt5Quickd.prl
│   Qt5QuickParticles.lib
│   Qt5QuickParticles.prl
│   Qt5QuickParticlesd.lib
│   Qt5QuickParticlesd.prl
│   Qt5QuickShapes.lib
│   Qt5QuickShapes.prl
│   Qt5QuickShapesd.lib
│   Qt5QuickShapesd.prl
│   Qt5QuickTemplates2.lib
│   Qt5QuickTemplates2.prl
│   Qt5QuickTemplates2d.lib
│   Qt5QuickTemplates2d.prl
│   Qt5QuickTest.lib
│   Qt5QuickTest.prl
│   Qt5QuickTestd.lib
│   Qt5QuickTestd.prl
│   Qt5QuickWidgets.lib
│   Qt5QuickWidgets.prl
│   Qt5QuickWidgetsd.lib
│   Qt5QuickWidgetsd.prl
│   Qt5RemoteObjects.lib
│   Qt5RemoteObjects.prl
│   Qt5RemoteObjectsd.lib
│   Qt5RemoteObjectsd.prl
│   Qt5Scxml.lib
│   Qt5Scxml.prl
│   Qt5Scxmld.lib
│   Qt5Scxmld.prl
│   Qt5Sensors.lib
│   Qt5Sensors.prl
│   Qt5Sensorsd.lib
│   Qt5Sensorsd.prl
│   Qt5SerialBus.lib
│   Qt5SerialBus.prl
│   Qt5SerialBusd.lib
│   Qt5SerialBusd.prl
│   Qt5SerialPort.lib
│   Qt5SerialPort.prl
│   Qt5SerialPortd.lib
│   Qt5SerialPortd.prl
│   Qt5Sql.lib
│   Qt5Sql.prl
│   Qt5Sqld.lib
│   Qt5Sqld.prl
│   Qt5Svg.lib
│   Qt5Svg.prl
│   Qt5Svgd.lib
│   Qt5Svgd.prl
│   Qt5Test.lib
│   Qt5Test.prl
│   Qt5Testd.lib
│   Qt5Testd.prl
│   Qt5TextToSpeech.lib
│   Qt5TextToSpeech.prl
│   Qt5TextToSpeechd.lib
│   Qt5TextToSpeechd.prl
│   Qt5ThemeSupport.lib
│   Qt5ThemeSupport.prl
│   Qt5ThemeSupportd.lib
│   Qt5ThemeSupportd.prl
│   Qt5UiTools.lib
│   Qt5UiTools.prl
│   Qt5UiToolsd.lib
│   Qt5UiToolsd.prl
│   Qt5VirtualKeyboard.lib
│   Qt5VirtualKeyboard.prl
│   Qt5VirtualKeyboardd.lib
│   Qt5VirtualKeyboardd.prl
│   Qt5VulkanSupport.lib
│   Qt5VulkanSupport.prl
│   Qt5VulkanSupportd.lib
│   Qt5VulkanSupportd.prl
│   Qt5WebChannel.lib
│   Qt5WebChannel.prl
│   Qt5WebChanneld.lib
│   Qt5WebChanneld.prl
│   Qt5WebSockets.lib
│   Qt5WebSockets.prl
│   Qt5WebSocketsd.lib
│   Qt5WebSocketsd.prl
│   Qt5WebView.lib
│   Qt5WebView.prl
│   Qt5WebViewd.lib
│   Qt5WebViewd.prl
│   Qt5Widgets.lib
│   Qt5Widgets.prl
│   Qt5Widgetsd.lib
│   Qt5Widgetsd.prl
│   Qt5WindowsUIAutomationSupport.lib
│   Qt5WindowsUIAutomationSupport.prl
│   Qt5WindowsUIAutomationSupportd.lib
│   Qt5WindowsUIAutomationSupportd.prl
│   Qt5WinExtras.lib
│   Qt5WinExtras.prl
│   Qt5WinExtrasd.lib
│   Qt5WinExtrasd.prl
│   Qt5Xml.lib
│   Qt5Xml.prl
│   Qt5Xmld.lib
│   Qt5Xmld.prl
│   Qt5XmlPatterns.lib
│   Qt5XmlPatterns.prl
│   Qt5XmlPatternsd.lib
│   Qt5XmlPatternsd.prl
│   qtfreetype.lib
│   qtfreetype.prl
│   qtfreetyped.lib
│   qtfreetyped.prl
│   qtlibpng.lib
│   qtlibpng.prl
│   qtlibpngd.lib
│   qtlibpngd.prl
│   qtmain.lib
│   qtmain.prl
│   qtmaind.lib
│   qtmaind.prl
...

So, to conclude, this is highly Window & MSVC compiler-specific stuff, which does not play well with MinGW. Probably worth fixing in qttypes. The only question is how to detect which toolchain is being used, and adapt accordingly.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 26, 2021

@ratijas In terms of the programmers' developing experience, both MSVC rustup toolchain and QT-MSVC lib are rarely the best choice, due to the lack of the breakpoint debugger. So, I honestly wish both GNU and MinGW become available for the Windows-hosted programmers.

@ratijas
Copy link
Collaborator

ratijas commented Jun 26, 2021

So, it supports separate debug builds of DLLs, but not the breakpoints? How weird. Well, whatever. I don't have neither MS Visual Studio nor MSVC compiler installed on my fresh Windows. Rustc uses GNU toolchain, and MinGW libs are provided by Qt Maintenance tool, which works perfectly fine together.

I assume, your compilation problems described in this thread are resolved by now? I'd like to close this issue, in favor of opening a new one regarding toolchain auto-detection by qttypes.

@ogoffart
Copy link
Member

The only question is how to detect which toolchain is being used, and adapt accordingly.

It is probably contained in one of the environment variable. Maybe TARGET

@ratijas
Copy link
Collaborator

ratijas commented Jun 26, 2021

I have extracted things related to MSVC linkage problems into its own issue. At this point it's already obvious how to fix it. I'll give it a shot right now. But what about CI which is broken anyway

@stuartZhang
Copy link
Author

stuartZhang commented Jun 26, 2021

@ratijas Ok. At least, I have the following chance, even though the rustup nightly channel is unavailable to the cross compilation.

  1. Develop the GUI application in Ubuntu-20.04 machine where the breakpoint debugger is usable.
  2. By virtue of the cross compilation, distribute a release build aiming at the Windows OS. Perhaps, I am capable of cargo build --release the source code in the Windows OS, instead of the cross compilation, because I prefer to the rustup nightly channel. I'm a genius.

When will the new version of this crate be published? I eagerly put it to use in my cross compilation.

@ratijas
Copy link
Collaborator

ratijas commented Jun 26, 2021

When will the new version of this crate be published? I eagerly put it to use in my cross compilation.

Here you go:

[patch.crates-io]
qttypes          = { git = "https://github.com/woboq/qmetaobject-rs" }
qmetaobject      = { git = "https://github.com/woboq/qmetaobject-rs" }
qmetaobject_impl = { git = "https://github.com/woboq/qmetaobject-rs" }

Alternatively, fork to your own repo with fixes, or clone locally and use path = "../qmetaobject-rs" instead of git = .

See rust-lang/cargo#9624 and https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html for more.

@stuartZhang
Copy link
Author

stuartZhang commented Jun 26, 2021

You are a genius too. @ratijas

ratijas added a commit that referenced this issue Jun 27, 2021
Simple cfg!(target_* = "...") doesn't work in build scripts the way it
does in crate's code, because build scripts are being compiled for the
toolchain's target triple -- not the default-host nor the cargo's
eventual target. Instead, such configuration should be loaded from
provided environment variables at run-time.

While initially trying to fix linkage issues for Windows + MinGW target
(first reported by @stuartZhang in #150), I came to realize in the
process that cfg!(target_os = ...), although being used only for OS X
at this moment, is likely screwed up in the same way (except, who would
ever cross-compile to or from Mac, and why?)

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Fixes #154
ogoffart pushed a commit that referenced this issue Jun 27, 2021
Simple cfg!(target_* = "...") doesn't work in build scripts the way it
does in crate's code, because build scripts are being compiled for the
toolchain's target triple -- not the default-host nor the cargo's
eventual target. Instead, such configuration should be loaded from
provided environment variables at run-time.

While initially trying to fix linkage issues for Windows + MinGW target
(first reported by @stuartZhang in #150), I came to realize in the
process that cfg!(target_os = ...), although being used only for OS X
at this moment, is likely screwed up in the same way (except, who would
ever cross-compile to or from Mac, and why?)

https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

Fixes #154
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

3 participants