Troubleshooting building cgx 2.19 from source on Mac OS

I’m trying to build cgx 2.19 from source on Mac OS.

I’ve tried following the Mac instructions from 2015 (noting that they apply to a different version of macOS). When I run sudo make in the /usr/local/CalculiX/cgx_2.19/src folder I get the following error:

parser.c:91:3: error: implicit declaration of function 'DrawCommandLine' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  DrawCommandLine(keystroke, strlen(keystroke) + *curshft);

It seems like the function definition for DrawCommandLine is not getting included. I’m not very familiar with C/C++ but it seems that this function is included in cgx.c which itself is included by MakeFile.inc

Any ideas what’s going on?

in parser.c, change the first line:

#include <cgx.h>
/*#include <extUtil.h>

in pickfunctions.c, correct line 4597:

  return;

correct the makefile:

LFLAGS =
-L/usr/lib -lGL -lGLU
-L/usr/X11R6/lib -lX11 -lXi -lXmu -lXext -lXt -lSM -lICE
-lm -lpthread

Hi mparente,

Thanks for your reply. I’ve implemented the changes as you suggested, and the compilation does get a lot further. Now it seems to exit on the following error:

ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make: *** [cgx] Error 1

do you have XQuartz installed ?

Marco

Yes I do.

I think I’ve managed to get past the ld error by including this in the LFLAGS section in the makefile:

-L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib \

It seems the compilation runs without errors, but ends with a lot of warnings like this:

ld: warning: object file (/var/tmp//ccrWCwNi.o) was built for newer macOS version (12.0) than being linked (10.17.4)
ld: warning: object file (/var/tmp//cck4ppOP.o) was built for newer macOS version (12.0) than being linked (10.17.4)
ld: warning: object file (/var/tmp//cc8xH23e.o) was built for newer macOS version (12.0) than being linked (10.17.4)

ok. I have this on my .bashrc:

export LIBRARY_PATH=“$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib”

on my Mac, after I open a .frd results file, I have to manually resize the cgx application window, for the model to show up. I first change its size to a small window then resize it to a normal one and the model shows up.

Marco

1 Like

Thank you so much. It’s working now. I indeed need to resize the window down until I get the following warning:

GLUT: Warning in cgx: glutReshapeWindow: non-positive width or height not allowed

Then when I resize up, the model is viewable.

Thanks again, you’ve been incredibly helpful.

:smile: glad to help

Best Regards
Marco

I had compiled it for macOS 10.13 some time ago but window was blank and I thought it didn’t work…thanks for the tip! Anyone knows what’s behind this behaviour?

Hi! I’m having a similar problem building cgx 2.20.1 on Monterey. If I change line 4597 to “return;” I get even more errors. The rest, I have done and it has helped.
Thank you!

I’m trying to build cgx 2_20 with Ventura on a M1 Ultra. I downloaded the latest binary, and after getting make errors, found this thread and in particular the suggestions by mparente for modifying parser.c, picfunctions.c, and the Makefile.
However, in addition to multiple warnings, I get 2 errors:
pickFunktions.c:4597:3: error: non-void function ‘normalLine’ should return a value [-Wreturn-type]
and
pickFunktions.c:8375:5: error: call to undeclared function ‘mergeElem’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Has anyone with a similar setup (Ventura, cgx 2_20) been able to get cgx to work? Any suggestions for how I could get this to work?
Thanks, in advanced

Thanks for the instructions and tips. any update how to resolve the view the model without the need to resizing the window? I found resizing the window to be unreliable as it seems to need to make the window very small that usually ended up closing the whole window.
Would be good to know if there is a more permanent fix.