Hello all.
I’ve just compiled NuPIC core and everything went swell, or so I thought. I’m using the core library as a standalone static library in a C++ project in Eclipse (Neon) CDT, NuPIC 0.6.4.dev0, and I’ve come across an odd problem. When I compile, running
Network net();
and then returning, there are no problems. More specifically, I run this, then check if NuPIC is initialized. But I find that NuPIC is not initialized. What’s more, is that when I replace the above with:
Network net;
I get a whole slew of linker errors with reference to python libraries. For example, "undefined reference to PyInt_FromLong
" or "undefined reference to PyObject_Call
". I’m currently including from nupic.core/build/release/include and I’m using the library path nupic.core/build/release/lib/ with libraries nupic_core (libnupic_core.a), gtest (libgtest.a) and npymath (libnpymath.a). I started with nupic_core but added the others in an attempt to fix this issue.
The C++ source includes iostream, nupic/engine/Network.hpp, nupic/engine/NuPIC.hpp, nupic/engine/Region.hpp, nupic/ntypes/Dimensions.hpp, and nupic/utils/Log.hpp. It uses namespace std and nupic. Complete source code:
/*
* main.cpp
*
* Date: Jun 15, 2017
* Author: Sam Gallagher
*
* @brief
* @description
* TODO:
*/
#include <iostream>
#include "nupic/engine/Network.hpp"
#include "nupic/engine/NuPIC.hpp"
#include "nupic/engine/Region.hpp"
#include "nupic/ntypes/Dimensions.hpp"
#include "nupic/utils/Log.hpp"
using namespace std;
using namespace nupic;
int main() /* No input args */
{
/* Create a new HTM network */
Network net;
//Region *l1 = net.addRegion("level1","TestNode","");
/* Creating a network should initialize Nupic */
if(NuPIC::isInitialized())
cout << "NuPIC initialized correctly!\n";
else
cout << "ERROR: NuPIC did not initialize correctly.\n";
/*
if(NuPIC::isInitialized())
cout << "NuPIC did not shutdown correctly.\n";
else
cout << "NuPIC shutdown correctly!\n";
*/
return 0;
}
Compile command:
g++ -I/home/sam/Documents/Devel/HTM/nupic.core/build/release/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"src/main.d" -MT"src/main.o" -o “src/main.o” “…/src/main.cpp”
Linker command:
g++ -L/home/sam/Documents/Devel/HTM/nupic.core/build/release/lib/ -o “walking-nupic” ./src/main.o -lnupic_core -lgtest -lnpymath
A cropping from the errors:
/tmp/ccb94oSf.ltrans5.ltrans.o: In function nupic::PyRegion::NTA_initPython()': <artificial>:(.text+0x35): undefined reference to
Py_IsInitialized’
/tmp/ccb94oSf.ltrans5.ltrans.o: In function `nupic::PyRegion::NTA_createPyNode(char const*, void*, void*, void**, char const*)’:
:(.text+0x257c): undefined reference to `PyFloat_FromString’
:(.text+0x26e9): undefined reference to `PyLong_FromUnsignedLongLong’
/tmp/ccb94oSf.ltrans5.ltrans.o: In function `nupic::PyRegion::NTA_finalizePython()’:
:(.text+0x21): undefined reference to `Py_Finalize’
…
Clearly there’s a problem linking to some Python library or some definitions are missing or something. The closest thing I could find was nupic.core’s py_support classes.
Other things to note:
When running ./unit_tests in release/bin, 25 tests fail. Results:
[----------] Global test environment tear-down
[==========] 319 tests from 45 test cases ran. (3076 ms total)
[ PASSED ] 294 tests.
[ FAILED ] 25 tests, listed below:
[ FAILED ] RandomTest.CapnpSerialization
[ FAILED ] PathTest.exists
[ FAILED ] PathTest.getParent
[ FAILED ] PathTest.getFilename
[ FAILED ] PathTest.getBasename
[ FAILED ] PathTest.getExtension
[ FAILED ] PathTest.normalize
[ FAILED ] PathTest.makeAbsolute
[ FAILED ] PathTest.split
[ FAILED ] PathTest.join
[ FAILED ] PathTest.remove
[ FAILED ] PathTest.rename
[ FAILED ] PathTest.copy
[ FAILED ] PathTest.copyInTemp
[ FAILED ] PathTest.isRootDir
[ FAILED ] PathTest.isAbsolute
[ FAILED ] PathTest.getExecutablePath
[ FAILED ] DirectoryTest.Existence
[ FAILED ] DirectoryTest.setCWD
[ FAILED ] DirectoryTest.RemoveTreeAndCreate
[ FAILED ] DirectoryTest.CopyTree
[ FAILED ] DirectoryTest.Iterator
[ FAILED ] ConnectionsTest.testWriteRead
[ FAILED ] SpatialPoolerTest.testSaveLoad
[ FAILED ] SpatialPoolerTest.testWriteRead
I’m running Linux Mint 18 64-bit version 3.0.7, linux kernel 4.40-78-generic. Any help is greatly appreciated!
Sam