rust 使用fltk 的小问题

rust 使用fltk 的小问题

    • windowns下进行编译
    • 使用cargo build --release 打包出现以下问题

最近有需求写一个简单的桌面应用程序,正好使用rust来练练手,中间碰到一些问题,尤其fltk 打包有个cmd黑框就很恶心。只记录一些国内网络上资料较少的问题,有问题欢迎大家指出,如有转载请注明出处。

windowns下进行编译

win10 下进行编译时会出现一些报错,碰到这种情况的话有很多资料显示执行以下代码。如果提示你装vs不要挣扎直接装一个。

rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu

注意使用以上模式会出现下面报错,不要使用gnu模式在windowns上面执行,gnu在windowns平台上面的支持不是很友好,使用msvc模式

rustup toolchain install stable-x86_64-pc-windows-msvc
rustup default stable-x86_64-pc-windows-msvc
cargo run
   Compiling os-gui v0.1.0 (E:\code\rust\os-gui)
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\rustcpTJrAM\\symbols.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.1azqfce5lx4sambd.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.1esf92alsev40t7t.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.23oarcdfam8vav7x.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.2gmnyt2m1gxmcpct.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.3f18umh4ebjvfqaa.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.3satt6gwnrb8yjvd.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.408236gaslckzz1r.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.409g7dxqoaxuv3b.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.43a1kr0p1jpq6ib1.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.45rboiqcj5kkcc7u.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.4695qzhrqc9pkzj7.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.49dwrr32c9bgekjv.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.4fttbblusecbja0v.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.4o8fcbfuvqsmfgge.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.4pnqk5p4ik4w4tyv.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.4tlu8yckkp3hdtn6.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.f545xlx1t8jeuhf.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.lbua4hb236sohdb.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.r0i49jliojpoby9.rcgu.o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.3189ch52cu0ceqv.rcgu.o" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\deps" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\build" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\build\\Release" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\lib" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\lib64" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\lib\\Release" "-L" "E:\\code\\rust\\os-gui\\target\\debug\\build\\fltk-sys-ac04a369c112a785\\out\\lib64\\Release" "-L" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libfltk-39d5e4c9087707a1.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libttf_parser-abb5e7d9e5584d79.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libcrossbeam_channel-bd95ba3f2ef73d9a.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libcrossbeam_utils-88487f692bdae9f2.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libcfg_if-d665f346d3258780.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libbitflags-e33b042289ec88bb.rlib" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\libfltk_sys-901c089775d8797c.rlib" "-Wl,--start-group" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-fefff10efd686913.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-9c45725c63c0d5ed.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-5e1c5cd9ff1eb7cc.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-b6bf783b1c783d10.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-2241249e06c7cb40.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-03ustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-8931bc6a2b527206.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\be248c77f2f0b.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-9148e9af213d2829.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-47941ef50057df8b.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-66b0ea2785827b9a.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-4b65aaa3f0b095f9.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-04a1f133ddb50e5e.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-f67804e146a91ffe.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-a5cbd3ad9e3068dd.rlib" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-4bc25ea8e4535542.rlib" "-Wl,--end-group" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-ac0b598a973ccaf7.rlib" "-Wl,-Bdynamic" "-lws2_32" "-lcomctl32" "-lgdi32" "-loleaut32" "-lole32" "-luuid" "-lshell32" "-ladvapi32" "-lcomdlg32" "-lwinspool" "-luser32" "-lkernel32" "-lodbc32" "-lgdiplus" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nostartfiles" "-L" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained" "-o" "E:\\code\\rust\\os-gui\\target\\debug\\deps\\os_gui-8040208486793bb6.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\Administrator\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: ld: cannot find -lgdiplus


error: could not compile `os-gui` due to previous error

使用cargo build --release 打包出现以下问题

win10下,我们需要正常打包出一个应用程序,但出现了一个cmd黑框,看着就很难受,解决以下问题使用以下命令

cargo rustc --release -- -Clink-args="/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"

rust 使用fltk 的小问题_第1张图片

你可能感兴趣的:(rust,fltk,rust,开发语言,后端)