Problem compiling Geoviewer on MacOS

I am on MacOS Mojave and I am trying to compile Flair.

I followed the instructions, but I am getting the following error when doing make -j4 inside the expanded flair directory:

In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/wchar.h:90,
                 from /opt/local/include/gcc9/c++/cwchar:44,
                 from /opt/local/include/gcc9/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc9/c++/iosfwd:40,
                 from /opt/local/include/gcc9/c++/ios:38,
                 from /opt/local/include/gcc9/c++/ostream:38,
                 from ../math/bbox.h:12,
                 from ../geometry/gbody.h:12,
                 from ../geometry/gzone.h:15,
                 from ../geometry/vzone.h:12,
                 from ../geometry/ray.h:12,
                 from d3layer.h:12,
                 from d3layer.cc:11:
/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
  222 | char *ctermid(char *);
      |       ^~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:524,
                 from ../os.h:115,
                 from ../geometry/geo.h:12,
                 from ../geometry/ray.h:11,
                 from d3layer.h:12,
                 from d3layer.cc:11:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage
   26 | char    *ctermid(char *);
      |          ^~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/wchar.h:90,
                 from /opt/local/include/gcc9/c++/cwchar:44,
                 from /opt/local/include/gcc9/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc9/c++/iosfwd:40,
                 from /opt/local/include/gcc9/c++/ios:38,
                 from /opt/local/include/gcc9/c++/ostream:38,
                 from ../math/vector.h:14,
                 from bvh.h:16,
                 from bvh.cc:21:
/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
  222 | char *ctermid(char *);
      |       ^~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:524,
                 from ../os.h:115,
                 from geo.h:12,
                 from bvh.h:15,
                 from bvh.cc:21:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage
   26 | char    *ctermid(char *);
      |          ^~~~~~~
c++ -MM -std=c++11 -I. -I.. plane.cc > plane.d
c++ -MM -std=c++11 -I. -I.. obbox.cc > obbox.d
c++ -MM -std=c++11 -I. -I.. matrix4.cc > matrix4.d
c++ -MM -std=c++11 -I. -I.. matrix3.cc > matrix3.d
c++ -MM -std=c++11 -I. -I.. matrix2.cc > matrix2.d
c++ -MM -std=c++11 -I. -I.. matrix.cc > matrix.d
c++ -MM -std=c++11 -I. -I.. histogram2d.cc > histogram2d.d
make[1]: *** [../rules.mk:252: bvh.o] Error 1
make[1]: Leaving directory '/Users/Stuart/Physics/fluka/flair-geoviewer-3.0/geometry'
make: *** [makefile:277: geometry/libgeometry.a] Error 2
make: *** Waiting for unfinished jobs....
c++ -c decorationlayer.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
c++ -MM -std=c++11 -I. -I.. histogram.cc > histogram.d
c++ -MM -std=c++11 -I. -I.. format.cc > format.d
c++ -MM -std=c++11 -I. -I.. conic.cc > conic.d
c++ -MM -std=c++11 -I. -I.. bmath.cc > bmath.d
c++ -MM -std=c++11 -I. -I.. bbox.cc > bbox.d
c++ -c bbox.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
make[1]: *** [../rules.mk:252: d3layer.o] Error 1
make[1]: *** Waiting for unfinished jobs....
c++ -c bmath.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
c++ -c palette.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
make[1]: Leaving directory '/Users/Stuart/Physics/fluka/flair-geoviewer-3.0/viewer'
make: *** [makefile:277: viewer/libviewer.a] Error 2
c++ -c svgexport.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
c++ -c viewport.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/wchar.h:90,
                 from /opt/local/include/gcc9/c++/cwchar:44,
                 from /opt/local/include/gcc9/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc9/c++/iosfwd:40,
                 from /opt/local/include/gcc9/c++/ios:38,
                 from /opt/local/include/gcc9/c++/ostream:38,
                 from color.h:12,
                 from palette.cc:10:
/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
  222 | char *ctermid(char *);
      |       ^~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:524,
                 from ../os.h:115,
                 from palette.h:11,
                 from palette.cc:8:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage
   26 | char    *ctermid(char *);
      |          ^~~~~~~
c++ -c conic.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
make[1]: *** [../rules.mk:252: palette.o] Error 1
make[1]: *** Waiting for unfinished jobs....
c++ -c format.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I..
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/wchar.h:90,
                 from /opt/local/include/gcc9/c++/cwchar:44,
                 from /opt/local/include/gcc9/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc9/c++/iosfwd:40,
                 from /opt/local/include/gcc9/c++/ios:38,
                 from /opt/local/include/gcc9/c++/ostream:38,
                 from /opt/local/include/gcc9/c++/iostream:39,
                 from format.h:12,
                 from format.cc:10:
/opt/local/lib/gcc9/gcc/x86_64-apple-darwin18/9.3.0/include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage
  222 | char *ctermid(char *);
      |       ^~~~~~~
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:524,
                 from ../os.h:115,
                 from format.cc:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage
   26 | char    *ctermid(char *);
      |          ^~~~~~~
make[1]: *** [../rules.mk:252: format.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/Users/Stuart/Physics/fluka/flair-geoviewer-3.0/graph'
make: *** [makefile:277: graph/libgraph.a] Error 2
make[1]: Leaving directory '/Users/Stuart/Physics/fluka/flair-geoviewer-3.0/math'
make: *** [makefile:277: math/libmath.a] Error 2

It seems that the definition in GCC is somehow conflicting with the system version, but I don’t know how to fix this. Does anyone have experience with this? I don’t think it is related to the xorg-libxcb and xorg-xcb-proto versioning issue. I imagine someone else has seen this error. Anyone know? Thanks!

Hi stwalker,

after a short googling I found this article, maybe this will solve your issue.

Cheers,
David

In the end because (by inspection) as it seemed to be a clash between the system headers and GCC, I just deactivated GCC and tried again with the system gcc (which actually is just clang I believe). This actually goes against the instructions on the website, where it is plainly stated that you must use gcc via MacPorts. Maybe there is something subtle that I am missing and for whatever reason using clang will result in worse errors further downstream, but for now, at least it works.

Hi @stwalker,

That’s really strange… and I think it should worth be investigated a bit more…
Looking at the output you’ve posted,
my guess would be that you’re missing some C++ headers.
These are a bit hidden in the system.
Could you please run:

 sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

(the path might differ at your system – might be possible to slightly “tune” it )
and then try compiling again following the instructions at the website?
Let me know if this will work,

Thanks,
Thanos

1 Like

The path in Catalina is different, try

export CPATH=`xcrun --show-sdk-path`/usr/include

Hi @xiaosj,

In order to keep track of the problem,
@stwalker specifically mentioned that he’s using Mojave and not Catalina.
In my knowledge, the problem is not a missing variable/path that has to be exported,
but missing libraries that have to be installed.
These libraries are provided to the OsX system by installing the package I’ve indicated in my previous message in this thread

Cheers,
Thanos

Hi @manousos,

You are right. I added this comment because I had the similar problem last night. Your post helped to identify the reason, but didn’t have a solution for Catalina, which I am using. You mentioned “the path might differ at your system”, so I worked out the way to find the path at Catalina (there is no “Packages” folder in my Mac). The variable tells the system where to find the SDK head files.

Thanks

Hi @xiaosj

That’s great. But in your Catalina configuration,
did you follow the instructions found at the website?
If yes, in which step did the compilation failed and with what error?
Was the error the same as @stwalker or a different one?

Cheers,
Thanos

Hi @manousos,

I should mention the error I got is different. I followed the steps on the website. It happened when I tried to make the Geoviewer (flair itself works), showing some as below (many times, just quote one here):

In file included from …/os.h:115,
from …/math/vector.h:16,
from …/math/point.h:12,
from vertex.h:15,
from edge.h:14,
from mesh.h:14,
from mesh.cc:11:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:669:48: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
669 | int mkpath_np(const char path, mode_t omode) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_5_0); / returns errno */
| ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:749:58: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
749 | int fgetattrlist(int,void*,void*,size_t,unsigned int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:750:58: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
750 | int fsetattrlist(int,void*,void*,size_t,unsigned int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from …/os.h:115,
from …/math/vector.h:16,
from …/math/point.h:12,
from vertex.h:15,
from edge.h:14,
from mesh.h:14,
from mesh.cc:11:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:774:51: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
774 | int ffsctl(int,unsigned long,void*,unsigned int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:779:31: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
779 | int fsync_volume_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:780:39: error: expected initializer before ‘__OSX_AVAILABLE_STARTING’
780 | int sync_volume_np(const char *, int) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0);
| ^~~~~~~~~~~~~~~~~~~~~~~~

This type of error can be resolved by adding either one of the following:

export CPATH=`xcrun --show-sdk-path`/usr/include
or
export SDKROOT=`xcrun --show-sdk-path`

Sorry I may drag the thread to another direction.

Hi,

I am having issues compiling flair-geoviewer. I am using Catalina.
This is the error I keep having

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C xdraw

c++ -c ocube.cc -m64 -g -DDarwin -O3 -funroll-loops -DNDEBUG -D_DEBUG=0 -ftree-vectorize -DTHREAD -std=c++11 -pedantic -W -Wall -Wcast-align -Wcast-qual -Wextra -Wformat -Wpointer-arith -Wredundant-decls -Wshadow -Wno-write-strings -Wno-long-long -Wno-non-virtual-dtor -Wno-variadic-macros -Woverloaded-virtual -Wpointer-arith -Wshadow -Wunused -Wuninitialized -Wwrite-strings -Wshadow -pipe -pthread -ftls-model=initial-exec -Wno-class-memaccess -fwrapv -fstack-protector -fstrict-aliasing -I. -I… -I/usr/X11/include

ocube.cc:16:10: fatal error: X11/Xlib.h: No such file or directory

16 | #include <X11/Xlib.h>

| **^~~~~~~~~~~~**

compilation terminated.

make[1]: *** [ocube.o] Error 1

make: *** [xdraw/libxdraw.a] Error 2

I have followed some instructions here and have these activated:

The following ports are currently installed:
xorg-libxcb @1.13.1_0+python37 (active)
xorg-libxcb @1.14_0+python37
xorg-xcb-proto @1.13_2+python37 (active)
xorg-xcb-proto @1.14_0+python37

Flair is working fine but the geometry is not functioning.

Hi @Funmi,
thanks for your first post.
Have you checked the installation of XQuartz?

Once I had the same problem and I fixed it by reinstalling XQuartz.
This should create the correct links in /usr.

Let us know.
Cheers

Hi @Funmi,

It seems that the X11 header libraries are somehow missing from your system.
In case they were properly installed before,
this could occur while upgrading to Catalina from a previous OsX version.
In such a case, then you should re-install XQuartz,
as well as follow the instructions for fixing macports after a major OsX version upgrade found in here.
You might also try to re-install/re-enable the command line tools.
In any case, I think that a fresh re-installation of XQuartz would be favourable.

After re-installing XQuartz and still geoviewer is not able to be compiled properly,
could you please give me the output of the following:

ls /opt/local/include/X11/Xlib.h
ls /opt/X11/include/X11/Xlib.h
ls /usr/X11
ls /usr/X11R6

As well as try to install via macports the following:

sudo port install py37-xlib

If you’re using python3.8 then the above command should be:

sudo port install py38-xlib

Let us know if this worked!
Cheers
Thanos

It’s working now.

I uninstalled XQuartz and reinstalled it.

Thank you so much.
I really appreciate.