Can't compile on Mac OS X 10.9.5
NelsonMinar opened this issue · 2 comments
nq sounds neat! Saw it on One Thing Well.
I don't have a need for this right now but I thought I'd report that it didn't build on my Mac OS X 10.9.5 machine (ie, Mavericks) using Apple's compiler. I think Mac's libc doesn't have fdopendir
, openat
, or renameat
. If I were more serious about making this work, I'd see if Homebrew has whatever is missing.
$ cc -g -Wall nq.c -v
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name nq.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -gdwarf-2 -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0 -Wall -fdebug-compilation-dir /tmp/nq -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/0j/nf7gs_917ss0cdldlygvnb600000gn/T/nq-77bc70.o -x c nq.c
clang -cc1 version 6.0 based upon LLVM 3.5svn default target x86_64-apple-darwin13.4.0
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
nq.c:175:12: warning: implicit declaration of function 'openat' is invalid in
C99 [-Wimplicit-function-declaration]
lockfd = openat(dirfd, lockfile, O_RDWR | O_APPEND);
^
nq.c:210:2: warning: implicit declaration of function 'renameat' is invalid in
C99 [-Wimplicit-function-declaration]
renameat(dirfd, lockfile, dirfd, lockfile+1);
^
nq.c:243:9: warning: implicit declaration of function 'fdopendir' is invalid in
C99 [-Wimplicit-function-declaration]
dir = fdopendir(dirfd);
^
nq.c:243:7: warning: incompatible integer to pointer conversion assigning to
'DIR *' from 'int' [-Wint-conversion]
dir = fdopendir(dirfd);
^ ~~~~~~~~~~~~~~~~
4 warnings generated.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/folders/0j/nf7gs_917ss0cdldlygvnb600000gn/T/nq-77bc70.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"_fdopendir", referenced from:
_main in nq-77bc70.o
"_openat", referenced from:
_main in nq-77bc70.o
"_renameat", referenced from:
_main in nq-77bc70.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
One would think 5 years are enough to implement POSIX 2008...
Unfortunately, replacing openat in nq is subtle and requires more string processing, which I'd rather avoid.
I can tell you it works on 10.10. ;)
Ah, working on 10.10 is interesting. Like I said I don't have a pressing need for nq
on my Mac, so I'm going to close this issue so as not to waste your time. Thanks again!