go-dht icon indicating copy to clipboard operation
go-dht copied to clipboard

Installation failure on macOS

Open limoli opened this issue 6 years ago • 16 comments

As documentation, I executed: go get -u github.com/d2r2/go-dht

# github.com/d2r2/go-dht
In file included from ../../go/src/github.com/d2r2/go-dht/dht.go:3:
../../go/src/github.com/d2r2/go-dht/dht.go.h:304:15: warning: implicit declaration of function 'sched_setscheduler' is invalid in C99 [-Wimplicit-function-declaration]
# github.com/d2r2/go-dht
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)

limoli avatar Jun 30 '18 09:06 limoli

Hi @Limoli! Could you clarify what hardware and OS you use to download and compile package? Just it seems you have CLANG compiler installed only, but I test it with GCC compiler on Linux OS.

Additional assumption you need to install ld tool (GNU linker from "binutils" installation distributive). I will try to test compiling without GCC in virtual environment a little later.

Sorry for late response.

d2r2 avatar Oct 02 '18 10:10 d2r2

same issue on mac os mojave

$ go get -u github.com/d2r2/go-dht ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) In file included from ../../d2r2/go-dht/dht.go:3: ../../d2r2/go-dht/dht.go.h:304:15: warning: implicit declaration of function 'sched_setscheduler' is invalid in C99 [-Wimplicit-function-declaration] ../../d2r2/go-dht/dht.go.h:317:15: warning: implicit declaration of function 'sched_setscheduler' is invalid in C99 [-Wimplicit-function-declaration]

ghost avatar Oct 12 '18 20:10 ghost

Could you clarify, why you are trying to compile this library directly on MacOS? This library is intended to compile and use on embedded Linux devices, like Raspberry PI, Orange PI, Banana PI and so on.

d2r2 avatar Oct 19 '18 04:10 d2r2

Using go cross compilation for arm-6, linux. Idea was to deploy already executable item to raspberry pi.

ghost avatar Oct 19 '18 22:10 ghost

Hi @darkowl91! Could you try again to get latest d2r2/go-dht and cross compile it? Just recently I have added a fix for macOS. P.S. I'm not sure that cross compilation will work from macOS, but lets try...

d2r2 avatar Nov 05 '18 11:11 d2r2

@d2r2 THe latest fix for macOS is not working . Just informing. As i am also gettgint he same error as @darkowl91

pradyuz3rocool avatar Dec 03 '18 11:12 pradyuz3rocool

Hi @pradyuz3rocool! Could you attach here compilation output with error from macOS?

d2r2 avatar Dec 03 '18 17:12 d2r2

apple@iSteers-MacBook-Pro-Pradyu ~ $ go get -u github.com/d2r2/go-dht
# github.com/d2r2/go-dht
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/d2r2/go-dht
In file included from go-workspace/src/github.com/d2r2/go-dht/dht.go:24:
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:428:10: warning: "Darwin doesn't have sched_setscheduler, so parameter boostPerfFlag is useless on Apple devices" [-W#warnings]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:434:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:440:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:446:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:454:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:462:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:470:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]
go-workspace/src/github.com/d2r2/go-dht/dht.go.h:475:9: warning: implicit declaration of function 'set_default_priority' is invalid in C99 [-Wimplicit-function-declaration]

pradyuz3rocool avatar Dec 03 '18 17:12 pradyuz3rocool

@pradyuz3rocool, thank you for reporting that issue still present! Main problem is that unfortunately I have no macOS system in my hands. I do all my development on Arch Linux system either directly on Raspberry PI linux. So, in both cases everything works great, but I have no chance to build DHT library on macOS. I will try to get in my hands macOS, but I don’t promise to do it quickly :(

Until this problem is fixed, my advice is to compile directly on Raspberry PI device, or any corresponding clones.

d2r2 avatar Dec 03 '18 18:12 d2r2

Thanks @d2r2 I myself work on Arch, but i was trying the same implementation on macOS, i was facing this issue. But Would love to make it generic. I will also look into the fix in the mean while.

pradyuz3rocool avatar Dec 03 '18 18:12 pradyuz3rocool

@pradyuz3rocool, I thought we have two concerns about macOS:

  1. macOS has no sched_setscheduler() function. So that's why I put calls of set_max_priority() and set_default_priority() in #ifdef block like:
    #if !defined(__APPLE__)
    ...
    #endif

But as I see, I forget to do this with bunch of set_default_priority()calls - you can fix it.

  1. I don't know what to do with error ld: library not found for -lrt and since linux use gcc compiler (macOS - clang), you should try to find approach how to modify this in dht.go:
// #include "dht.go.h"
// #cgo LDFLAGS: -lrt

to make it working on both systems.

Try and give me reply how it's going.

d2r2 avatar Dec 03 '18 18:12 d2r2

Sure 👍 will look into it

pradyuz3rocool avatar Dec 03 '18 18:12 pradyuz3rocool

@pradyuz3rocool any luck with this ?

ghost avatar Mar 05 '19 15:03 ghost

Was able to build on mac with the following settings

#export GOARM=6 GOARCH=arm GOOS=linux CGO_ENABLED=1
#env CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \
#    CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 \

ghost avatar Mar 14 '19 15:03 ghost

@darkowl91, in this case compile line for mac OS will looks like:

CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 go build ...

Is it correct?

d2r2 avatar Mar 16 '19 04:03 d2r2

yes

ghost avatar Feb 16 '20 10:02 ghost