Skip to content

Build fails on macOS #6

@rlipscombe

Description

@rlipscombe

There were three problems; more details below:

  1. gcc is clang, doesn't support nested functions.
  2. popt is missing.
  3. getrandom() doesn't exist.

gcc is clang

By default, gcc on macOS refers to clang, which doesn't support nested functions:

image.c:1067:4: error: function definition is not allowed here
 1067 |    {                            // Safe colour check of pixel
      |    ^
image.c:1079:14: error: call to undeclared function 'col'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1079 |          if (col (x, y) != c)
      |              ^
image.c:1150:4: error: function definition is not allowed here
 1150 |    {
      |    ^
image.c:1163:7: error: call to undeclared function 'addcolour'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1163 |       addcolour (0);
      |       ^
image.c:1172:10: error: call to undeclared function 'addcolour'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
 1172 |          addcolour (c);
      |          ^
5 errors generated.

To fix this, I installed gcc 15, using brew install gcc. Unfortunately, this doesn't provide a gcc binary, so I couldn't just mess with $PATH. Instead I had to edit the Makefiles to reference $(CC) instead of gcc and then run it with CC=$(brew --prefix gcc)/bin/gcc-15 make.

popt is missing

To fix it:

  1. brew install popt.
  2. Edit the Makefiles to add -I/opt/homebrew/opt/popt/include -L/opt/homebrew/opt/popt/lib. I'm unsure whether this could be done with an environment variable instead.

getrandom

There's no getrandom() function in <sys/random.h>.

So I stubbed it out at the top of the qr.c file with the following:

ssize_t
getrandom(void *buf, size_t buflen, unsigned int flags) {
    return -1;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions