Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
911 stars 99 forks source link

irony-install-server failure #196

Open codekingplusplus opened 9 years ago

codekingplusplus commented 9 years ago

I have been unsuccessful in properly executing the irony-install-server command. I have read through some prior issues and tried various options such as -DCMAKE_PREFIX_PATH, -DCMAKE_LIBCLANG_LIBRARY and -DLIBCLANG_INCLUDE_DIR. I first tried llvm/clang that comes with my Mac (running OSX 10.10.3), when that didn't work I tried brew install llvm --with-clang. The errors I get are of the form:

dyld: Library not loaded: @rpath/libclangAST.dylib Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib Reason: image not found

If I execute sudo install_name_tool -change @rpath/libclangAST.dylib /usr/local/opt/llvm/lib/libclangAST.dylib /usr/local/opt/llvm/lib/libclang.3.6.dylib and try running irony-install-server again, then I get the same error message with different .dylib files (I did this a lot more than once....). I can find all of these .dylib files in the /usr/local/opt/llvm/lib/.

The command that I have run (shown in irony-server build buffer) is:

/opt/local/bin/cmake -DLIBCLANG_LIBRARY=/usr/local/opt/llvm/lib/libclang.3.6.dylib -DLIBCLANG_INCLUDE_DIR=/usr/local/opt/llvm/include/ -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm -DCMAKE_INSTALL_PREFIX\=/Users/thutmose/.emacs.d/irony/ /Users/thutmose/.emacs.d/elpa/irony-20150408.1501/server && /opt/local/bin/cmake --build . --use-stderr --config Release --target install

I think I have these "PATHS" configured correctly and I'm not sure what else to try. Please let me know if you need more information. Thanks.

Sarcasm commented 9 years ago

You can also try to set the -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON as shown here: https://github.com/Sarcasm/irony-mode#faq

Can you show the output of otool -L on irony-server or libclang.dylib? See this issue: https://github.com/Homebrew/homebrew/issues/34169

Did you try this very command (replacing 3.5 by 3.6)? https://github.com/Sarcasm/irony-mode/issues/135#issuecomment-62843253

Can you go back to the simple cmake command:

mkdir /tmp/build-irony
cd /tmp/build-irony
/opt/local/bin/cmake /Users/thutmose/.emacs.d/elpa/irony-20150408.1501/server
make
./bin/irony-server --version

And copy/paste any error you get.

Debugging OS X issues is difficult for me as I cannot test, maybe @tsukimizake may help, I don't know.

codekingplusplus commented 9 years ago

First Suggestion

cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_INSTALL_PREFIX\=/Users/thutmose/.emacs.d/irony/ /Users/thutmose/.emacs.d/elpa/irony-20150614.1225/server && cmake --build . --use-stderr --config Release --target install

-*- mode: compilation; default-directory: "/var/folders/kf/9_ybd9l55sx4ktk77r831q600000gn/T/build-irony-server-0.2.0-cvs4/" -*-
Compilation started at Wed Jun 17 11:36:40

cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_INSTALL_PREFIX\=/Users/thutmose/.emacs.d/irony/ /Users/thutmose/.emacs.d/elpa/irony-20150614.1225/server && cmake --build . --use-stderr --config Release --target install
-- Detecting libclang builtin headers directory
-- Detecting libclang builtin headers directory -- fail
CMake Warning at cmake/CheckLibClangBuiltinHeadersDir.cmake:87 (message):
  CheckLibClangBuiltinHeadersDir: unsupported configuration, please report.

    Check with args: -isystem;"/usr/local/Cellar/llvm/3.6.0/lib/clang/3.6.0/include";/var/folders/kf/9_ybd9l55sx4ktk77r831q600000gn/T/CMakeFiles/CMakeTmp/check-libclang-stddef.cpp
    Check output:
      dyld: Library not loaded: @rpath/libclangAST.dylib
    Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib
    Reason: image not found

  SIGTRAP

Call Stack (most recent call first):
  src/CMakeLists.txt:8 (check_libclang_builtin_headers_dir)

-- Irony package version is '0.2.0-cvs4'
-- Found emacs: /usr/bin/emacs
-- Configuring done
-- Generating done
-- Build files have been written to: /var/folders/kf/9_ybd9l55sx4ktk77r831q600000gn/T
[100%] Built target irony-server
Install the project...
-- Install configuration: "Release"
-- Installing: /Users/thutmose/.emacs.d/irony/bin/irony-server

Compilation finished at Wed Jun 17 11:36:41

Second Suggestion

/usr/local/Cellar/llvm/3.6.0/lib $ otool -L libclang.dylib 
libclang.dylib:
    /usr/local/opt/llvm/lib/libclang.3.6.dylib (compatibility version 1.0.0, current version 3.6.0)
    @rpath/libclangAST.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangBasic.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangFrontend.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangIndex.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangLex.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangSema.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangTooling.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libclangARCMigrate.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libLLVMCore.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libLLVMSupport.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

Third Suggestion

/usr/local/opt/llvm/lib $ sudo install_name_tool -change @rpath/libLLVM-3.6.dylib /usr/local/opt/llvm/lib/libLLVM-3.6.dylib /usr/local/opt/llvm/lib/libclang.dylib

yields: the same output as above.

Fourth Suggestion

/tmp/build-irony $ cmake /Users/thutmose/.emacs.d/elpa/irony-20150614.1225/server/ 
-- The C compiler identification is AppleClang 6.1.0.6020049
-- The CXX compiler identification is AppleClang 6.1.0.6020049
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified
-- Performing Test HAS_STDCXX11
-- Performing Test HAS_STDCXX11 - Success
-- Performing Test HAS_CXX11_STDLIB
-- Performing Test HAS_CXX11_STDLIB - Success
-- C++11 compiler option(s): -std=c++11
-- Found LibClang: /usr/local/Cellar/llvm/3.6.0/lib/libclang.dylib  
-- Detecting libclang builtin headers directory
-- Detecting libclang builtin headers directory -- fail
CMake Warning at cmake/CheckLibClangBuiltinHeadersDir.cmake:87 (message):
  CheckLibClangBuiltinHeadersDir: unsupported configuration, please report.

    Check with args: -isystem;"/usr/local/Cellar/llvm/3.6.0/lib/clang/3.6.0/include";/tmp/build-irony/CMakeFiles/CMakeTmp/check-libclang-stddef.cpp
    Check output:
      dyld: Library not loaded: @rpath/libclangAST.dylib
    Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib
    Reason: image not found

  SIGTRAP

Call Stack (most recent call first):
  src/CMakeLists.txt:8 (check_libclang_builtin_headers_dir)

-- Irony package version is '0.2.0-cvs4'
-- Found emacs: /usr/bin/emacs
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build-irony
/tmp/build-irony $ make
Scanning dependencies of target irony-server
[ 16%] Building CXX object src/CMakeFiles/irony-server.dir/support/CommandLineParser.cpp.o
[ 33%] Building CXX object src/CMakeFiles/irony-server.dir/support/TemporaryFile.cpp.o
[ 50%] Building CXX object src/CMakeFiles/irony-server.dir/Command.cpp.o
[ 66%] Building CXX object src/CMakeFiles/irony-server.dir/Irony.cpp.o
[ 83%] Building CXX object src/CMakeFiles/irony-server.dir/TUManager.cpp.o
[100%] Building CXX object src/CMakeFiles/irony-server.dir/main.cpp.o
Linking CXX executable ../bin/irony-server
[100%] Built target irony-server
/tmp/build-irony $ ./bin/irony-server --version
dyld: Library not loaded: @rpath/libclangAST.dylib
  Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib
  Reason: image not found
trace/BPT trap: 5

Further Suggestions

@Sarcasm Thanks for all the help so far, I hope this output that I gave you is helpful. I hope we can come up with a solution.

Sarcasm commented 9 years ago

Can you add -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON to your cmake command line and repeat the tests?

codekingplusplus commented 9 years ago

Here is the output:

-_- mode: compilation; default-directory: "/var/folders/kf/9ybd9l55sx4ktk77r831q600000gn/T/build-irony-server-0.2.0-cvs4/" -- Compilation started at Wed Jun 17 13:01:04

cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_PREFIX\=/Users/thutmose/.emacs.d/irony/ /Users/thutmose/.emacs.d/elpa/irony-20150614.1225/server && cmake --build . --use-stderr --config Release --target install -- Detecting libclang builtin headers directory -- Detecting libclang builtin headers directory -- fail CMake Warning at cmake/CheckLibClangBuiltinHeadersDir.cmake:87 (message): CheckLibClangBuiltinHeadersDir: unsupported configuration, please report.

Check with args: -isystem;"/usr/local/Cellar/llvm/3.6.0/lib/clang/3.6.0/include";/var/folders/kf/9_ybd9l55sx4ktk77r831q600000gn/T/CMakeFiles/CMakeTmp/check-libclang-stddef.cpp
Check output:
  dyld: Library not loaded: @rpath/libclangAST.dylib
Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib
Reason: image not found

SIGTRAP

Call Stack (most recent call first): src/CMakeLists.txt:8 (check_libclang_builtin_headers_dir)

-- Irony package version is '0.2.0-cvs4' -- Found emacs: /usr/bin/emacs -- Configuring done -- Generating done -- Build files have been written to: /var/folders/kf/9_ybd9l55sx4ktk77r831q600000gn/T [100%] Built target irony-server Install the project... -- Install configuration: "Release" -- Installing: /Users/thutmose/.emacs.d/irony/bin/irony-server

Compilation finished at Wed Jun 17 13:01:04

Sarcasm commented 9 years ago

Can you run ./bin/irony-server --version. Not 100% sure the test binaries have the rpath set.

I'm sorry, apart from that I don't know much what to do. Maybe @tsukimizake can help?

Maybe you will have a better luck on stackexchange asking question about rpath and stuff. I don't know the tools to inspect the rpath, to list the libraries that aren't found, ...

codekingplusplus commented 9 years ago

It tells me the same thing as last time:

~/.emacs.d/irony $ ./bin/irony-server --version dyld: Library not loaded: @rpath/libclangAST.dylib Referenced from: /usr/local/opt/llvm/lib/libclang.3.6.dylib Reason: image not found trace/BPT trap: 5

Yeah, thanks for all the help again. I'll have to read more about the rpath.

Sarcasm commented 9 years ago

I'm interested by any solution you can find, so let the ticket open until you find one.

If you just want irony to works, I think you can download a working archive here: http://llvm.org/releases/

codekingplusplus commented 9 years ago

All I really want is Cocoa UI object/method completion (e.g. completion on the methods for the NSTextField class) what's the easiest way to get this capability?

Sarcasm commented 9 years ago

Probably to download the archive from http://llvm.org/releases/

You can an example here: https://github.com/Sarcasm/irony-mode/issues/138#issuecomment-65955439

codekingplusplus commented 9 years ago

Sweet! That works well!