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 failed on macOS using brew (Cmake: jsoncpp not found) #62

Open
zhovner opened this issue Aug 21, 2019 · 13 comments
Open

Build failed on macOS using brew (Cmake: jsoncpp not found) #62

zhovner opened this issue Aug 21, 2019 · 13 comments

Comments

@zhovner
Copy link

zhovner commented Aug 21, 2019

I've try to build it using brew formula

brew install https://raw.githubusercontent.com/insomniacslk/dublin-traceroute/master/homebrew/dublin-traceroute.rb

and get this error:

==> cmake . -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/dublin-traceroute/0.4.2 -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -D
Last 15 lines from /Users/a/Library/Logs/Homebrew/dublin-traceroute/01.cmake:
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- libtins found via CMake
-- Checking for one of the modules 'jsoncpp'
CMake Error at /usr/local/Cellar/cmake/3.15.2/share/cmake/Modules/FindPkgConfig.cmake:696 (message):
  None of the required 'jsoncpp' found
Call Stack (most recent call first):
  CMakeLists.txt:42 (pkg_search_module)


-- googletest git submodule is absent. Run `git submodule init && git submodule update` to get it
-- Configuring incomplete, errors occurred!
See also "/tmp/dublin-traceroute-20190821-40946-p6478r/dublin-traceroute-0.4.2/CMakeFiles/CMakeOutput.log".

Do not report this issue to Homebrew/brew or Homebrew/core!

Package jsoncpp is installed. Probably you have jsoncpp-devel instelled on your system?

@insomniacslk
Copy link
Owner

hey @zhovner , I don't have a Mac to test this on, but the CI seems to work just fine on OSX. The dependencies are installed according to this script, https://github.com/insomniacslk/dublin-traceroute/blob/master/.travis/install_dependencies_osx.sh . Can you try to run these commands first, then retry the brew install dublin-traceroute.rb ?

Also, which version of OSX are you on?

Meanwhile I'll add this test to the CI as well.

@zhovner zhovner changed the title Build failed on macOS using brew (jsoncpp not found) Build failed on macOS using brew (Cmake: jsoncpp not found) Aug 21, 2019
@zhovner
Copy link
Author

zhovner commented Aug 21, 2019

CI seems to work just fine on OSX

What is CI?

The dependencies are installed according to this script

All dependencies are already installed by homebrew formula and I have jsoncpp package installed:

$ ls -la  /usr/local/include/json/
total 184
drwxr-xr-x  13 a  staff    416 Jul 12 00:38 .
drwxr-xr-x   3 a  staff     96 Jul 12 00:38 ..
-rw-r--r--   1 a  staff   2499 Jul 12 00:38 allocator.h
-rw-r--r--   1 a  staff   2643 Jul 12 00:38 assertions.h
-rw-r--r--   1 a  staff    686 Jul 12 00:38 autolink.h
-rw-r--r--   1 a  staff   6226 Jul 12 00:38 config.h
-rw-r--r--   1 a  staff   1811 Jul 12 00:38 features.h
-rw-r--r--   1 a  staff    912 Jul 12 00:38 forwards.h
-rw-r--r--   1 a  staff    444 Jul 12 00:38 json.h
-rw-r--r--   1 a  staff  13801 Jul 12 00:38 reader.h
-rw-r--r--   1 a  staff  28422 Jul 12 00:38 value.h
-rw-r--r--   1 a  staff    815 Jul 12 00:38 version.h
-rw-r--r--   1 a  staff  12142 Jul 12 00:38 writer.h

and pkg file:

ls -la /usr/local/lib/pkgconfig/jsoncpp.pc
/usr/local/lib/pkgconfig/jsoncpp.pc -> ../../Cellar/jsoncpp/1.9.1/lib/pkgconfig/jsoncpp.pc

It's all symlinked to this jsoncpp package files:

$ brew list jsoncpp
/usr/local/Cellar/jsoncpp/1.9.1/include/json/ (11 files)
/usr/local/Cellar/jsoncpp/1.9.1/lib/libjsoncpp.1.9.0.dylib
/usr/local/Cellar/jsoncpp/1.9.1/lib/cmake/ (3 files)
/usr/local/Cellar/jsoncpp/1.9.1/lib/pkgconfig/jsoncpp.pc
/usr/local/Cellar/jsoncpp/1.9.1/lib/ (2 other files)

I'm using latest macOS Mojave 10.14.6 (18G87) and latest packages from brew.

@insomniacslk
Copy link
Owner

What's the output of pkg-config --libs --cflags jsoncpp?

@insomniacslk
Copy link
Owner

insomniacslk commented Aug 21, 2019

I wonder if PKG_CONFIG_PATH is pointing to the correct location. According to https://linux.die.net/man/1/pkg-config :

PKG_CONFIG_PATH

A colon-separated (on Windows, semicolon-separated)
list of directories to search for .pc files. The default
directory will always be searched after searching
the path; the default is libdir/pkgconfig:datadir/pkgconfig
where libdir is the libdir where pkg-config and datadir
is the datadir where pkg-config was installed

@insomniacslk
Copy link
Owner

insomniacslk commented Aug 21, 2019

CI seems to work just fine on OSX

What is CI?

Continuous Integration, the automation that I use to build and test dublin-traceroute on linux and osx at every commit

@zhovner
Copy link
Author

zhovner commented Aug 21, 2019

What's the output of pkg-config --libs --cflags jsoncpp?

-I/usr/local/Cellar/jsoncpp/1.9.1/include -L/usr/local/Cellar/jsoncpp/1.9.1/lib -ljsoncpp

@insomniacslk
Copy link
Owner

I'm struggling to reproduce the issue here, and I won't have access to a macOS device before next week (because of holidays abroad).

Meanwhile I'm trying to understand from the cmake documentation what could be failing to find the package via pkg-config

@insomniacslk
Copy link
Owner

FYI the PR where I'm trying to reproduce the issue is #64

@fra-iesus
Copy link

Hi there, I have the same issue (macOS version is the same as well). In case any check on my side could be done to speed up the fixation, just let me know.
Thanks.

@supertylerc
Copy link

Hello. I've experienced the same issue. I had to fix it by setting LIBRARY_PATH. Before:

$ make
[ 75%] Built target dublintraceroute
[ 87%] Linking CXX executable dublin-traceroute
ld: library not found for -ljsoncpp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dublin-traceroute] Error 1
make[1]: *** [CMakeFiles/dublin-traceroute.dir/all] Error 2
make: *** [all] Error 2

After:

$ LIBRARY_PATH=/usr/local/opt/jsoncpp/lib make

[ 75%] Built target dublintraceroute
[ 87%] Linking CXX executable dublin-traceroute
[100%] Built target dublin-traceroute

@Leonkoithara
Copy link

Hi I am not a user of this project however I came across this exact same issue. I couldn't find this in the JsonCPP project documentation but the fix for me was to use ${JSONCPP_LINK_LIBRARIES} in target_link_libraries in CMakeLists.txt. E.g:

cmake_minimum_required(VERSION 3.22)
set(CMAKE_CXX_STANDARD 11)

find_package(PkgConfig REQUIRED)
pkg_check_modules(JSONCPP jsoncpp)

add_executable(utils main.cpp)

target_link_libraries(
    utils
    ${JSONCPP_LINK_LIBRARIES}
)

@jagibson
Copy link

This is what I had to do for Apple Silicon since homebrew is installed to /opt/homebrew, not /usr/local.

sed -i txt 's#/usr/local#/opt/homebrew#' CMakeLists.txt
mkdir build ; cd build
cmake ..
LIBRARY_PATH=/opt/homebrew/opt/jsoncpp/lib make

@insomniacslk
Copy link
Owner

CMakeLists.txt requires a lot of rework to compile on modern platforms, I'll take a look at it when I have time, but I'm happy to review a PR if someone is willing to do that

LIBRARY_PATH=/opt/homebrew/opt/jsoncpp/lib

If you don't have a standard homebrew installation path, just replace /opt/homebrew/opt with the output of brew --prefix jsoncpp

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

No branches or pull requests

6 participants