Cargo-concordium for Windows

It appears that the link to cargo-concordium for Windows is broken or access is denied. I get a XML file in return saying that access is denied, much like a soap service response.

https://developer.concordium.software/en/testnet/net/installation/downloads.html#cargo-concordium

Ok, so now the link works and I get “cargo-concordium_1.0.0-2.exe”, but how exactly am I suppose to use this tool?
All I see it offers me is a command to get a help text (2 lines) and a command to get the version.

How is this used with VS Code and Rust? … What am I missing?

Hi petlan,

We appreciate your interest in Concordium’s smart contracts!

I’m not sure what happened regarding the link, but I’m glad it worked out.

You should rename cargo-concordium_1.0.0-2.exe to cargo-concordium.exe and make sure that it is on your PATH.
This can be achieved by either:

  1. Moving the executable to a folder that is already on your PATH, for example C:\Users\<your-username>\.cargo\bin\ (replacing <your-username> with your actual username).
  2. Or, by adding its current location to your PATH environment.

Once cargo-concordium.exe is on your path, you can invoke it with cargo concordium in the terminal.

You can read more about compiling smart contracts with cargo concordium in our documentation.

And I can recommend our Piggy Bank smart contract tutorial as a great initial resource to learn from.

Let us know if you have any further questions.

Have a great day,

/ Kasper

Thank you for explaining.
When you’re new to Rust in general, this part wasn’t really self explaining to me. My plan was indeed to try out the Piggy Bank tutorial.

I agree, this is not clear from the documentation either and will probably confuse more people in the future. We’ll add it to the smart contract tool installation guide.

Thanks for bringing this to our attention, and hope you’ll have a nice learning experience!

/Søren

I’m having problems with the Piggy Bank sample - the test in the tutorial won’t build when trying “cargo test” as described.

I get “error: linking with link.exe failed: exit code: 1169” and a whole lot of other text, but this is the overall error message.

Before adding the test to the library, it was building just fine though - as I recall.

UPDATE: I found that the compile doesn’t fail if I use “cargo concordium test”.
However that doesn’t seem to be the idea until I’m supposed to compile to wasm, as I understand it.
So it is still a problem that “cargo test” fails.

From what I can tell this error message is caused by multiple symbols with the same name. Is it possible that the name of your test collides with the name of another function?

Do you get the same error with cargo test on this version: https://github.com/Concordium/concordium-rust-smart-contracts/tree/main/examples/piggy-bank/part2?

Yeah it’s really odd, if I remove all tests from the code so I only have the piggy bank code itself, I get the error on “cargo build”… However, not on “cargo concordium build”.

On “cargo build” I get the following:

cargo build --verbose
       Fresh unicode-xid v0.2.2
       Fresh memory_units v0.4.0
       Fresh cfg-if v0.1.10
       Fresh concordium-contracts-common v0.4.0
       Fresh proc-macro2 v1.0.29
       Fresh quote v1.0.0
       Fresh winapi v0.3.9
       Fresh syn v1.0.77
       Fresh wee_alloc v0.4.5
       Fresh concordium-std-derive v0.5.0
       Fresh concordium-std v0.5.0
   Compiling piggy_bank v0.1.0 (C:\Users\Peter\projects\piggy_bank)
     Running `rustc --crate-name piggy_bank --edition=2018 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --crate-type rlib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=696701e15033e769 --out-dir C:\Users\Peter\projects\piggy_bank\target\debug\deps -C incremental=C:\Users\Peter\projects\piggy_bank\target\debug\incremental -L dependency=C:\Users\Peter\projects\piggy_bank\target\debug\deps --extern concordium_std=C:\Users\Peter\projects\piggy_bank\target\debug\deps\libconcordium_std-8bbfadcfb3e54c51.rlib`
error: linking with `link.exe` failed: exit code: 1169
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\Peter\\AppData\\Local\\Temp\\rustcziuNwb\\lib.def" "/NOLOGO" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.18hs9gjlj5ivludt.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.1iop6hsajh6pau5t.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.1q75vnbshqc7sz8g.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.1rujk0bvkeqa2pgd.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.253d41u836tb5f6n.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.2h9mckwoq6yfavxv.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.2tpaf0tuw0a7s9mx.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.3nkgp2gf647q3mfe.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.42efm3vhi9ms63dy.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.48fbjzofxf95ofnh.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.5dsxde6ys69zui5u.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.6amwbhjs0ovav1a.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.fzwszbprcdyv0sq.rcgu.o" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.kpni0kemhjeh6y7.rcgu.o" "/LIBPATH:C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libconcordium_std-8bbfadcfb3e54c51.rlib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libconcordium_contracts_common-1db2cf1df09b6912.rlib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libwee_alloc-e29de2f5483f3531.rlib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libwinapi-51f6bb9ad1f883c9.rlib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libmemory_units-086cd4ecfdb549f6.rlib" "C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\libcfg_if-e8d0e3aeffc180e3.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-3d786a338e3fbd3c.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-c7722f94ca812e0f.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-f6ac1aae8e3d5b95.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-8244d5c29082f380.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-c29ed8b388a545d6.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-daec0207219073db.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-e1164c8529217a2a.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-78991d36592dccee.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-3e2bb97c5be118b7.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-d5bd6400adb9fa95.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-07dcecfd1f459221.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-f0c150dc0abba70a.rlib" "C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-0f3806ca1d72c7be.rlib" "advapi32.lib" "cfgmgr32.lib" "kernel32.lib" "synchronization.lib" "user32.lib" "kernel32.lib" "ws2_32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.dll" "/OPT:REF,NOICF" "/DLL" "/IMPLIB:C:\\Users\\Peter\\projects\\piggy_bank\\target\\debug\\deps\\piggy_bank.dll.lib" "/DEBUG" "/NATVIS:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: ws2_32.lib(WS2_32.dll) : error LNK2005: send already defined in libconcordium_std-8bbfadcfb3e54c51.rlib(concordium_std-8bbfadcfb3e54c51.concordium_std.61efhuco-cgu.1.rcgu.o)
          ws2_32.lib(WS2_32.dll) : error LNK2005: accept already defined in libconcordium_std-8bbfadcfb3e54c51.rlib(concordium_std-8bbfadcfb3e54c51.concordium_std.61efhuco-cgu.1.rcgu.o)
             Creating library C:\Users\Peter\projects\piggy_bank\target\debug\deps\piggy_bank.dll.lib and object C:\Users\Peter\projects\piggy_bank\target\debug\deps\piggy_bank.dll.exp
          C:\Users\Peter\projects\piggy_bank\target\debug\deps\piggy_bank.dll : fatal error LNK1169: one or more multiply defined symbols found


error: aborting due to previous error

error: could not compile `piggy_bank`

Caused by:
  process didn't exit successfully: `rustc --crate-name piggy_bank --edition=2018 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --crate-type rlib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=696701e15033e769 --out-dir C:\Users\Peter\projects\piggy_bank\target\debug\deps -C incremental=C:\Users\Peter\projects\piggy_bank\target\debug\incremental -L dependency=C:\Users\Peter\projects\piggy_bank\target\debug\deps --extern concordium_std=C:\Users\Peter\projects\piggy_bank\target\debug\deps\libconcordium_std-8bbfadcfb3e54c51.rlib` (exit code: 1)

My Cargo.toml also looks different though (I just followed the tutorial), maybe that has something to do with it?

Cargo.toml

[package]
    name = "piggy_bank"
    version = "0.1.0"
    edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
concordium-std = "0.5"

There are 3 read exclamation signs on the right side of “concordium-std = 0.5”… Something about “git” which I don’t use.

Hi petlan,

I am not certain why you are experiencing this issue, however, here are some things you can try.

Please let us know what the outcome is.

All the best
/ Kasper

That seemed to fix the problem - not that I’m sure what the first line does exactly. Apparently some Rust stuff was uninstalled because VS Code wanted to install some Rust specifics when I tried to use the online samples. I didn’t take everything from the online samples though, just the lib.rs content.

I tried to create 2 libs, one with and one without the tests and they both build now. Here is the output from building the one including the tests.

warning: panic message is not a string literal
   --> src\lib.rs:100:9
|
100 | /         claim_eq!(
101 | |             state,
102 | |             PiggyBankState::Intact,
103 | |             "Piggy bank state should be intact after initialization."
104 | |         );
| |__________^
|
= note: `#[warn(non_fmt_panics)]` on by default
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:120:9
|
120 |         claim_eq!(actions, ActionsTree::accept(), "No action should be produced.");
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:121:9
|
121 |         claim_eq!(state, PiggyBankState::Intact, "Piggy bank state should still be intact.");
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:135:9
|
135 |         claim!(actions_result.is_err(), "Should failed when piggy bank is smashed.");
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:157:9
|
157 |         claim_eq!(actions, ActionsTree::simple_transfer(&owner, balance));
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:158:9
|
158 |         claim_eq!(state, PiggyBankState::Smashed);
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:179:9
|
179 |         claim_eq!(err, SmashError::NotOwner, "Expected to fail with error NotOwner")
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
   --> src\lib.rs:199:9
|
199 |         claim_eq!(err, SmashError::AlreadySmashed, "Expected  to fail with error AlreadySmashed")
|         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: this warning originates in the macro `$crate::fail` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: `piggy_bank3` (lib test) generated 8 warnings
Finished test [unoptimized + debuginfo] target(s) in 1.76s
 Running unittests (target\debug\deps\piggy_bank3-c8e6d63a271fb3bd.exe)

running 6 tests
test tests::test_init ... ok
test tests::test_insert_intact ... ok
test tests::test_insert_smashed ... ok
test tests::test_smash_intact ... ok
test tests::test_smash_intact_not_owner ... ok
test tests::test_smash_smashed ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Hi petlan,

That’s great to hear!
Thanks for letting us know about the warnings.
We’ll make sure to update our claim_eq implementation when it becomes relevant.

Have a great day :blush:

/ Kasper