HPCE / hpce-2017-cw5

1 stars 6 forks source link

Makefile: make all on MacOS - "library not found for -lrt" #8

Closed aDu closed 6 years ago

aDu commented 6 years ago

On my Mac, I run make all, then I get the following error:

$ make all 
mkdir -p bin
c++ -std=c++11 -W -Wall  -g -O3 -I include -o bin/execute_puzzle src/execute_puzzle.cpp lib/libpuzzler.a  -lrt -Llib -lpuzzler
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bin/execute_puzzle] Error 1

I searched the error online and some sources say that Mac doesn't support lrt.

Makefile:

ifeq ($(OS),Windows_NT)
LDLIBS += -lws2_32
else
LDLIBS += -lrt
endif

Although, if I remove the line with LDLIBS += -lrt then it compiles on my Mac. I was wondering if anyone else was experiencing similar problems?

m8pple commented 6 years ago

I'm afraid I don't have a mac to run this on, so I'll need someone with a Mac to suggest a fix.

My guess would be something like:

ifeq ($(OS),Windows_NT)
LDLIBS += -lws2_32
else ifeq($(OS),MachOS)
# Nothing
else
LDLIBS += -lrt
endif

But I don't know what the magic environment variable is.

aDu commented 6 years ago

Thanks for the update, I have made an environment $(OS) variable on my Mac to fix this for my personal use.

I did found another solution though: https://stackoverflow.com/questions/714100/os-detecting-makefile