Closed ghost closed 7 months ago
Same issue here, I installed criterion using brew on my M1 macbook pro. When trying to compile a simple file I get
gcc -o test simple.c -lcriterion
simple.c:1:10: fatal error: 'criterion/criterion.h' file not found
#include <criterion/criterion.h>
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
So in order to compile I have to specify the location of both the include directory and lib location using
gcc -o simple -I/opt/homebrew/Cellar/criterion/2.4.1_3/include simple.c -L/opt/homebrew/Cellar/criterion/2.4.1_3/lib -lcriterion
./simple
[----] simple.c:4: Assertion Failed
[----]
[----] The expression 0 is false.
[----]
[FAIL] misc::failing: (0.00s)
[====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0
I'm looking for a way to for Apple clang to directly fetch the libraries and includes from homebrew but haven't found the correct way to do it yet. But at least with that you should be able to compile
See this SO post for more info. https://stackoverflow.com/questions/74912616/criterion-c-header-not-found-on-macos/77366984#77366984. Instead of passing include and lib folders of the Criterion tap, you can pass the HomeBrew's global include and lib folders as per the linked answer.
Same issue here, I installed criterion using brew on my M1 macbook pro. When trying to compile a simple file I get
gcc -o test simple.c -lcriterion simple.c:1:10: fatal error: 'criterion/criterion.h' file not found #include <criterion/criterion.h> ^~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.
So in order to compile I have to specify the location of both the include directory and lib location using
gcc -o simple -I/opt/homebrew/Cellar/criterion/2.4.1_3/include simple.c -L/opt/homebrew/Cellar/criterion/2.4.1_3/lib -lcriterion ./simple [----] simple.c:4: Assertion Failed [----] [----] The expression 0 is false. [----] [FAIL] misc::failing: (0.00s) [====] Synthesis: Tested: 2 | Passing: 1 | Failing: 1 | Crashing: 0
I'm looking for a way to for Apple clang to directly fetch the libraries and includes from homebrew but haven't found the correct way to do it yet. But at least with that you should be able to compile
Adding homebrew include and lib to CPATH and PATH_LIBRARY worked for me
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib
I think this can be closed. As explained by others, setting the include and library paths fixes the problem.
Also you can find some basic aspirations on the homebrew example. https://github.com/Homebrew/homebrew-core/blob/master/Formula/c/criterion.rb#L36-L47
Compile a sample test give this error:
This is the sample: