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

macOS下编译失败 #247

Closed
shuxiao9058 opened this Issue Jan 14, 2019 · 18 comments

Comments

Projects
None yet
4 participants
@shuxiao9058
Copy link

shuxiao9058 commented Jan 14, 2019

 librime (master) ✗ make -f Makefile.xcode                                                                                                                                                                                                                (master|✚1

cmake . -Bxbuild -GXcode -DBUILD_STATIC=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
-- Failed to find all ICU components (missing: ICU_INCLUDE_DIR ICU_LIBRARY)
-- Boost version: 1.68.0
-- Found the following Boost libraries:
--   filesystem
--   regex
--   system
--   locale
-- Found gflags: /usr/local/lib/libgflags.dylib
-- Found glog: /Users/jiya/workspace/librime/thirdparty/lib/libglog.a
-- Found yaml-cpp: /Users/jiya/workspace/librime/thirdparty/lib/libyaml-cpp.a
-- Found leveldb: /Users/jiya/workspace/librime/thirdparty/lib/libleveldb.a
-- Found marisa: /Users/jiya/workspace/librime/thirdparty/lib/libmarisa.a
-- Found opencc: /Users/jiya/workspace/librime/thirdparty/lib/libopencc.a
-- Found X11/keysym.h at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Headers
-- Configuring done
CMake Warning (dev):
  Policy CMP0068 is not set: RPATH settings on macOS do not affect
  install_name.  Run "cmake --help-policy CMP0068" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, the install_name fields for
  the following targets are still affected by RPATH settings:

   rime

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/jiya/workspace/librime/xbuild
cmake --build xbuild --config Release
Prepare build
note: Using legacy build system

=== BUILD AGGREGATE TARGET ZERO_CHECK OF PROJECT rime WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/jiya/workspace/librime/xbuild/rime.build/Release/ZERO_CHECK.build/Script-24087AEA11E14D0494FA810C.sh
chmod 0755 /Users/jiya/workspace/librime/xbuild/rime.build/Release/ZERO_CHECK.build/Script-24087AEA11E14D0494FA810C.sh

PhaseScriptExecution CMake\ Rules xbuild/rime.build/Release/ZERO_CHECK.build/Script-24087AEA11E14D0494FA810C.sh
    cd /Users/jiya/workspace/librime
    /bin/sh -c /Users/jiya/workspace/librime/xbuild/rime.build/Release/ZERO_CHECK.build/Script-24087AEA11E14D0494FA810C.sh
echo ""

make -f /Users/jiya/workspace/librime/xbuild/CMakeScripts/ReRunCMake.make
make[2]: `/Users/jiya/workspace/librime/xbuild/CMakeFiles/cmake.check_cache' is up to date.

=== BUILD TARGET rime OF PROJECT rime WITH CONFIGURATION Release ===

Check dependencies

Write auxiliary files
write-file /Users/jiya/workspace/librime/xbuild/src/rime.build/Release/rime.build/Script-3C00F4D8CD5D4DB8872F8C9C.sh
chmod 0755 /Users/jiya/workspace/librime/xbuild/src/rime.build/Release/rime.build/Script-3C00F4D8CD5D4DB8872F8C9C.sh

Ld xbuild/lib/Release/librime.1.3.2.dylib normal x86_64
    cd /Users/jiya/workspace/librime
    export MACOSX_DEPLOYMENT_TARGET=10.14
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -L/Users/jiya/workspace/librime/xbuild/lib/Release -L/usr/local/lib/Release -L/usr/local/lib -L/Users/jiya/workspace/librime/thirdparty/lib/Release -L/Users/jiya/workspace/librime/thirdparty/lib -F/Users/jiya/workspace/librime/xbuild/lib/Release -filelist /Users/jiya/workspace/librime/xbuild/src/rime.build/Release/rime.build/Objects-normal/x86_64/rime.1.3.2.LinkFileList -install_name /librime.1.3.2.dylib -mmacosx-version-min=10.14 -dynamiclib -Wl,-headerpad_max_install_names -install_name @rpath/librime.1.dylib /usr/local/lib/libboost_filesystem-mt.a /usr/local/lib/libboost_regex-mt.a /usr/local/lib/libboost_system-mt.a /usr/local/lib/libboost_locale-mt.a /Users/jiya/workspace/librime/thirdparty/lib/libglog.a /Users/jiya/workspace/librime/thirdparty/lib/libyaml-cpp.a /usr/local/lib/libgflags.dylib /usr/lib/libiconv.dylib /Users/jiya/workspace/librime/thirdparty/lib/libleveldb.a /Users/jiya/workspace/librime/thirdparty/lib/libmarisa.a /Users/jiya/workspace/librime/thirdparty/lib/libopencc.a -compatibility_version 1.0.0 -current_version 1.3.2 -Xlinker -dependency_info -Xlinker /Users/jiya/workspace/librime/xbuild/src/rime.build/Release/rime.build/Objects-normal/x86_64/rime.1.3.2_dependency_info.dat -o /Users/jiya/workspace/librime/xbuild/lib/Release/librime.1.3.2.dylib
ld: warning: directory not found for option '-L/usr/local/lib/Release'
ld: warning: directory not found for option '-L/Users/jiya/workspace/librime/thirdparty/lib/Release'
Undefined symbols for architecture x86_64:
  "_UCNV_FROM_U_CALLBACK_SKIP_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_UCNV_FROM_U_CALLBACK_STOP_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_UCNV_TO_U_CALLBACK_SKIP_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_UCNV_TO_U_CALLBACK_STOP_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "icu_63::UnicodeString::append(int)", referenced from:
      boost::locale::impl_icu::icu_std_converter<wchar_t, 4>::icu_checked(wchar_t const*, wchar_t const*) const in libboost_locale-mt.a(codepage.o)
  "icu_63::UnicodeString::UnicodeString(char const*, int, UConverter*, UErrorCode&)", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu(char const*, char const*) const in libboost_locale-mt.a(codepage.o)
  "icu_63::UnicodeString::UnicodeString(int, int, int)", referenced from:
      boost::locale::impl_icu::icu_std_converter<wchar_t, 4>::icu_checked(wchar_t const*, wchar_t const*) const in libboost_locale-mt.a(codepage.o)
  "icu_63::UnicodeString::~UnicodeString()", referenced from:
      boost::locale::conv::impl::uconv_between::convert(char const*, char const*) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu(char const*, char const*) const in libboost_locale-mt.a(codepage.o)
      boost::locale::conv::impl::uconv_to_utf<char>::convert(char const*, char const*) in libboost_locale-mt.a(codepage.o)
      boost::locale::conv::impl::uconv_from_utf<char>::convert(char const*, char const*) in libboost_locale-mt.a(codepage.o)
      boost::locale::conv::impl::uconv_to_utf<wchar_t>::convert(char const*, char const*) in libboost_locale-mt.a(codepage.o)
      boost::locale::conv::impl::uconv_from_utf<wchar_t>::convert(wchar_t const*, wchar_t const*) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<wchar_t, 4>::icu_checked(wchar_t const*, wchar_t const*) const in libboost_locale-mt.a(codepage.o)
      ...
  "_u_errorName_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu(char const*, char const*) const in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::go(char16_t const*, int, int) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<wchar_t, 4>::std(icu_63::UnicodeString const&) const in libboost_locale-mt.a(codepage.o)
  "_u_strToUTF32_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<wchar_t, 4>::std(icu_63::UnicodeString const&) const in libboost_locale-mt.a(codepage.o)
  "_ucnv_close_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu_std_converter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::std(icu_63::UnicodeString const&) const in libboost_locale-mt.a(codepage.o)
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu(char const*, char const*) const in libboost_locale-mt.a(codepage.o)
  "_ucnv_fromUChars_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::go(char16_t const*, int, int) in libboost_locale-mt.a(codepage.o)
  "_ucnv_getMaxCharSize_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::icu_std_converter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_ucnv_open_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_ucnv_setFromUCallBack_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
  "_ucnv_setToUCallBack_63", referenced from:
      boost::locale::impl_icu::icu_std_converter<char, 1>::uconv::uconv(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, boost::locale::impl_icu::cpcvt_type) in libboost_locale-mt.a(codepage.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **
@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 14, 2019

Try commenting out the find_package(Iconv) line in CMakeLists.txt, clear build/ and re-run cmake.
Otherwise it has to do with boost build/install options.

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 14, 2019

Compare your first-time build log to
https://travis-ci.org/rime/librime/jobs/479235614
to see what's different.

@kuoruan

This comment has been minimized.

Copy link

kuoruan commented Jan 16, 2019

Same issue here.

@shuxiao9058

This comment has been minimized.

Copy link
Author

shuxiao9058 commented Jan 18, 2019

Try commenting out the find_package(Iconv) line in CMakeLists.txt, clear build/ and re-run cmake.
Otherwise it has to do with boost build/install options.

试了这个操作,还是有问题!

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 18, 2019

Otherwise it has to do with boost build/install options.

@shuxiao9058

This comment has been minimized.

Copy link
Author

shuxiao9058 commented Jan 18, 2019

Otherwise it has to do with boost build/install options.

我是直接用brew安装的boost,你说的这个选项在哪能看得到?

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 18, 2019

The error shows boost was trying to link to uconv_* functions, which belongs to ICU library, one of the optional backends of boost::locale.
By default it should use /usr/lib/libiconv.dylib which macOS provides.
You probably have ICU library installed but not for the same architecture.
The log you attached seems to be a rebuild rather than a clean build, it doesn't show full information CMake look for libraries.

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 18, 2019

By the way, /usr/local/lib/libgflags.dylib is another optional library linked to your build.
The build will only work on your own machine, because libgflags.dylib isn't provided by the system but installed locally.

@wwwjfy

This comment has been minimized.

Copy link

wwwjfy commented Jan 19, 2019

I tried to install boost by source brew install --build-from-source boost and still met the same issue.
Is there compatibility issue with boost versions? I'm using 1.68 (from latest brew)

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 19, 2019

as i said earlier it might be an issue with boost's optional dependencies, icu4c in particular.
compare your build log (cmake output and linking options) to
https://travis-ci.org/rime/squirrel/builds/481759893
pay attention to anything from /usr/local/; that could be the offending library.

@wwwjfy

This comment has been minimized.

Copy link

wwwjfy commented Jan 19, 2019

Thanks for providing a successful build log, so I can find out what's wrong.
It turns out to be the boost version. The latest boost version installed by homebrew is 1.68, and in the travis log, it's 1.67.
I successfully built and installed Squirrel by

brew uninstall boost
brew install boost@1.60
set -gx BOOST_ROOT /usr/local/opt/boost@1.60/
make deps
make
sudo make install
@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 19, 2019

I see what the problem is.

$ brew info boost
boost: stable 1.68.0 (bottled), HEAD
Collection of portable C++ source libraries
https://www.boost.org/
/usr/local/Cellar/boost/1.67.0_1 (13,506 files, 456.4MB) *
  Poured from bottle on 2018-10-21 at 12:12:20
From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/boost.rb
==> Dependencies
Required: icu4c ✘
==> Options
--HEAD
	Install HEAD version
==> Caveats
Building of Boost.Log is disabled because it requires newer GCC or Clang.

homebrew is installing icu4c as dependency of boost starting from v1.68.
any version of boost manually built from source or previous versions installed via homebrew (my case) should not have ICU libraries available by default.

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 20, 2019

It was this commit in homebrew formula
Homebrew/homebrew-core@4c9da08#diff-5148b5dd1fa3716ad2777ce49eaf03a9
that changed boost's default build options from --without-icu to --with-icu=....

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 20, 2019

To fix, either build boost with --without-icu option, or build librime with this patch:
https://github.com/rime/librime/tree/with-icu
note that it'll link against locally installed ICU library.

@shuxiao9058

This comment has been minimized.

Copy link
Author

shuxiao9058 commented Jan 20, 2019

To fix, either build boost with --without-icu option, or build librime with this patch:
https://github.com/rime/librime/tree/with-icu
note that it'll link against locally installed ICU library.

Thanks a lot, it works fine now.

@lotem lotem closed this in d15662a Jan 20, 2019

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 20, 2019

Unfortunately with-icu branch cannot be merged to master as it'll create non-portable binary.
Resolved by putting up a notice in https://github.com/rime/librime/blob/master/README-mac.md

@lotem

This comment has been minimized.

Copy link
Member

lotem commented Jan 21, 2019

On this machine I installed boost=1.68.0 earlier, icu4c was still an optional dependency, and --with-icu4c wasn't the default compile option.

brew info boost
boost: stable 1.68.0 (bottled), HEAD
Collection of portable C++ source libraries
https://www.boost.org/
/usr/local/Cellar/boost/1.62.0 (12,405 files, 396.4MB)
  Poured from bottle on 2016-11-22 at 15:21:58
/usr/local/Cellar/boost/1.67.0_1 (13,506 files, 450.9MB)
  Poured from bottle on 2018-07-14 at 14:54:32
/usr/local/Cellar/boost/1.68.0 (13,712 files, 460.2MB) *
  Poured from bottle on 2018-11-26 at 11:42:32
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/boost.rb
==> Dependencies
Optional: icu4c ✔
==> Options
--with-icu4c
	Build regexp engine with icu support
--without-single
	Disable building single-threading variant
--without-static
	Disable building static library variant
--HEAD
	Install HEAD version
==> Analytics
install: 66,340 (30 days), 193,361 (90 days), 650,242 (365 days)
install_on_request: 18,898 (30 days), 55,596 (90 days), 192,660 (365 days)
build_error: 0 (30 days)

librime build successfully with this boost installation. This clearly shows it's not related to the version of boost libraries but changes in boost's default compile options in homebrew formula.

otool -L build/Release/Squirrel.app/Contents/Frameworks/librime.1.dylib
build/Release/Squirrel.app/Contents/Frameworks/librime.1.dylib:
	@rpath/librime.1.dylib (compatibility version 1.0.0, current version 1.4.0)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
@wwwjfy

This comment has been minimized.

Copy link

wwwjfy commented Jan 21, 2019

Right, I got the same result.

Interesting. Homebrew wants to remove all options.
Homebrew/homebrew-core#31510
Homebrew/homebrew-core#35735

Is it possible for it to detect such cases?

@lotem lotem referenced this issue Jan 21, 2019

Closed

build failed #293

hchunhui added a commit to hchunhui/librime that referenced this issue Jan 21, 2019

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