eyedouble / erlsass

Compile Sass/Scss implemented as Erlang NIF using libsass.
MIT License
1 stars 2 forks source link

Add macOS support #5

Open Spoowy opened 5 years ago

Spoowy commented 5 years ago

I'm getting this error:

The on_load function for module erlsass returned: {error,{load_failed,"Failed to load NIF library: 'dlopen(/.../deps/erlsass/priv/erlsass_nif.so, 2): image not found'"}}

Do I have to compile anything else, since erlsass_nif.so is not existent.

Cheers, Erwin

ivanwel commented 5 years ago

Hi Erwin, Thanks for reaching out.

Please elaborate on your issue, namely: Operating system, Erlang/otp version, and did you install the required prerequisites as per the readme.md?

Also did you encounter any errors during compilation? (Note that rebar3 does this for you).

Please let me know and thanks ks for using Erlsass!

Cheers, Irsan van Wel

Spoowy commented 5 years ago

Hey Irsan, Thanks for the rapid reply!

Operating system: MacOS Mojave 10.14 Erlang/otp version: 21.0 Dependencies (gcc, g++) are installed.

This is the output the compilation gives me:

===> Compiling erlsass
make: Nothing to be done for `all'.
Darwin
Darwin
/.../_build/default/deps/erlsass/c_src
/.../_build/default/deps/erlsass/priv
cp libsass/lib/libsass.so ../priv
Undefined symbols for architecture x86_64:
  "_enif_alloc_env", referenced from:
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_free_env", referenced from:
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_get_list_length", referenced from:
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_get_string", referenced from:
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_make_atom", referenced from:
      mk_atom(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      mk_error(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      mk_ok(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_make_badarg", referenced from:
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_make_existing_atom", referenced from:
      mk_atom(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      mk_error(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      mk_ok(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_make_string", referenced from:
      mk_ok(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
  "_enif_make_tuple", referenced from:
      mk_error(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      mk_ok(enif_environment_t*, char const*) in erlsass_nif-fc98b9.o
      compile_file(enif_environment_t*, int, unsigned long const*) in erlsass_nif-fc98b9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
cp erlsass_nif.so ../priv
cp: erlsass_nif.so: No such file or directory
make: *** [copy2] Error 1
===> Hook for compile failed!

I shall be obliged! Erwin

ivanwel commented 5 years ago

Hi Erwin,

Unfortunately I have never tested the lib on Mac OS, and I don't own a Mac so I can't really do it myself. However I see more people that are encountering similar issues.

It seems that on Mac Os the C compiler needs different flags, based on your output dump I assume the compiler can't find/load the erlang nif header.

Are you able to clone the project and make some changes yourself ?

Have a look at: http://erlang.org/pipermail/erlang-questions/2011-June/059679.html

Also a google search on Erlang NIF Mac Osx or similar might help you.

The following file is where the you want to look: https://github.com/eyedouble/erlsass/blob/master/c_src/Makefile

At the top of that file you find a block 'Define os' you probably want to add some condition there for Darwin/MacOs.

Then under OS specific you want to add a clause for your OS and copy paste unix and then adjust the flags.

You might also want to have a look at: https://github.com/eyedouble/erlsass/blob/master/rebar.config

Let me know, I'm pretty sure you should be able to get it to work.

Kr,

Irsan

ivanwel commented 5 years ago

By the way is your target environment Mac Os as well? Just out of interest...

Spoowy commented 5 years ago

Thanks for the info! I shall have a look. My target environment is Ubuntu 14

ivanwel commented 5 years ago

Hi Erwin,

Good luck, let me know if you need any help. And when you get it to work I would be happy to add your changes.

PS. As you can see I have changed this title of this issue hope you agree.

Kr,

Irsan