Compile Fails on MacOS 10.13.1
YK-Unit opened this issue · 11 comments
Compile Fails on MacOS 10.13.1, here is the cmake log:
$ cmake ..
-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- 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
-- Building without sanitizers
CMake Error at /usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES) (found version "2.9.4")
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.9.3_1/share/cmake/Modules/FindLibXml2.cmake:56 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
lib/CMakeLists.txt:4 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/York/Downloads/LibEBC/build/CMakeFiles/CMakeOutput.log".
Here is the CMakeOutput.log
+1. Facing the same issue. Tried to make it work by giving custom paths, like so,
cmake .. -DLIBXML2_INCLUDE_DIR:PATH=/usr/include/libxml2/ -DLIBXML2_LIBRARIES:PATH=/usr/local/libxml2/lib -DLLVM_DIR:PATH=/usr/local/Cellar/llvm/5.0.0/lib/cmake/llvm -DBUILD_SHARED=OFF -DBUILD_TESTING=OFF
But now it's stuck at
[ 93%] Building CXX object tool/CMakeFiles/ebcutil.dir/ebcutil.cpp.o make[2]: *** No rule to make target
/usr/local/libxml2/lib', needed by tool/ebcutil'. Stop. make[1]: *** [tool/CMakeFiles/ebcutil.dir/all] Error 2 make: *** [all] Error 2
+2. Similar issue.
macOS 10.13.1 High Sierra
Xcode Version 9.1 (9B55)
brew installed libxml2
brew installed llvm
$git reset --hard HEAD && git pull
HEAD is now at 8f89102 Merge pull request #4 from dennisfrett/master
Already up-to-date.
$ mkdir build && cd build
$ cmake .. -DLIBXML2_INCLUDE_DIR:PATH=/usr/local/opt/libxml2/include/libxml2 -DLIBXML2_LIBRARIES:PATH=/usr/local/opt/libxml2/lib/libxml2 -DLLVM_DIR:PATH=/usr/local/opt/llvm/lib/cmake/llvm
-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working C compiler: /Applications/Xcode910.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode910.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/Xcode910.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode910.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
-- Building without sanitizers
-- Found LibXml2: /usr/local/opt/libxml2/lib/libxml2 (found version "2.9.7")
-- LLVM Hint:
-- Found LLVM 5.0.0
-- Looking for xar_open in xar
-- Looking for xar_open in xar - found
-- Building with libxar: xar
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/erik/Development/LibEBC/build
$ cmake --build .
Scanning dependencies of target ebc
[ 3%] Building CXX object lib/CMakeFiles/ebc.dir/src/BinaryMetadata.cpp.o
[ 7%] Building CXX object lib/CMakeFiles/ebc.dir/src/BitcodeArchive.cpp.o
[ 11%] Building CXX object lib/CMakeFiles/ebc.dir/src/BitcodeContainer.cpp.o
[ 15%] Building CXX object lib/CMakeFiles/ebc.dir/src/BitcodeMetadata.cpp.o
[ 19%] Building CXX object lib/CMakeFiles/ebc.dir/src/BitcodeRetriever.cpp.o
[ 23%] Building CXX object lib/CMakeFiles/ebc.dir/src/EmbeddedFile.cpp.o
[ 26%] Building CXX object lib/CMakeFiles/ebc.dir/src/EmbeddedFileFactory.cpp.o
[ 30%] Building CXX object lib/CMakeFiles/ebc.dir/src/EmbeddedXar.cpp.o
[ 34%] Building CXX object lib/CMakeFiles/ebc.dir/src/util/Bitcode.cpp.o
[ 38%] Building CXX object lib/CMakeFiles/ebc.dir/src/util/MachO.cpp.o
[ 42%] Building CXX object lib/CMakeFiles/ebc.dir/src/util/UUID.cpp.o
[ 46%] Building CXX object lib/CMakeFiles/ebc.dir/src/util/Xar.cpp.o
[ 50%] Building CXX object lib/CMakeFiles/ebc.dir/src/util/Xml.cpp.o
[ 53%] Linking CXX static library libebc.a
[ 53%] Built target ebc
Scanning dependencies of target ebctest
[ 57%] Building CXX object test/CMakeFiles/ebctest.dir/src/Main.cpp.o
[ 61%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestBinaryMetadata.cpp.o
[ 65%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestBitcodeArchive.cpp.o
[ 69%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestBitcodeContainer.cpp.o
[ 73%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestBitcodeMetadata.cpp.o
[ 76%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestBitcodeUtil.cpp.o
[ 80%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestEmbeddedBitcode.cpp.o
[ 84%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestUUID.cpp.o
[ 88%] Building CXX object test/CMakeFiles/ebctest.dir/src/TestXmlUtil.cpp.o
make[2]: *** No rule to make target /usr/local/opt/libxml2/lib/libxml2', needed by
test/ebctest'. Stop.
make[1]: *** [test/CMakeFiles/ebctest.dir/all] Error 2
make: *** [all] Error 2
Same issue
Can you try again after running brew link --force libxml2
? That does the trick for me.
So you're not using the system libxml2? Brew requires that you force it because they're reluctant to override the system libxml2
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/libxml2/lib
CPPFLAGS: -I/usr/local/opt/libxml2/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/libxml2/lib/pkgconfig
The better choice during cmake configure is to pass -D options or in the file set:
set( LIBXML2_INCLUDE_DIR /usr/local/opt/libxml2/include )
set( LIBXML2_LIBRARIES /usr/local/opt/libxml2/lib )
I'm having the same issue as the issue author. I tried some of the work arounds that @palmerc suggested, but it's just leading me down a rabbit hole of similar errors.
@tylermilner First, I'm a huge fan of rabbit holes.
Second,
MacBook-Pro:LibEBC-build palmerc$ cmake -DLIBXML2_LIBRARIES=/usr/local/opt/libxml2/lib -D LIBXML2_INCLUDE_DIR=/usr/local/opt/libxml2/include ../LibEBC
-- Building without sanitizers
-- Found LibXml2: /usr/local/opt/libxml2/lib (found version "2.9.4")
Passing the options as I suggested, given the correct path to your libxml2, gets FindLibrary to find libxml2.
However, this project still has a number of build issues related to libxml2 which means I'll have to look at fixing it. I originally looked at this project but gave up because I was short on time.
Stuff like this is popular amongst certain developers but considered bad form in CMake:
file(GLOB_RECURSE SOURCE_FILES ${SOURCE_DIR}/*.cpp)
and mostly put me off touching it previously.
So to get it to compile...
Taking a bit of deeper dive it seems that generally compiling on a Mac with Brew is problematic for this project. I had to add the following to CMakeLists.txt
under lib/
and test/
set( LIBXML2_INCLUDE_DIR /usr/local/opt/libxml2/include/libxml2 )
set( ZLIB_ROOT /usr/local/opt/zlib )
# LibXml2 Dependency
find_package(LibXml2 REQUIRED
HINTS /usr/local/opt/libxml2 )
include_directories(${LIBXML2_INCLUDE_DIR})
The issue is that there isn't a variable for LibXML2 to hint where to look. ZLIB_ROOT and LLVM_DIR both hint the location for those projects. The include directory for XML2 has an additional directory so you need to correct that.
Seems that to clue CMake into the correct location and avoid adding HINTS
or PATHS
to the find_package command you can just do this at the command-line:
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/libxml2 ../LibEBC
The hints and suggestions in this thread helped me pull off a successful build on my mac - thanks guys!
Same issue.
I had to install libxm2, zlib and llvm via homebrew
brew install libxml2 brew install zlib brew install llvm
And as suggested @palmrec had to pass CMAK_PREFIX_PATH with libxml2 and zlib, also need to specify LLVM_DIR variable
LLVM_DIR="/usr/local/Cellar/llvm/11.1.0/lib/cmake/llvm" cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/libxml2 -DCMAKE_PREFIX_PATH=/usr/local/opt/zlib ..
`
OS: Big Sur 11.0.1