# Troubleshooting building cgx 2.19 from source on Mac OS

**URL:** <https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158>\
**Category:** CalculiX GraphiX\
**Created:** [July 14, 2022, 11:02am UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158 "2022-07-14T11:02:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ty4](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/ty4/32/865_2.png) [@ty4](https://calculix.discourse.group/u/ty4)\
**Post date:** [July 14, 2022, 11:02am UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/1 "2022-07-14T11:02:05Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![mparente](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@mparente](https://calculix.discourse.group/u/mparente)\
**Post date:** [July 14, 2022, 6:05pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/2 "2022-07-14T18:05:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ty4](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/ty4/32/865_2.png) [@ty4](https://calculix.discourse.group/u/ty4)\
**Post date:** [July 14, 2022, 7:47pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/3 "2022-07-14T19:47:45Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![mparente](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@mparente](https://calculix.discourse.group/u/mparente)\
**Post date:** [July 14, 2022, 8:00pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/4 "2022-07-14T20:00:53Z")

</div>

do you have XQuartz installed ?

Marco

---

<div class="post-metadata">

**Author:** ![ty4](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/ty4/32/865_2.png) [@ty4](https://calculix.discourse.group/u/ty4)\
**Post date:** [July 14, 2022, 8:13pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/5 "2022-07-14T20:13:11Z")

</div>

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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![mparente](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@mparente](https://calculix.discourse.group/u/mparente)\
**Post date:** [July 14, 2022, 8:25pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/6 "2022-07-14T20:25:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ty4](https://yyz2.discourse-cdn.com/free1/user_avatar/calculix.discourse.group/ty4/32/865_2.png) [@ty4](https://calculix.discourse.group/u/ty4)\
**Post date:** [July 15, 2022, 4:43am UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/7 "2022-07-15T04:43:40Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![mparente](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@mparente](https://calculix.discourse.group/u/mparente)\
**Post date:** [July 15, 2022, 11:54am UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/8 "2022-07-15T11:54:17Z")

</div>

😄 glad to help

Best Regards  
Marco

---

<div class="post-metadata">

**Author:** ![JuanP74](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JuanP74](https://calculix.discourse.group/u/JuanP74)\
**Post date:** [July 15, 2022, 9:36pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/9 "2022-07-15T21:36:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![fede](https://avatars.discourse-cdn.com/v4/letter/f/9fc348/32.png) [@fede](https://calculix.discourse.group/u/fede)\
**Post date:** [February 10, 2023, 11:48pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/10 "2023-02-10T23:48:10Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![rth](https://avatars.discourse-cdn.com/v4/letter/r/9d8465/32.png) [@rth](https://calculix.discourse.group/u/rth)\
**Post date:** [May 17, 2023, 6:36pm UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/11 "2023-05-17T18:36:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AshkanRafiee](https://avatars.discourse-cdn.com/v4/letter/a/a587f6/32.png) [@AshkanRafiee](https://calculix.discourse.group/u/AshkanRafiee)\
**Post date:** [January 22, 2024, 2:23am UTC](https://calculix.discourse.group/t/troubleshooting-building-cgx-2-19-from-source-on-mac-os/1158/12 "2024-01-22T02:23:11Z")

</div>

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.
