GithubHelp home page GithubHelp logo

MacOS: Build error about fltrdr HOT 12 CLOSED

winderickxeli avatar winderickxeli commented on August 18, 2024 2
MacOS: Build error

from fltrdr.

Comments (12)

gh0stl4b avatar gh0stl4b commented on August 18, 2024 2

I've got it to compile by adding

set (CMAKE_C_COMPILER /usr/local/bin/gcc-8)
set (CMAKE_CXX_COMPILER /usr/local/bin/g++-8)

and then just running cmake . in the project root, after you just run the typical make install and you're done.

my uname:
Darwin ####### 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

from fltrdr.

octobanana avatar octobanana commented on August 18, 2024 1

Was the llvm binary installed by you, or is it the default Apple llvm compiler?

If it's one installed by you, try appending these two lines to the CMakeLists.txt file,
where <path-to-clang> is the canonical path to the clang and clang++ binaries:

set (CMAKE_C_COMPILER <path-to-clang>)
set (CMAKE_CXX_COMPILER <path-to-clang++>)

from fltrdr.

knowler avatar knowler commented on August 18, 2024 1

I was running into this issue as well and here’s what I tried:

  • Installed llvm with Homebrew and configured the compiler paths in CMakeLists.txt.
  • Ran /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg since I guess macOS Mojave (10.14) doesn’t install the headers in /usr/include.

The library linking error still persisted and as far as I could tell — I’m not a C++ developer — the library simply isn’t on the system at all. So at this point, my desire to use this awesome tool overcame my desire to get the bottom of why the libraries were missing (or where they are if they do exist) and I ended up using boost::filesystem instead and it compiles fine.

Here’s the changes I made to get it to work (again, not a C++ developer):

  • Install Boost with Homebrew (i.e. brew install boost)
  • Make the following code changes:

src/fltrdr/tui.cc

-#include <filesystem>
-namespace fs = std::filesystem;
+#include <boost/filesystem/operations.hpp>
+namespace fs = boost::filesystem;

CMakeLists.txt

+FIND_PACKAGE( Boost 1.68 COMPONENTS system filesystem REQUIRED )
+INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
+
 target_link_libraries (
   ${TARGET}
-  stdc++fs
+  ${Boost_LIBRARIES}
 )

from fltrdr.

noqqe avatar noqqe commented on August 18, 2024

Having the same issue.

Appending the lines on macOS also does not work :(

from fltrdr.

joelparkerhenderson avatar joelparkerhenderson commented on August 18, 2024

Same issue.

My guess is that it's essentially because macOS and the default clang do not put the filesystem header in the same place. See this discussion: https://stackoverflow.com/questions/42633477/macos-clang-c17-filesystem-header-not-found

$ ./install.sh

Setting Environment Variables

Setting Environment Variables

Building fltrdr in release mode

Compiling fltrdr
CMAKE_BUILD_TYPE is release
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/fltrdr/build/release
[ 16%] Building CXX object CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o
clang: warning: argument unused during compilation: '-s' [-Wunused-command-line-argument]
/opt/fltrdr/src/fltrdr/tui.cc:27:10: fatal error: 'filesystem' file not found
#include <filesystem>
         ^~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o] Error 1
make[1]: *** [CMakeFiles/fltrdr.dir/all] Error 2
make: *** [all] Error 2

real	0m0.647s
user	0m0.543s
sys	0m0.082s

$ which clang
/usr/bin/clang

$ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ which clang++
/usr/bin/clang++

$ clang++ --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ uname -a
Darwin Mains-MacBook-Pro.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Oct 10 23:06:14 PDT 2018; root:xnu-4570.71.13~1/RELEASE_X86_64 x86_64

I tried adding the CMAKE lines as described in the GitHub issue above, to point to clang and clang++. No effect.

I'm going to try installing a newer llvm then adjusting the path e.g.:

brew install llvm

https://stackoverflow.com/questions/42633477/macos-clang-c17-filesystem-header-not-found

from fltrdr.

foobert avatar foobert commented on August 18, 2024

Installing llvm via brew and configuring it in CMakeLists.txt gets me a bit further: it compiles but doesn't link.

ld: library not found for -lstdc++fs
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)

from fltrdr.

octobanana avatar octobanana commented on August 18, 2024

@knowler I'm glad you got it to work! Although, switching to the Boost filesystem library shouldn't be necessary. I think it's possible to link the std::filesystem library properly with running either brew link gcc or brew link llvm after install. Then adding the two CMake lines shown above should allow it to compile properly.

from fltrdr.

winderickxeli avatar winderickxeli commented on August 18, 2024

Hi @octobanana

To recaps what I've done so far:

  • brew install gcc llvm clang
  • brew link gcc ( I wasn't able to link llvm. I got this error:
Warning: Refusing to link macOS-provided software: llvm
If you need to have llvm first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"

to which I added the llvm folder to my path as shown above.)

  • added the two lines of code to CMakeLists.txt
set (CMAKE_C_COMPILER <path-to-clang>)
set (CMAKE_CXX_COMPILER <path-to-clang++>)

so far I'm still having problems. I haven't tried the solution @knowler presented since you thought it should work with llvm and gcc.

Thanks for taking the time to help us with this issue.

from fltrdr.

octobanana avatar octobanana commented on August 18, 2024

@winderickxeli since you installed and linked gcc, use the path to the gcc binaries in the CMakeLists.txt file. One compiler is enough, and since it looks like llvm has issues with the default library, going with gcc seems to be the better option.

Make sure to replace the path arguments, they will probably look something like the following:

set (CMAKE_C_COMPILER /usr/local/bin/gcc-8)
set (CMAKE_CXX_COMPILER /usr/local/bin/g++-8)

from fltrdr.

winderickxeli avatar winderickxeli commented on August 18, 2024

@gh0stl4b , @octobanana I added the lines as suggested and boom! It works really nice!
Build.sh works without errors and then install.sh without errors.
Could not be happier! Thanks for assist!

from fltrdr.

Di9 avatar Di9 commented on August 18, 2024

Hi all!
I've set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER,
also linked some /include/ libs, but still got error on the last step:

Setting Environment Variables

Building fltrdr in release mode

Compiling fltrdr
-- The C compiler identification is GNU 9.1.0
-- The CXX compiler identification is GNU 9.1.0
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/local/bin/gcc-9
-- Check for working C compiler: /usr/local/bin/gcc-9 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++-9
-- Check for working CXX compiler: /usr/local/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_BUILD_TYPE is release
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/User/git/fltrdr/build/release
Scanning dependencies of target fltrdr
[ 14%] Building CXX object CMakeFiles/fltrdr.dir/src/main.cc.o
[ 28%] Building CXX object CMakeFiles/fltrdr.dir/src/ob/crypto.cc.o
[ 42%] Building CXX object CMakeFiles/fltrdr.dir/src/ob/string.cc.o
[ 57%] Building CXX object CMakeFiles/fltrdr.dir/src/ob/readline.cc.o
[ 71%] Building CXX object CMakeFiles/fltrdr.dir/src/fltrdr/tui.cc.o
[ 85%] Building CXX object CMakeFiles/fltrdr.dir/src/fltrdr/fltrdr.cc.o
[100%] Linking CXX executable fltrdr
ld: warning: option -s is obsolete and being ignored
ld: library not found for -licuuc
collect2: error: ld returned 1 exit status
make[2]: *** [fltrdr] Error 1
make[1]: *** [CMakeFiles/fltrdr.dir/all] Error 2
make: *** [all] Error 2```

Could you help me?

from fltrdr.

octobanana avatar octobanana commented on August 18, 2024

@Di9 The list of dependencies can be found here. It looks like the build fails at the linking stage, so your system is either missing the ICU library or it can't be found.

ICU can be installed through brew with the icu4c package.
Take a look at this stackoverflow answer on installing the ICU library.

I don't have a macOS setup at the moment to test. If you wouldn't mind writing down the steps you take to install and configure the ICU library, I could add them to the build instructions to help out others building on macOS.

Let me know how it goes!

from fltrdr.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.