ArteMisc / libsalty

Elixir bindings for libsodium (NIF)
Apache License 2.0
21 stars 25 forks source link

It does not compile #8

Closed sgessa closed 6 years ago

sgessa commented 6 years ago

Thank you for porting libsodium to Elixir.

Elixir version: 1.6.3 Erlang/OTP: 20

Build log (libsalty 0.1.1 - I tried to build from any commit and it just won't compile): https://pastebin.com/raw/fjuYnwM6

Let me know if you need further informations. Thank you and great job!

ArteMisc commented 6 years ago

Which OS are you using?

The errors seem to indicate that your system is missing the header files for libsodium, or the compiler is unable to locate them.

maybe the instructions at https://download.libsodium.org/doc/installation/#compilation-on-unix-like-systems can help solve your problems? If I recall correctly, running the sudo make install command should install the library (.so) and development headers in your system's include folder where the compiler can find them.

sgessa commented 6 years ago

Thanks for the quick reply!

OS Version:

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:    16.04
Codename:   xenial

> dpkg -l | grep libsodium                        
ii  libsodium-dev:amd64                   1.0.8-5                               amd64
ii  libsodium18:amd64                     1.0.8-5                               amd64

In the meanwhile I will try to compile libsodium from source..

sgessa commented 6 years ago

Ok, salty compiles fine with libsodium compiled from sources.

However, version 0.1.1 still does not compile because of deprecation warnings treated as errors.

Compiling salty from branch master complains about missing app file:

* libsalty (https://github.com/ArteMisc/libsalty)
  could not find an app file at "_build/dev/lib/libsalty/ebin/libsalty.app". This may happen if the dependency was not yet compiled, or you specified the wrong application name in your deps, or the dependency indeed has no app file (then you can pass app: false as option)

It looks like the .app file is misnamed: _build/dev/lib/libsalty/ebin/salty.app

I tried to rename it to libsalty.app but I get:

Unchecked dependencies for environment dev:
* libsalty (https://github.com/ArteMisc/libsalty)
  the app file at "_build/dev/lib/libsalty/ebin/libsalty.app" is invalid
** (Mix) Can't continue due to errors on dependencies

I changed the first line in libsalty.app from:

{application,salty,

to:

{application,libsalty,

and I get:

02:38:35.669 [info]  Application libsalty exited: exited in: Salty.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in :filename.join/2
            (stdlib) filename.erl:413: :filename.join({:error, :bad_name}, "salty_nif")
            (stdlib) filename.erl:400: :filename.join/1
            (libsalty) lib/salty/nif.ex:10: Salty.Nif.load_nif/0
            (libsalty) lib/salty/application.ex:11: Salty.Application.start/2
            (kernel) application_master.erl:273: :application_master.start_it_old/4
ArteMisc commented 6 years ago

Could you give me the commands you are using, so I can try to reproduce these errors?

sgessa commented 6 years ago

In my mix.exs:

  defp deps do
    [
      {:libsalty, git: "https://github.com/ArteMisc/libsalty"}
    ]
  end

Then I run:

ArteMisc commented 6 years ago

Have you tried including the package as a hex dependency?

  defp deps do
    [
      {:salty, "~> 0.1.2", hex: :libsalty}`
    ]
  end

Or try changing the direct github dep to be called salty instead of libsalty

  defp deps do
    [
      {:salty, git: "https://github.com/ArteMisc/libsalty"}
    ]
  end

It seems that these errors originate from the difference between the library's package name (salty) and the repository's name (libsalty).

sgessa commented 6 years ago

Thank you! Now it's working! gj

ArteMisc commented 6 years ago

you're welcome! :)