hmgle / graftcp

A flexible tool for redirecting a given program's TCP traffic to SOCKS5 or HTTP proxy.
GNU General Public License v3.0
2.14k stars 179 forks source link

runtime.main_main·f: function main is undeclared in the main package #39

Closed hongyi-zhao closed 3 years ago

hongyi-zhao commented 3 years ago

On Ubuntu 20.04, I try to compile the git master version of graftcp, but meet the following messages:

$ make
cc -Wall -O2 -DNDEBUG -DVERSION=\"v0.4.0-2-ge6daf52\" -c -o main.o main.c
cc -Wall -O2 -DNDEBUG -DVERSION=\"v0.4.0-2-ge6daf52\" -c -o graftcp.o graftcp.c
cc -Wall -O2 -DNDEBUG -DVERSION=\"v0.4.0-2-ge6daf52\" -c -o util.o util.c
cc -Wall -O2 -DNDEBUG -DVERSION=\"v0.4.0-2-ge6daf52\" -c -o string-set.o string-set.c
cc main.o graftcp.o util.o string-set.o -o graftcp
make -C local VERSION=v0.4.0-2-ge6daf52
make[1]: Entering directory '/home/werner/Public/repo/github.com/hmgle/graftcp.git/local'
go build -ldflags "-s -w -X main.version=v0.4.0-2-ge6daf52" ./cmd/graftcp-local
make -C .. libgraftcp.a
make[2]: Entering directory '/home/werner/Public/repo/github.com/hmgle/graftcp.git'
ar rcs libgraftcp.a graftcp.o util.o string-set.o
make[2]: Leaving directory '/home/werner/Public/repo/github.com/hmgle/graftcp.git'
go build -ldflags "-s -w -X main.version=v0.4.0-2-ge6daf52" ./cmd/mgraftcp
# github.com/hmgle/graftcp/local/cmd/mgraftcp
runtime.main_main·f: function main is undeclared in the main package
make[1]: *** [Makefile:18: mgraftcp] Error 2
make[1]: Leaving directory '/home/werner/Public/repo/github.com/hmgle/graftcp.git/local'
make: *** [Makefile:61: local/graftcp-local] Error 2

Any hints for this problem?

Regards, HY

hmgle commented 3 years ago

It looks like your CGO_ENABLED is set to 0. Check the CGO_ENABLED: go env | grep CGO_ENABLED and set to 1.

hongyi-zhao commented 3 years ago

Check the CGO_ENABLED: go env | grep CGO_ENABLED and set to 1.

$ go env | grep CGO_ENABLED
CGO_ENABLED="0"

Thank you very much. The following method can solve this problem:

$ CGO_ENABLED=1 make