Strange cmder behavior

I just started with Go and generally I am new in programming.
I noticed a strange behavior of cmder bash session when I run a compiled to exe Go program.
I put the program into the Windows folder.
It just calculate an md5sum of a text. The command line argument is the text.
When I run the program by cmd or cmder/cmd session it runs as expected.
If I run it by cmder/bash session the system tells me that there is no such file or directory. It takes the argument as a path.
Why is that? I am asking because it’s more convenient for me to use bash syntax.

2 Likes

Sounds like a build architecture problem. As far as I understand:

  1. the compiled binary is for windows/amd64 (I’m assuming you’re operating on Windows)
  2. cmder/bash should be operating in unix architecture, which also means there are a lot of architecture to choose from. (Suggest linux/amd64).
  3. cmd is operating on Windows architecture, therefore, the existing binary works.

Try cross-compile into linux/amd64 and use cmder/bash to find the new binary. You need to export GOARCH=linux/amd64.

I previously wrote a guide here: https://sites.google.com/view/chewkeanho/guides/go/build. However, I did no have the command line for Windows to cross-compile. You might need to explore a bit.

Keywords: cross-compile, GOARCH


NOTE: I may be wrong since there is limited information available from your question.

1 Like

I’m not sure if I understand you correctly… What do you mean by “I put the program into the Windows folder”? Are you talking about C:\Windows here? Please remove it there, thats the OS’ space and shouldn’t be touched by you.

From what you describe otherwise, it seems to be a discrepancy in PATH between both environments. Usually bash will inherit the PATH of the parent environment (windows system in your case), at least if you are using a bash from a POSIX compatibility layer as cygwin or “git for windows”. You might have overwritten it in the .bashrc then though.

If though you use the WSL-bash then it has its own environment and does not inherit from windows at all, as it is a “real” linux and wouldn’t be able to run windows binaries anyway.

2 Likes

These works is more simple on mac or linux. Did you try these platforms?

2 Likes

Even though I’d always prefer Linux over windows or macOS, proposing to use a different operating system is not the solution to the problem at hand.

In fact the problem seems to be that the user doesn’t understand how different tools on their computer work together. This problem can happen on every operating system and is not unique to windows.

3 Likes

let’s wait for OP to supply more information. Otherwise, it’s hard to tell where went wrong.

1 Like

I’m not quite sure what information to provide. I’m using Windows 10 x64 right now. I am planing to install a Linux system but on a separate hard disk. Which I have to buy. I prefer Linux but have to work on Windows.

I didn’t touch .bashrc or any other configuration. I installed WLS yesterday and I could use that eventually. As soon as I know how to access the computer’s folders and the files.

Quick research gives me that C drive is located in /mnt . So obvious that I even didn’t think about it :smiley:

2 Likes

Noted, keep in mind that Go program requires you to cross-compile to the deployment OS.

As far as I understand, WLS is a different system. You need to compile to linux/amd64 and give it a try.

1 Like

I will remember that. Thank you.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.