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

Wouldn't compile on M1 Mac #80

Open
guntgbtgv opened this issue Mar 12, 2024 · 9 comments
Open

Wouldn't compile on M1 Mac #80

guntgbtgv opened this issue Mar 12, 2024 · 9 comments

Comments

@guntgbtgv
Copy link

guntgbtgv commented Mar 12, 2024

I'm trying this repo directly by git clone. (#52 (comment)_ )
I've installed all the requirements in README.md, yet I get this error:


GCHS +++ include/drat/argp.h +++ out/include/drat/argp.gch
gcc -std=c99 -D _GNU_SOURCE -Werror -Wall -Wextra -Wno-incompatible-pointer-types -Wno-multichar -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -I./include -I/usr/local/Cellar/argp-standalone/1.3/include/ -c "include/drat/argp.h" -o "out/include/drat/argp.gch"
include/drat/argp.h:6:10: error: 'argp.h' file not found with <angled> include; use "quotes" instead
#include <argp.h>
         ^~~~~~~~
         "argp.h"
include/drat/argp.h:30:53: error: array has incomplete element type 'const struct argp_option'
extern const struct argp_option argp_options_globals[];
                                                    ^
include/drat/argp.h:30:21: note: forward declaration of 'struct argp_option'
extern const struct argp_option argp_options_globals[];
                    ^
include/drat/argp.h:31:1: error: unknown type name 'error_t'
error_t argp_parser_command(int key, char* arg, struct argp_state* state);
^
include/drat/argp.h:31:56: error: declaration of 'struct argp_state' will not be visible outside of this function [-Werror,-Wvisibility]
error_t argp_parser_command(int key, char* arg, struct argp_state* state);
                                                       ^
include/drat/argp.h:32:1: error: unknown type name 'error_t'
error_t argp_parser_globals(int key, char* arg, struct argp_state* state);
^
include/drat/argp.h:32:56: error: declaration of 'struct argp_state' will not be visible outside of this function [-Werror,-Wvisibility]
error_t argp_parser_globals(int key, char* arg, struct argp_state* state);
                                                       ^
include/drat/argp.h:35:45: error: array has incomplete element type 'const struct argp_child'
extern const struct argp_child argp_children[];
                                            ^
include/drat/argp.h:35:21: note: forward declaration of 'struct argp_child'
extern const struct argp_child argp_children[];
                    ^
7 errors generated.
make: *** [out/include/drat/argp.gch] Error 1


@stephanmantler
Copy link

I encountered the same issue because my homebrew path is different from the one specified in the Makefile (brew list argp-standalone confirmed the include and library paths needed to be /opt/homebrew/... instead of /usr/local/...).

Other problems I encountered:

  • variable 'val_end' set but not used in commands/modify.c and commands/search.c
  • declaration of open_container__info_stream() in include/drat/io.h is missing the parameter (should be int open_container__info_stream(FILE* info_stream);)
  • variable 'num_records' set but not used in include/drat/print-fs-records.c

Minimum effort patchfile

Resolving those issues, everything builds successfully (MacBook Air M1 2020, Sonoma 14.4) and drat inspect confirms more or less the same APFS issues I have with diskutil verifyvolume.

@guntgbtgv
Copy link
Author

Thanks, this solved the issue. I've applied the changed you've suggested, and compiled like magic.

However, in my case drat inspect did not work

baggeon-u@gunoos-MacBook-Pro-2 drat % ./drat inspect --container /dev/disk7s2
Opening `/dev/disk7s2` in read-only mode ... open_container__info_stream: ERROR: You do not have sufficient privileges to read this file.
baggeon-u@gunoos-MacBook-Pro-2 drat % sudo ./drat inspect --container /dev/disk7s2 
Password:
Opening `/dev/disk7s2` in read-only mode ... open_container__info_stream: ERROR: Unknown error.

This may be another issue, not related to the original compile issue.

@stephanmantler
Copy link

Opening `/dev/disk7s2` in read-only mode ... open_container__info_stream: ERROR: You do not have sufficient privileges to read this file.

You'll need to run as root to have full access to the disk (sudo ./drat inspect ...)

@oleggromov
Copy link

I encountered the same issue because my homebrew path is different from the one specified in the Makefile (brew list argp-standalone confirmed the include and library paths needed to be /opt/homebrew/... instead of /usr/local/...).

Other problems I encountered:

  • variable 'val_end' set but not used in commands/modify.c and commands/search.c
  • declaration of open_container__info_stream() in include/drat/io.h is missing the parameter (should be int open_container__info_stream(FILE* info_stream);)
  • variable 'num_records' set but not used in include/drat/print-fs-records.c

Minimum effort patchfile

Resolving those issues, everything builds successfully (MacBook Air M1 2020, Sonoma 14.4) and drat inspect confirms more or less the same APFS issues I have with diskutil verifyvolume.

Thank you @stephanmantler!
This resulted in a working build on an M3 mac with argp-standalone installed in a newer version 1.5.0 (via homebrew), and the installation location was /opt/homebrew/Cellar/argp-standalone/1.5.0/. In case the reader faces the same, you can obtain the location of your installed lib via brew info argp-standalone

@algebravic
Copy link

I encountered the same issue because my homebrew path is different from the one specified in the Makefile (brew list argp-standalone confirmed the include and library paths needed to be /opt/homebrew/... instead of /usr/local/...).

Other problems I encountered:

* variable 'val_end' set but not used in `commands/modify.c` and `commands/search.c`

* declaration of `open_container__info_stream()` in `include/drat/io.h` is missing the parameter (should be `int open_container__info_stream(FILE* info_stream);`)

* variable 'num_records' set but not used in `include/drat/print-fs-records.c`

Minimum effort patchfile

Resolving those issues, everything builds successfully (MacBook Air M1 2020, Sonoma 14.4) and drat inspect confirms more or less the same APFS issues I have with diskutil verifyvolume.

Thanks for the patchfile. This almost worked. However homebrew only has arp-standalone version 1.5.0. When I try the build with that everything compiles ok, but now when it tries to bind it gets the following errors:

Undefined symbols for architecture arm64:
  "_argp_parse", referenced from:
      _main in drat.o
      _cmd_list in list.o
      _cmd_resolver in resolver.o
      _cmd_inspect in inspect.o
      _cmd_explore_omap_tree in explore-omap-tree.o
      _cmd_search in search.o
      _cmd_read in read.o
      ...
ld: symbol(s) not found for architecture arm64

Any suggestions are appreciated.

@stephanmantler
Copy link

@algebravic you probably need to adjust both CPATH and LDPATH in the Makefile to reflect the 1.5.0 version, like so:

### On macOS, include <argp.h> from Homebrew package `argp-standalone`
ifneq ($(OS),Windows_NT)
        ifeq ($(shell uname -s),Darwin)
                override CFLAGS  += -I/opt/homebrew/Cellar/argp-standalone/1.5.0/include/
                override LDFLAGS += -L/opt/homebrew/Cellar/argp-standalone/1.5.0/lib/ -largp
        endif
endif

I just upgraded my Homebrew installation, and with that change everything builds and runs.

@algebravic
Copy link

algebravic commented Jan 4, 2025 via email

@stephanmantler
Copy link

That's odd. It feels a bit like the problem described in this issue where an existing installation for the wrong architecture made the compiler trip up and explicitly adding the relevant homebrew paths (such as described here) resolved it.

@algebravic
Copy link

algebravic commented Jan 4, 2025 via email

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