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 of retdec-config fails with "undefined reference to Json::Value" #52

Closed
rchatsiri opened this issue Dec 19, 2017 · 13 comments
Closed

Comments

@rchatsiri
Copy link

I compile the Retdec source code. Error from compiling was showed an error as below.

[ 32%] Linking CXX executable retdec-config
../retdec-config/libretdec-config.a(architecture.cpp.o): In function `retdec_config::Architecture::getJsonValue() const':
architecture.cpp:(.text+0x4cd): undefined reference to `Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x4da): undefined reference to `Json::Value::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x521): undefined reference to `Json::Value::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x5ce): undefined reference to `Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x5db): undefined reference to `Json::Value::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x616): undefined reference to `Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
architecture.cpp:(.text+0x623): undefined reference to `Json::Value::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

I check command line generate an error result again with $make VERBOSE=1. Error present as below.

cd /retdec/build/deps/fileformat/deps/retdec-config/src/retdec-configtool && cmake -E cmake_link_script CMakeFiles/retdec-configtool.dir/link.txt --verbose=1
/usr/local/bin/c++  -O3 -DNDEBUG   CMakeFiles/retdec-configtool.dir/retdec-configtool.cpp.o  -o retdec-config -Wl,-rpath,:::::::::::::: ../retdec-config/libretdec-config.a ../../../../../capstone2llvmir/deps/tl-cpputils/src/tl-cpputils/libtl-cpputils.a ../../../../../fnc-patterns/deps/fileformat/deps/retdec-config/deps/jsoncpp/jsoncpp-project-prefix/src/jsoncpp-project-build/src/lib_json/libjsoncpp.a /usr/local/lib64/libjsoncpp.a 
../retdec-config/libretdec-config.a(architecture.cpp.o): In function `retdec_config::Architecture::getJsonValue() const':
architecture.cpp:(.text+0x4cd): undefined reference to `Json::Value::Value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

Cross check library path of Jsoncpp library install in /usr/local/lib64/ completed.

@s3rvac s3rvac changed the title Retdec_config unreference to json cpp library. Build of retdec-config fails with "undefined reference to Json::Value" Dec 20, 2017
@s3rvac
Copy link
Member

s3rvac commented Dec 20, 2017

Hi. Can you please provide the following details so we can investigate this further?

  • What Linux distribution and version do you use?
  • What CMake version do you use?
  • What was the cmake command that you used before make?
  • What compiler and version did you use for build?
  • From what you have written, I assume that you have jsoncpp installed in your system. Correct?

@rchatsiri
Copy link
Author

  • Source code build on Linux-AWS-AMI
  • Cmake version 3.10.1
  • Yes, I was run Cmake before use a Make command line.
  • GCC version 5.3.0
  • That path to install the Jsoncpp files are /usr/local/lib64/. Path file contain library such as libjsoncpp.so.1.8.3 , libjsoncpp.so, libjsoncpp.so.a. Library and include files of the Jsoncpp compiled from source code.

@rchatsiri
Copy link
Author

rchatsiri commented Dec 21, 2017

I think should close that issues because found the way to built step completed. The root cause $make -j4 command line instead of $make as manual suggested.

@s3rvac
Copy link
Member

s3rvac commented Dec 21, 2017

There is no need to close as make -j4 is valid. From the output that you provided, it seems that jsoncpp is linked twice on your system when building retdec-config:

/usr/local/bin/c++ [..] retdec-configtool.cpp.o [..]
    jsoncpp/jsoncpp-project-prefix/[..]/lib_json/libjsoncpp.a /usr/local/lib64/libjsoncpp.a

First, there is our version, and then the system version, which should not be linked. What is strange is that I also have jsoncpp installed in my system, but it links fine (i.e. just once, our version).

We will investigate this.

@pro-spero
Copy link

I also run into these undefined references using on my Linux boxes.
One runs redhat, the other funtoo.
The build compilers are gcc 7.2. cmake is at version 3.10 (also tried with 3.9.3).
Build was attempted with simple 'make' after 'cmake' as well as 'cmake --build .'

@s3rvac
Copy link
Member

s3rvac commented Dec 21, 2017

@pro-spero Thank you for the confirmation. May I ask if you have JsonCpp installed in your system on these boxes? I am trying to reproduce this issue, but no success so far.

@pro-spero
Copy link

On the redhat machine the libraries are installed, but the headers are not present.
The funtoo machine has both headers and the binaries.

@pro-spero
Copy link

Piping the build outputs to a log file and checking the details I found that the dependent projects do not all use the same compiler (7.2) as the top level one, e.g., llvm itself selected the system compiler on redhat, which is 4.8.5. Such mixing will not work. I will attempt to get a more consistent use of compilers.

@s3rvac
Copy link
Member

s3rvac commented Dec 21, 2017

That's a good point. We will need to properly propagate the compiler selected in the top-level project to all the external projects (e.g. jsoncpp).

@pro-spero
Copy link

It is not sufficient to have the compiler in the path to be picked up, but setting the CC and CXX variables before calling the top level cmake for configuration apparently allows to avoid the problem of undefined references.

@s3rvac
Copy link
Member

s3rvac commented Dec 22, 2017

I have improved the build of retdec-config and jsoncpp so that they both use the same compiler. Could you please try to build the current master branch of the retdec repository (without any need to set the CC or CXX variables) to verify whether this fixed the build for you?

@pro-spero
Copy link

I can confirm that I can now build successfully without special settings to the environment. I successfully compiled the master branch at revision 74ae5a5.

@s3rvac
Copy link
Member

s3rvac commented Dec 23, 2017

Perfect, thank you for the confirmation! I am closing the issue, but if anyone still has these jsoncpp-related problems, let us know.

@s3rvac s3rvac closed this as completed Dec 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants