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

fatal error: 'event.h' file not found on MacOS Ventura M1 Pro #146

Closed
GPrimola opened this issue Aug 1, 2023 · 1 comment · Fixed by #148
Closed

fatal error: 'event.h' file not found on MacOS Ventura M1 Pro #146

GPrimola opened this issue Aug 1, 2023 · 1 comment · Fixed by #148

Comments

@GPrimola
Copy link

GPrimola commented Aug 1, 2023

Hi,

I'm having an issue when compiling katipo on MacOS Ventura 13.5 M1 as you can see in the logs below:

$ rebar3 compile
===> Verifying dependencies...
===> Fetching katipo v1.0.4
===> Fetching rebar3_hex v7.0.7
===> Fetching hex_core v0.8.4
===> Fetching verl v1.1.1
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching rebar3_proper v0.12.1
===> Analyzing applications...
===> Compiling rebar3_proper
===> Fetching coveralls v1.4.0
===> Analyzing applications...
===> Compiling coveralls
===> Fetching metrics v2.5.0
===> Fetching worker_pool v6.0.0
cc -O3 -std=c99 -arch x86_64 -Wall -Wmissing-prototypes -fPIC -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/erts-12.3.2.13/include/ -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/lib/erl_interface-5.2.2/include  -c -o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.c
/Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.c:2:10: fatal error: 'event.h' file not found
#include <event.h>
         ^~~~~~~~~
1 error generated.
make: *** [/Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o] Error 1
===> Hook for compile failed!

Steps to reproduce

  1. Clone https://github.com/GPrimola/test_katipo
  2. Run rebar3 compile

Workaround

I found this answer on StackExchange that helped pass through the fatal error: 'event.h' file not found.

But then I get the following error:

$ export LDFLAGS="-L/opt/homebrew/lib"
$ export CPPFLAGS="-I/opt/homebrew/include"
$
$ rebar3 compile                      
===> Verifying dependencies...
cc -O3 -std=c99 -arch x86_64 -Wall -Wmissing-prototypes -fPIC -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/erts-12.3.2.13/include/ -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/lib/erl_interface-5.2.2/include -I/opt/homebrew/include -c -o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.c
cc /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o -L/opt/homebrew/lib -L /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/lib/erl_interface-5.2.2/lib -lei -lcurl -lssl -lcrypto -levent -o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/../priv/katipo
ld: warning: ignoring file /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o, building for macOS-arm64 but attempting to link with file built for unknown-x86_64
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/../priv/katipo] Error 1
===> Hook for compile failed!

which I solved by running the same command shown just after the ===> Verifying dependencies... but with the flag -arch arm64:

cc -O3 -std=c99 -arch arm64 -Wall -Wmissing-prototypes -fPIC -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/erts-12.3.2.13/include/ -I /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/lib/erl_interface-5.2.2/include -I/opt/homebrew/include -c -o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.c

and only after that I can compile katipo:

$ rebar3 compile
===> Verifying dependencies...
cc /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/katipo.o -L/opt/homebrew/lib -L /Users/giorgio.torres/.asdf/installs/erlang/24.3.4.13/lib/erl_interface-5.2.2/lib -lei -lcurl -lssl -lcrypto -levent -o /Users/giorgio.torres/projects/test_katipo/_build/default/lib/katipo/c_src/../priv/katipo
===> Analyzing applications...
===> Compiling worker_pool
===> Compiling metrics
===> Compiling katipo
===> Analyzing applications...
===> Compiling test_katipo

I suspect there's a kind of misconfiguration with my Homebrew so the include and libs for libevent aren't being found, but also I don't know why when compiling c_src/katipo.c the architecture is not set correctly:

$ arch
arm64

Is anybody facing a similar issue?

EDIT

Versions

$ brew -v
Homebrew 4.1.3
Homebrew/homebrew-core (git revision 7a144369d9e; last commit 2023-07-12)
Homebrew/homebrew-cask (git revision cb0391d439; last commit 2023-07-12)

$ gcc -v
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ cc -v
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ rebar3 -v
rebar 3.22.0 on Erlang/OTP 24 Erts 12.3.2.13
@puzza007
Copy link
Owner

puzza007 commented Nov 6, 2023

Hi @GPrimola! Try #148 and let me know if it works for you.

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

Successfully merging a pull request may close this issue.

2 participants