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

Build fails on macOS #1

Closed
ubolonton opened this issue Apr 22, 2018 · 23 comments
Closed

Build fails on macOS #1

ubolonton opened this issue Apr 22, 2018 · 23 comments

Comments

@ubolonton
Copy link

Build fails on macOS 0.13.4 (17E199).
Package manager is MacPorts.

This is the error:

[100%] Linking C shared library libegit2.dylib
Undefined symbols for architecture x86_64:
  "_libiconv", referenced from:
      _git_path_iconv in libgit2.a(path.c.o)
  "_libiconv_close", referenced from:
      _git_path_iconv_clear in libgit2.a(path.c.o)
  "_libiconv_open", referenced from:
      _git_path_iconv_init_precompose in libgit2.a(path.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/libegit2.dylib] Error 1
make[1]: *** [src/CMakeFiles/egit2.dir/all] Error 2
make: *** [all] Error 2
@TheBB
Copy link
Collaborator

TheBB commented Apr 23, 2018

I'd be happy to receive build patches for other OSes. I don't have a Mac. :-/

@TheBB
Copy link
Collaborator

TheBB commented Apr 23, 2018

rust-lang/cargo#1032 seems relevant.

Can you check where your libiconv is, if cmake can find it correctly and if it invokes linking with the right paths (make VERBOSE=1)?

@ubolonton
Copy link
Author

Thanks! I'll check that out.

@ubolonton
Copy link
Author

The problem seems to be the same. It tries to link with /usr/lib/libiconv.dylib instead of /opt/local/lib/libiconv.dylib.

I don't know how to fix it though, since I'm not familiar with cmake.

@TheBB
Copy link
Collaborator

TheBB commented Apr 25, 2018

Try something like cmake -DCMAKE_PREFIX_PATH=/opt/local ..

@ubolonton
Copy link
Author

That works.

Testing fails with this

Running tests...
Test project /Users/ubolonton/Programming/lib/libegit2/build
    Start 1: libegit2_repository
Process not started
 /Users/ubolonton/Programming/lib/libegit2/cask
[permission denied]
1/1 Test #1: libegit2_repository ..............***Not Run   0.00 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.00 sec

The following tests FAILED:
          1 - libegit2_repository (BAD_COMMAND)
Errors while running CTest
make: *** [test] Error 8

@TheBB
Copy link
Collaborator

TheBB commented Apr 25, 2018

Great. :-)

As for testing I didn't put those instructions in the README at the time. If you have cask installed you should be able to do cask install in the root folder, then cask exec ert-runner to run the tests. make test does more or less just that.

@ubolonton
Copy link
Author

ubolonton commented Apr 26, 2018

Using cask exec ert-runner gives this error instead: Cannot open load file: No such file or directory, libegit2.

@TheBB
Copy link
Collaborator

TheBB commented Apr 26, 2018

That's very strange. The load-path is tweaked in test-helpers.el, line 1, and there should be a libegit.xyz in the build directory, no?

@ubolonton
Copy link
Author

Silly me. I should have remembered this. Shared libs in macOS has .dylib extension, while module-file-suffix is ".so". My own modules have build scripts that create .so symlink.

@ubolonton
Copy link
Author

make test still doesn't work, but cask exec ert-runner works now, with 2 failed tests.

@ubolonton
Copy link
Author

I think we should set up Travis integration for this now, to iterate faster. They support testing on mac OS.

Integration is pretty simple, like this: https://github.com/ubolonton/emacs-module-rs/blob/master/.travis.yml

@TheBB
Copy link
Collaborator

TheBB commented Apr 26, 2018

Yep, agree.

I thought Emacs would look for .dylib files by default on Mac.

@TheBB
Copy link
Collaborator

TheBB commented Apr 26, 2018

https://github.com/TheBB/libegit2/pull/4

Here's a PR for Travis. I fixed some of the OSX build issues in cmake, so it should be easier for you. I suppose you still have to set the prefix path though.

Three tests fail on OSX. In each case libgit returns a path starting with /private which shouldn't be there. Do you know what's up with that?

@TheBB
Copy link
Collaborator

TheBB commented Apr 26, 2018

Looks like /tmp is a symlink to /private/tmp...

@TheBB
Copy link
Collaborator

TheBB commented Apr 26, 2018

Tests are passing on OSX and I've added the macports gotcha to the readme.

Thanks for helping with this. :-)

@TheBB TheBB closed this as completed Apr 26, 2018
@ubolonton
Copy link
Author

🎉

@Lord-Kamina
Copy link

Lord-Kamina commented Aug 26, 2019

EDIT: Readability 😂

I had this same issue; the problem is with cargo trying to use the macports libiconv (although probably same thing will happen with homebrew) instead of the system one.

This can be reproduced, among other things, when a crate adds the package manager tree to the library/include search paths; one common reason it might happen is OpenSSL; because macOS by default ships an old version incompatible with cargo crates. I fixed it by applying several patches on libgit2-sys, libssh2, openssl-sys and openssl-src (I'm not sure whether all of these are actually needed, some are definitely better candidates than others). For my use-case I did it backwards (as I slowly understood the issue) but the first thing I'd try in order to fix this would be to default openssl-sys to the vendored version if on macOS.

@s-kostyaev
Copy link

@TheBB for now on mac os build is broken. Instead of libegit2.dylib there is libegit2.so.

@TheBB
Copy link
Collaborator

TheBB commented Feb 7, 2020

https://github.com/magit/libegit2/blob/master/src/CMakeLists.txt#L6-L10

That was purposeful. From what I could see based on the Travis tests, Emacs on OSX looked for .so files, not .dylib, so I had to override the extension.

Has that changed?

@s-kostyaev
Copy link

Emacs on OSX looked for .so files, not .dylib

This is not true. Maybe it's not true in emacs 27 only. But I have this issue.

@TheBB
Copy link
Collaborator

TheBB commented Feb 7, 2020

Could you PR a fix? I don't have an OSX computer so it's difficult for me to test. I assume safest would be to add a cmake directive to copy the generated file so there's both a .so and a .dylib present. In the linked file there's already one that copies the library to the parent dir, so you can see how it should look like.

@s-kostyaev
Copy link

I will try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants