GoClipse / goclipse

Eclipse IDE for the Go programming language:
http://goclipse.github.io/
Eclipse Public License 1.0
841 stars 290 forks source link

Executable file doesn't exist #236

Open AlvinAlvin82 opened 7 years ago

AlvinAlvin82 commented 7 years ago

i'm new to Go and GoClipse and i'm not able to compile a simple "hello World" on my linux machine. Here is my configuration:

On Windows->Preferences->Go:

On Windows->Preferences->Go->tools:

The output of go envis:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/lib/go-1.7"
GOTOOLDIR="/usr/lib/go-1.7/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build306567185=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

I've tried t compile the following "hello world" code

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

But i have this error message:

Executable file (/root/workspace/Test/bin/Test) doesnt exist.

What's wrong? How can i configure eclipse properly? Thanks

bruno-medeiros commented 7 years ago

What's the output of the Go build console when you build your project? The build console looks like this: image

With your GOPATH setting, the executable should have been outputted to /root/go/bin/Test

shadow1163 commented 7 years ago

I also met same problem, I can't understand why the executable outputted to system variable "GOBIN".

AlvinAlvin82 commented 7 years ago

Which error do you have? Are you using Eclipse on Linux? Did you have installed Go with apt install? You should configure the path in your eclipse project

shadow1163 commented 7 years ago

The error is "Executable file does not exists", I have install Golang, Eclipse on my windows machine. Maybe I should change default build command to solve the problem.

AlvinAlvin82 commented 7 years ago

I'm using eclipse on linux, but the problem is the same. Try this:

  1. Create an "hello world" go project in eclipse
  2. Right click on your folder project and then click on Properties
  3. Go Compiler-> Go Installation
  4. Set the folder where your Go binaries are installed
  5. Then build and run you project
ghost commented 6 years ago

I managed to find the issue, It is no configuration issue or anything. You have to do 3 things as follows,

1) Make sure GOPATH value is different from GOROOT. 2) Make sure GOBIN value is empty. 3) Your package name on the go file in eclipse should be main and not the package name "hello". This should be the case for at least the file that has main function. To do this, File->New go file->Source file type should be -> Command source file-> Empty main function. Then type your code after which you can build to see the the .exe file in GOPATH/bin and the program run.

Worked for me.