When building NUPIC getting error undefined references to YAML in 64-bit Ubuntu

Hi I am trying to install NUPIC from source code by using the following instructions:

Building NuPIC “Installation from Source Code”

I am doing this on a clean 64 bit Ubuntu 15.10 Server (note: I successfully did this on 64 -bit
Ubuntu 15.10 Desktop at home)
The reason I am building from code is that I was getting a unit
test error running from binary which went away when I built it from code.

Everything works as expected until I get to the following
step
make -j2

I get numerous errors -> undefined references to YAML I have pasted in the tail end of the errors at the bottom of this post

I have been working on this since Friday.

  • I have double and tripled checked my previous steps
  • Looked on numerous internet sites for clues including numeta.org, GitHub and YAML but no luck
  • I looked at environment variables, made sure YAML was there

Is there an environment variable I need to set?
Any ideas what I need to do to resolve? Thanks
Hi I looked at this several time over the weekend and still stuck. Hope
someone can help?

/tmp/ccnUaX5x.ltrans29.ltrans.o::function YAML::Emitter&
YAML::Emitter::WriteStreamable(double): error: undefined reference to
'YAML::Emitter::PreWriteStreamable(std::_cxx11::basicstringstream,
std::allocator >&)'
/tmp/ccnUaX5x.ltrans29.ltrans.o::function YAML::Emitter&
YAML::Emitter::WriteStreamable(double): error: undefined reference to
'YAML::Emitter::GetDoublePrecision() const'
/tmp/ccnUaX5x.ltrans29.ltrans.o::function YAML::Emitter&
YAML::Emitter::WriteStreamable(double): error: undefined reference to
'YAML::Emitter::PostWriteStreamable(std::_cxx11::basicstringstream,
std::allocator > const&)'
/tmp/ccnUaX5x.ltrans29.ltrans.o::function YAML::Emitter&
YAML::Emitter::WriteIntegralType(int): error: undefined reference to
'YAML::Emitter::PreWriteIntegralType(std::_cxx11::basicstringstream,
std::allocator >&)'
/tmp/ccnUaX5x.ltrans29.ltrans.o::function YAML::Emitter&
YAML::Emitter::WriteIntegralType(int): error: undefined reference to
'YAML::Emitter::PostWriteIntegralType(std::_cxx11::basicstringstream,
std::allocator > const&)'
collect2: error: ld returned 1 exit status
test/CMakeFiles/run-tests.dir/build.make:211: recipe for target
'test/run-tests' failed
make[5]: *** [test/run-tests] Error 1
CMakeFiles/Makefile2:172: recipe for target 'test/CMakeFiles/run-tests.dir/all'
failed
make[4]: *** [test/CMakeFiles/run-tests.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
make[3]: *** [all] Error 2
external/CMakeFiles/YamlCppStaticLib.dir/build.make:111: recipe for target
'ThirdParty/Stamp/YamlCppStaticLib/YamlCppStaticLib-build' failed
make[2]: *** [ThirdParty/Stamp/YamlCppStaticLib/YamlCppStaticLib-build] Error 2
CMakeFiles/Makefile2:227: recipe for target
'external/CMakeFiles/YamlCppStaticLib.dir/all' failed
make[1]: *** [external/CMakeFiles/YamlCppStaticLib.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error
1 Like

Sorry @mbernet, but I’ve been out of the office for the past week, and did not see your post. Please don’t cross post into other categories, you’ll get no help in #htm-theory on NuPIC installation issues.

Unfortunately, I’ve had no success building NuPIC on Ubuntu 15.

The best place to search is at http://numenta.org/search For example: http://numenta.org/search/?q=ubuntu%2015 returns the wiki I posted above as the first link.

The stack trace you posted makes it seem like yaml is not installed properly. Did you apt-get install yaml manually?

Took me some time, but I think I found the error. The error message is a bit misleading.

You will find some hints in your build log (lots of messages like “/usr/bin/ranlib: : plugin needed to handle lto object”).

Since GCC 4.7, GCC provides its own wrappers around ar, nm and ranlib, which
should be used for builds with link-time optimization. Since GCC 4.9, using them is actually necessary for LTO builds using convenience libraries to succeed.

We’re compiling YamlCppStaticLib with LTO enabled (-flto), so we have to make sure we use /usr/bin/gcc-ranlib (and /usr/bin/gcc-ar, …) because the non-gcc versions don’t find the LTO plugin (liblto_plugin.so which is located in /usr/lib/gcc/x86_64-linux-gnu/4.9).

How you can fix it:

First, tell CMAKE to use the gcc wrappers for ar and ranlib by adding the CMAKE variables CMAKE_AR and CMAKE_RANLIB:

cmake $NUPIC_CORE -DCMAKE_INSTALL_PREFIX=../release -DPY_EXTENSIONS_DIR=$NUPIC_CORE/bindings/py/nupic/bindings -DCMAKE_AR:PATH=/usr/bin/gcc-ar -DCMAKE_RANLIB:PATH=/usr/bin/gcc-ranlib

There’s currently a bug in CMAKE that prevents CMAKE from using these variables also for subsequent makefile generations (https://cmake.org/Bug/view.php?id=15547), so CMAKE will pick the wrong versions of ar and ranlib in the compiler settings cmake file for YamlCppStaticLib ($NUPIC_CORE/build/scripts/ThirdParty/Build/YamlCppStaticLib/CMakeFiles/3.2.2/CMakeCXXCompiler.cmake). You either can edit this file directly

set(CMAKE_AR "/usr/bin/ar")
set(CMAKE_RANLIB "/usr/bin/ranlib")
=>
set(CMAKE_AR "/usr/bin/gcc-ar")
set(CMAKE_RANLIB "/usr/bin/gcc-ranlib")

or you edit CMakeLists.txt in the original source package:

$NUPIC_CORE/external/common/share/yaml-cpp//yaml-cpp-release-0.3.0.tar.gz
by adding:

IF(CMAKE_SYSTEM_NAME STREQUAL Linux)
	set(CMAKE_AR "/usr/bin/gcc-ar")
	set(CMAKE_RANLIB "/usr/bin/gcc-ranlib")
endif()

You can quickly test your modifications by building YamlCppStaticLib directly ($NUPIC_CORE/build/scripts/make YamlCppStaticLib).

1 Like

@helge, thank you for the discovery. Would you mind creating an issue with all these details at https://github.com/numenta/nupic.core/issues? We’re also open to pull requests, if opportune :wink:.

Many thanks,
Vitaly

1 Like

Thank you for the feedback, that seems to have helped but I am getting different errors now… I am continuing to investigate but been at it for a while and unsure what to do next.

The tail of the make -j2 is below

<artificial>:(.text+0x8a2): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0x8a9): undefined reference to `typeinfo for nupic::LoggingException'
<artificial>:(.text+0x9a0): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0x9bc): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0x9c3): undefined reference to `typeinfo for nupic::LoggingException'
<artificial>:(.text+0xa8b): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xaa7): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xaae): undefined reference to `typeinfo for nupic::LoggingException'
<artificial>:(.text+0xb79): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xb91): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xb98): undefined reference to `typeinfo for nupic::LoggingException'
<artificial>:(.text+0xbb9): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xbf5): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xc88): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xdef): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text+0xe64): undefined reference to `nupic::LoggingException::~LoggingException()'
/tmp/ccvJ96JO.ltrans4.ltrans.o: In function `nupic::ArrayRef::~ArrayRef()':
<artificial>:(.text+0x1f): undefined reference to `nupic::ArrayBase::~ArrayBase()'
/tmp/ccvJ96JO.ltrans4.ltrans.o: In function `nupic::Array::~Array()':
<artificial>:(.text+0x4f): undefined reference to `nupic::ArrayBase::~ArrayBase()'
/tmp/ccvJ96JO.ltrans4.ltrans.o: In function `nupic::ArrayRef::~ArrayRef()':
<artificial>:(.text+0xb): undefined reference to `nupic::ArrayBase::~ArrayBase()'
/tmp/ccvJ96JO.ltrans4.ltrans.o: In function `nupic::Array::~Array()':
<artificial>:(.text+0x3b): undefined reference to `nupic::ArrayBase::~ArrayBase()'
/tmp/ccvJ96JO.ltrans4.ltrans.o: In function `main':
<artificial>:(.text.startup+0xb3): undefined reference to `nupic::NuPIC::init()'
<artificial>:(.text.startup+0xc9): undefined reference to `nupic::NuPIC::shutdown()'
<artificial>:(.text.startup+0xee): undefined reference to `nupic::OS::getProcessMemoryUsage(unsigned long&, unsigned long&)'
<artificial>:(.text.startup+0x576): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text.startup+0x597): undefined reference to `nupic::LoggingException::~LoggingException()'
<artificial>:(.text.startup+0x59e): undefined reference to `typeinfo for nupic::LoggingException'
<artificial>:(.text.startup+0x5b4): undefined reference to `nupic::LoggingException::~LoggingException()'
/tmp/ccvJ96JO.ltrans4.ltrans.o:(.data.rel.ro+0x10): undefined reference to `typeinfo for nupic::ArrayBase'
/tmp/ccvJ96JO.ltrans4.ltrans.o:(.data.rel.ro+0x30): undefined reference to `typeinfo for nupic::ArrayBase'
collect2: error: ld returned 1 exit status
src/CMakeFiles/cpp_region_test.dir/build.make:99: recipe for target 'src/cpp_region_test' failed
make[2]: *** [src/cpp_region_test] Error 1
CMakeFiles/Makefile2:591: recipe for target 'src/CMakeFiles/cpp_region_test.dir/all' failed
make[1]: *** [src/CMakeFiles/cpp_region_test.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2
mbernet@gb16lap002:~/nupic.core/build/scripts$

Have you tried building without -j2 (or with -j1) to eliminate build concurrency issues (race conditions)? Eliminating concurrency also simplifies the analysis of the overall build log.

Thanks for the suggestion. Just tried make -j1 and looks like the errors are the same

Thank you for following through, @helge!

Just created a PR (#984). All CI builds successful.

I was compiling NUPIC by using the tutorial page Compiling NuPIC on Ubuntu 14
At the build stage when I give make -j4 I am getting these messages. My Ubuntu is 15.10 and gcc is 5.2.1 . Please help. I have been trying this for a few days now. I ran

cmake $NUPIC_CORE -DCMAKE_INSTALL_PREFIX=../release 
-DPY_EXTENSIONS_DIR=$NUPIC_CORE/bindings/py/nupic/bindings 
-DCMAKE_AR:PATH=/usr/bin/gcc-ar -DCMAKE_RANLIB:PATH=/usr/bin/gcc-ranlib

and then did make -j4

/tmp/cc1ysgzr.ltrans11.ltrans.o: In function `nupic::YAMLUtils::toValue(YAML::Node const&, NTA_BasicType)':
<artificial>:(.text+0xfaa): undefined reference to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
<artificial>:(.text+0x14d1): undefined reference to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
<artificial>:(.text+0x19d9): undefined reference to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
<artificial>:(.text+0x1a51): undefined reference to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
<artificial>:(.text+0x1a9f): undefined reference to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const'
/tmp/cc1ysgzr.ltrans11.ltrans.o:<artificial>:(.text+0x1af4): more undefined references to `YAML::Node::GetScalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) const' follow
collect2: error: ld returned 1 exit status
src/CMakeFiles/unit_tests.dir/build.make:1124: recipe for target 'src/unit_tests' failed
make[2]: *** [src/unit_tests] Error 1
CMakeFiles/Makefile2:562: recipe for target 'src/CMakeFiles/unit_tests.dir/all' failed
make[1]: *** [src/CMakeFiles/unit_tests.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2

This is what we are working on right now. You’ll have to wait for Ubuntu 15 support until this PR is merged:

Thanks Matt. I saw https://github.com/numenta/nupic.core/pull/984/files being committed by hstm . I manually changed those make files but it didnot work. Should I just re-install nupic/nupic.core ?

Yes, you should certainly start from scratch after getting those changes.

I removed nupic and nupic.core. I also removed gcc 5.2.1 and have now have gcc 4.7.4 . ubuntu version is still 15.10
Then cloned it back in with git
followed the tutorial on compiling nupic till the make step
Please help.

[ 11%] Performing build step for 'CapnProto'
Scanning dependencies of target kj
[  1%] Building CXX object src/kj/CMakeFiles/kj.dir/array.c++.o
In file included from /home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/exception.h:29:0,
                 from /home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/array.c++:23:
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:213:28: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:213:32: error: expected unqualified-id before ‘{’ token
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:213:48: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:214:36: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:214:44: error: expected unqualified-id before ‘{’ token
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:214:60: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:215:29: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:215:19: error: ‘kj::Own<T>&& kj::_::OwnOwn<T>::operator*()’ cannot be overloaded
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:213:18: error: with ‘kj::Own<T>& kj::_::OwnOwn<T>::operator*()’
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:215:34: error: expected unqualified-id before ‘{’ token
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:215:58: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:216:37: error: expected ‘;’ at end of member declaration
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:216:25: error: ‘const kj::Own<T>&& kj::_::OwnOwn<T>::operator*() const’ cannot be overloaded
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:214:24: error: with ‘const kj::Own<T>& kj::_::OwnOwn<T>::operator*() const’
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:216:46: error: expected unqualified-id before ‘{’ token
/home/kaustavsaha/nupic.core/build/scripts/ThirdParty/Source/CapnProto/src/kj/memory.h:216:70: error: expected ‘;’ at end of member declaration
cc1plus: warning: unrecognized command line option "-Wno-incompatible-pointer-types" [enabled by default]
src/kj/CMakeFiles/kj.dir/build.make:54: recipe for target 'src/kj/CMakeFiles/kj.dir/array.c++.o' failed
make[5]: *** [src/kj/CMakeFiles/kj.dir/array.c++.o] Error 1
CMakeFiles/Makefile2:95: recipe for target 'src/kj/CMakeFiles/kj.dir/all' failed
make[4]: *** [src/kj/CMakeFiles/kj.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make[3]: *** [all] Error 2
external/CMakeFiles/CapnProto.dir/build.make:110: recipe for target 'ThirdParty/Stamp/CapnProto/CapnProto-build' failed
make[2]: *** [ThirdParty/Stamp/CapnProto/CapnProto-build] Error 2
CMakeFiles/Makefile2:157: recipe for target 'external/CMakeFiles/CapnProto.dir/all' failed
make[1]: *** [external/CMakeFiles/CapnProto.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2

Are you following these instructions? https://github.com/numenta/nupic/wiki/Compiling-NuPIC-on-Ubuntu-15

but in this tutorial as well there are errors when I give the make command. Even in the tutorial i see you pasted errors. What is the way to circumvent these errors ?

Link to console output.

I don’t know, it worked for me with @helge’s PR changes. You might want to try again with HEAD of master after we get the PR merged.

Seems like YamlCppStaticLib hasn’t been built correctly.

Did you make sure you have all changes from https://github.com/numenta/nupic.core/pull/984/files applied correctly to all seven files

  • $NUPIC_CORE/CMakeLists.txt
  • $NUPIC_CORE/CommonCompilerConfig.cmake (changes before and after Vitaly’s comment)
  • $NUPIC_CORE/external/Apr1Lib.cmake
  • $NUPIC_CORE/external/AprUtil1Lib.cmake
  • $NUPIC_CORE/external/YamlCppLib.cmake
  • $NUPIC_CORE/external/YamlLib.cmake
  • $NUPIC_CORE/external/Zlib.cmake

If you make changes to these files, please make sure you delete the $NUPIC_CORE/build directory and create a new one before issuing the cmake/build command.

1 Like

Thanks a lot Helge and Matt. Really appreciate your time. With the changes incorporated this works at last. But I think the tutorial has to be updated

I created a folder numenta where i kept nupic and nupic.core

ubuntu-precision-server:~$ mkdir numenta
ubuntu-precision-server:~$ cd numenta
Clone hstm/nupic.core
ubuntu-precision-server:~/numenta$ cd nupic.core/
ubuntu-precision-server:~/numenta/nupic.core$
ubuntu-precision-server:~/numenta/nupic.core$ git checkout -b gcc4.9-fix
Switched to a new branch 'gcc4.9-fix’
ubuntu-precision-server:~/numenta/nupic.core$ git pull origin gcc4.9-fix
git clone nupic

I saw all the changes of the 7 files you mentioned

I then deleted $NUPIC_CORE/build directory and created build and scripts directory

ubuntu-precision-server:~/numenta/nupic.core$ mkdir build
ubuntu-precision-server:~/numenta/nupic.core$ cd build
ubuntu-precision-server:~/numenta/nupic.core/build$ mkdir scripts
ubuntu-precision-server:~/numenta/nupic.core/build$ cd scripts/

ubuntu-precision-server:~/numenta/nupic.core/build/scripts$ cmake $NUPIC_CORE -DCMAKE_INSTALL_PREFIX=…/release -DPY_EXTENSIONS_DIR=$NUPIC_CORE/bindings/py/nupic/bindings -DCMAKE_AR:PATH=/usr/bin/gcc-ar -DCMAKE_RANLIB:PATH=/usr/bin/gcc-ranlib

make -j3

make install