Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation failure on macOS #11

Open
limoli opened this issue Jun 30, 2018 · 16 comments
Open

Installation failure on macOS #11

limoli opened this issue Jun 30, 2018 · 16 comments

Comments

@limoli
Copy link

limoli commented Jun 30, 2018

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)
@d2r2
Copy link
Owner

d2r2 commented Oct 2, 2018

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.

@ghost
Copy link

ghost commented Oct 12, 2018

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]

@d2r2
Copy link
Owner

d2r2 commented Oct 19, 2018

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.

@ghost
Copy link

ghost commented Oct 19, 2018

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

@d2r2
Copy link
Owner

d2r2 commented Nov 5, 2018

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...

@pradyuz3rocool
Copy link

pradyuz3rocool commented Dec 3, 2018

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

@d2r2
Copy link
Owner

d2r2 commented Dec 3, 2018

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

@pradyuz3rocool
Copy link

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]

@d2r2
Copy link
Owner

d2r2 commented Dec 3, 2018

@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 d2r2 changed the title Installation failure Installation failure on macOS Dec 3, 2018
@pradyuz3rocool
Copy link

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.

@d2r2
Copy link
Owner

d2r2 commented Dec 3, 2018

@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.

@pradyuz3rocool
Copy link

Sure 👍
will look into it

@ghost
Copy link

ghost commented Mar 5, 2019

@pradyuz3rocool any luck with this ?

@ghost
Copy link

ghost commented Mar 14, 2019

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 \

@d2r2
Copy link
Owner

d2r2 commented Mar 16, 2019

@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?

@ghost
Copy link

ghost commented Feb 16, 2020

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants