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

Building Error On MacOS #2

Open
MFaisalZaki opened this issue Jul 22, 2021 · 12 comments
Open

Building Error On MacOS #2

MFaisalZaki opened this issue Jul 22, 2021 · 12 comments

Comments

@MFaisalZaki
Copy link

MFaisalZaki commented Jul 22, 2021

Hello,

I am trying to build pandaPIgrounder on my macOS machine and it fails when building boruvka, I have followed the building steps as mentioned yet I got this error:

/Applications/Xcode.app/Contents/Developer/usr/bin/make CC="cc" DEBUG=no -C third-party/boruvka all
cc -O3 -Wall -pedantic -std=gnu99 -ffast-math -I. -c -o .objs/fifo-sem.o src/fifo-sem.c
src/fifo-sem.c:30:9: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
    if (sem_init(&fifo->full, 0, 0) != 0){
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:42: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
                                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:196:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
src/fifo-sem.c:35:9: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
    if (sem_init(&fifo->empty, 0, SEM_VALUE_MAX) != 0){
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:55:42: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
                                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:196:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
src/fifo-sem.c:86:5: warning: 'sem_destroy' is deprecated [-Wdeprecated-declarations]
    sem_destroy(&fifo->full);
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:53:26: note: 'sem_destroy' has been explicitly marked deprecated here
int sem_destroy(sem_t *) __deprecated;
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:196:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
src/fifo-sem.c:87:5: warning: 'sem_destroy' is deprecated [-Wdeprecated-declarations]
    sem_destroy(&fifo->empty);
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:53:26: note: 'sem_destroy' has been explicitly marked deprecated here
int sem_destroy(sem_t *) __deprecated;
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:196:40: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((__deprecated__))
                                       ^
src/fifo-sem.c:164:9: error: implicit declaration of function 'sem_timedwait' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (sem_timedwait(&fifo->full, &tm) != 0)
        ^
src/fifo-sem.c:164:9: note: did you mean 'sem_trywait'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/semaphore.h:58:5: note: 'sem_trywait' declared here
int sem_trywait(sem_t *);
    ^
4 warnings and 1 error generated.
make[1]: *** [.objs/fifo-sem.o] Error 1
make: *** [boruvka] Error 2

Please help me if possible.

@galvusdamor
Copy link
Collaborator

Boruvka is an external library we use. It was written by Daniel Fiser. The main repo of the boruvka project can be found here.
https://gitlab.com/danfis/boruvka

Note that the actual error is this one
src/fifo-sem.c:164:9: error: implicit declaration of function 'sem_timedwait' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (sem_timedwait(&fifo->full, &tm) != 0)
I would recommend to open an issue for this compilation problem in boruvka's main repo - if the error can be reproduced in a checkout of the main project.

@Badru45
Copy link

Badru45 commented Apr 20, 2023

Is this issue solved ? even I am facing same issue on my Mac.

@galvusdamor
Copy link
Collaborator

I am not aware that it has been. @MFaisalZaki has not opened an issue on the repo of Boruvka - which would need to be fixed for this issue to be resolved.

My assumption is that the default C++ version the compiler is using under Mac is older (C99) than the one used by Linux and Windows compilers which causes this problem. One way to solve this is to locally add a flag to the compiler that forces the use of a newer C++ version.

One proposal is this one:
#1

@Badru45 Does this fix your problem?

@galvusdamor galvusdamor reopened this Apr 20, 2023
@rpgoldman
Copy link

I am able to get past this build error on MacOS with Homebrew as follows:

CC=/opt/homebrew/opt/gcc/bin/gcc-13 make boruvka opts bliss lpsolve

...but I still am not able to build successfully. I will open an issue for my new error, which may be due to boruvka requiring boost...

@galvusdamor
Copy link
Collaborator

galvusdamor commented Jul 26, 2023

I have added auto-dection of MacOS X to the makefile for cpddl and the grounder itself. As for the pandaPIengine, I have added the path to gcc-13 and g++-12 in the homebrew directory as the default and used @rpgoldman's patch to allow for a manual override in the pandaPIgrounder itself.
For cpddl, I had to add another patch to fix its makefile as it is a submodule.

Does this make compilation easier under MaxOSX?

@rpgoldman
Copy link

I have added auto-dection of MacOS X to the makefile for cpddl and the grounder itself. As for the pandaPIengine, I have added the path to gcc-13 and g++-12 in the homebrew directory as the default and used @rpgoldman's patch to allow for a manual override in the pandaPIgrounder itself. For cpddl, I had to add another patch to fix its makefile as it is a submodule.

Does this make compilation easier under MaxOSX?

@galvusdamor Did you mean for me to try the PR branch or master?

@rpgoldman
Copy link

master gives me the following error:

CC=/opt/homebrew/bin/gcc-13 make boruvka opts bliss lpsolve
...
/opt/homebrew/bin/gcc-13 -O3 -Wall -pedantic -std=gnu99 -ffast-math -I. -o bin/bor-qdelaunay bin/qdelaunay-main.c -pthread  -L. -lboruvka -lm -lrt
ld: library not found for -lrt
collect2: error: ld returned 1 exit status
make[1]: *** [bin/bor-qdelaunay] Error 1
make: *** [boruvka] Error 2

Same error when trying to use Apple's clang C compiler.

Some items on Stack Overflow seem to suggest that -lrt is not needed, but 🤷

@galvusdamor
Copy link
Collaborator

@galvusdamor Did you mean for me to try the PR branch or master?

I've pushed this to the master.

@galvusdamor
Copy link
Collaborator

master gives me the following error:

CC=/opt/homebrew/bin/gcc-13 make boruvka opts bliss lpsolve
...
/opt/homebrew/bin/gcc-13 -O3 -Wall -pedantic -std=gnu99 -ffast-math -I. -o bin/bor-qdelaunay bin/qdelaunay-main.c -pthread  -L. -lboruvka -lm -lrt
ld: library not found for -lrt
collect2: error: ld returned 1 exit status
make[1]: *** [bin/bor-qdelaunay] Error 1
make: *** [boruvka] Error 2

Same error when trying to use Apple's clang C compiler.

Some items on Stack Overflow seem to suggest that -lrt is not needed, but shrug

Apparently -lrt is actually not necessary - at least cpddl compiles for me locally. I've updated the patch files in the repo to remove the -lrt wherever it occurs.

@rpgoldman can you try to compile again?

@rpgoldman
Copy link

Tried and now there is a new error:

ar cr libboruvka.a .objs/alloc.o .objs/varr.o .objs/quat.o .objs/vec4.o .objs/vec3.o .objs/vec2.o .objs/vec.o .objs/mat4.o .objs/mat3.o .objs/poly2.o .objs/predicates.o .objs/sort.o .objs/heapsort.o .objs/mergesort.o .objs/qsort.o .objs/listsort.o .objs/timsort.o .objs/pc.o .objs/pc-internal.o .objs/gug.o .objs/nearest-linear.o .objs/vptree.o .objs/vptree-hamming.o .objs/nn-linear.o .objs/mesh3.o .objs/net.o .objs/qhull.o .objs/chull3.o .objs/fibo.o .objs/pairheap.o .objs/dij.o .objs/pairheap_nonintrusive_int.o .objs/bucketheap.o .objs/tasks.o .objs/task-pool.o .objs/hfunc.o .objs/htable.o .objs/google-city-hash.o .objs/barrier.o .objs/rand-mt.o .objs/rand-mt-parallel.o .objs/timer.o .objs/parse.o .objs/image.o .objs/segmarr.o .objs/extarr.o .objs/rbtree.o .objs/rbtree_int.o .objs/splaytree.o .objs/splaytree_int.o .objs/multimap_int.o .objs/fifo.o .objs/fifo-sem.o .objs/lifo.o .objs/ring_queue.o .objs/scc.o .objs/msg-schema.o .objs/iset.o .objs/lset.o .objs/cset.o .objs/hashset.o .objs/ibucketq.o .objs/lbucketq.o .objs/pbucketq.o .objs/iadaq.o .objs/ladaq.o .objs/padaq.o .objs/apq.o .objs/lp.o .objs/lp-cplex.o .objs/lp-lpsolve.o .objs/lp-gurobi.o .objs/digraph.o .objs/err.o
ranlib libboruvka.a
/opt/homebrew/bin/gcc-13 -O3 -Wall -pedantic -std=gnu99 -ffast-math -I. -o bin/bor-qdelaunay bin/qdelaunay-main.c -pthread  -L. -lboruvka -lm
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make[1]: *** [bin/bor-qdelaunay] Error 1
make: *** [boruvka] Error 2

I get these both with the brew gcc and with Apple's.

But if I set CC=clang then make boruvka opts bliss lpsolve compiles successfully, and so does make in the pandaPIgrounder directory.

Somehow clang seems to know how to find all the required libraries. Perhaps one of the other compilers could be made to work by setting the library path, but I can't really figure this out. It seems like the right library file is "/usr/lib/libSystem.B.dylib" but I don't even know what causes -lSystem

@galvusdamor
Copy link
Collaborator

Yes, it looks like he is trying to find a library of the name /usr/lib/libSystem.B.dylib -- this might be due to the -lboruvka which refers to the library that we just assembled in the previous step. Maybe setting the library path with -L. does not work correctly.

If CC=clang works, we might just declare it to be the default option for the whole panda system under MacOS?

@rpgoldman
Copy link

It does seem that using clang is the best way to make this work natively on the Mac.

I don't understand what is going on with the failures -- why gcc wants a System library, and why the System library on MacOS is actually called System.B.

But maybe we don't need to understand!

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

No branches or pull requests

4 participants