Code Monkey home page Code Monkey logo

cogutil's Introduction

OpenCog Utilities

CircleCI

The OpenCog utilities is a miscellaneous collection of C++ utilities use for typical programming tasks in multiple OpenCog projects. These include:

  • thread-safe queues, stacks and sets
  • asynchronous method caller
  • thread-safe resource pool
  • thread-safe backtrace printing
  • high-performance signal-slot
  • random tournament selection
  • OS portability layers.

The main project site is at http://opencog.org

Prerequisites

To build the OpenCog utilities, the packages listed below are required. With a few exceptions, most Linux distributions will provide these packages. Users of Ubuntu 14.04 "Trusty Tahr" may use the dependency installer at scripts/octool. Users of any version of Linux may use the Dockerfile to quickly build a container in which OpenCog will be built and run.

boost

C++ utilities package http://www.boost.org/ | libboost-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, libboost-thread-dev

cmake

Build management tool; v3.12 or higher recommended. http://www.cmake.org/ | cmake

cxxtest

Unit test framework https://cxxtest.com/ | apt-get install cxxtest

Optional Prerequisites

The following are optional, but are strongly recommended, as they result in "pretty" stack traces, which result in far more useful and readable stack traces. These are requires, and not really optional, if you are a regular OpenCog developer.

binutils BFD library

The GNU binutils linker-loader, ahem, cough, "Binary File Description". http://gnu.org/s/binutils | binutils-dev The linker-loader understands calling conventions.

iberty

The GNU GCC compiler tools libiberty component. http://gcc.gnu.org | libiberty-dev The GCC compiler, and iberty in particular, know stack traces.

doxygen

Documentation generator under GNU General Public License http://www.stack.nl/~dimitri/doxygen/ | doxygen Generates code documentation

Building Cogutil

Perform the following steps at the shell prompt:

    cd to project root dir
    mkdir build
    cd build
    cmake ..
    make

Libraries will be built into subdirectories within build, mirroring the structure of the source directory root.

Unit tests

To build and run the unit tests, from the ./build directory enter (after building opencog as above):

    make check

Install

After building, you MUST install the utilities!

    sudo make install

cogutil's People

Contributors

alex-van-der-peet avatar amebel avatar anitzkin avatar czhedu avatar edajade avatar ferrouswheel avatar githart avatar huangdeheng avatar inflector avatar jal278 avatar jinhua avatar keyvan-m-sadeghi avatar kizzobot avatar linas avatar misgeatgit avatar ngeiswei avatar noskill avatar rekino avatar rodsol avatar rtreutlein avatar sebastianruder avatar shujingke avatar themixed avatar timothywangdev avatar tnick avatar tpsjr7 avatar trent-waddington avatar vsbogd avatar williampma avatar xiaohui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cogutil's Issues

GCC version 6 is not enough to build Atomspace, at least 7 or later is required

Cogutil macro checks that GCC is 6 or later:

# Version 6.0 of gcc is required for C++17 support.
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
MESSAGE(FATAL_ERROR "GCC version must be at least 6.0!")
ENDIF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)

but std::set::merge method which is used in atomspace code:
https://github.com/opencog/atomspace/blob/a633fe2b66cbd9c83cb2d71517a19cc924758703/opencog/atoms/container/JoinLink.cc#L139
was introduced in GCC starting from version 7.

OC_ASSERT is not printing to logfile or stdout

OC_ASSERT is supposed to record a stack trace in the logfile, and also print something to stdout.

It does neither, at the moment, and just exits silently. This defeats the whole purpose of debugging with asserts.

Unknown CMake command "add_compile_definitions".

While refreshing on an Ubuntu bionic (18.04 LTS) system, I got the error

CMake Error at opencog/util/CMakeLists.txt:72 (add_compile_definitions):
  Unknown CMake command "add_compile_definitions".

Apparently, this requires a newer version of CMake? Which version? Currently, the very first line of CMakeLists.txt is

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.2)

but apparently, this is not enough? Looking at the blame log, this shows that pull req #240 added this code, and it was provided by @ntoxeg and merged by me (apparently, without checking if it worked on bionic ...)

Any clue for what it would take to get this to work on bionic?

does not compile under cygwin

I know there is another issue open but since this project is pretty actively developed, that issues seems outdated. below is the relevant output. Let me know if you want me to zip the whole directory or provide further information.

-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - failed
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - failed
-- Build type: Release
-- Looking for include file bfd.h
-- Looking for include file bfd.h - not found
-- BFD not found
-- Binutils-dev missing: No pretty stack-trace printing.
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- program_options
-- regex
-- serialization
-- system
-- thread
-- Boost version 105800 found.
-- Found PythonInterp: /usr/bin/python (found version "2.7.10")
-- Cxxtest was not found. Make sure CXXTEST_BIN_DIR is set.
-- CxxTest missing: needed for unit tests.
-- Looking for include file libiberty.h
-- Looking for include file libiberty.h - found
-- Found libiberty: /usr/lib/libiberty.a
-- Libiberty found.
-- Found Doxygen: /usr/bin/doxygen.exe (found version "1.8.11")

The following components will be built:

Doxygen - Code documentation.
Util - General utility library.

The following components WILL NOT be built:

StackPrint - Pretty printing of stack traces.
Unit tests - Unit tests.

-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/c/Users/chrid/Desktop/opencog/cogutils/build2

chrid@DESKTOP-2HSP4B9 /cygdrive/c/Users/chrid/Desktop/opencog/cogutils/build2
$ make
Scanning dependencies of target cogutil
[ 4%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/ansi.cc.o
[ 9%] Building C object opencog/util/CMakeFiles/cogutil.dir/backtrace-symbols.c.o
[ 14%] Building C object opencog/util/CMakeFiles/cogutil.dir/cluster.c.o
[ 19%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Config.cc.o
[ 23%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/exceptions.cc.o
[ 28%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/files.cc.o
[ 33%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_normal_selector.cc.o
[ 38%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_random_selector.cc.o
[ 42%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_selector.cc.o
[ 47%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/log_prog_name.cc.o
[ 52%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Logger.cc.o
[ 57%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/misc.cc.o
[ 61%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/mt19937ar.cc.o
[ 66%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/oc_assert.cc.o
[ 71%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/oc_omp.cc.o
[ 76%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/octime.cc.o
[ 80%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/platform.cc.o
[ 85%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/StringManipulator.cc.o
[ 90%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/StringTokenizer.cc.o
[ 95%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/tree.cc.o
[100%] Linking CXX shared library cygcogutil.dll
Error copying file "/cygdrive/c/Users/chrid/Desktop/opencog/cogutils/build2/opencog/util/cygcogutil.dll" to "/cygdrive/c/Users/chrid/Desktop/opencog/cogutils/build2/tests/util/".
opencog/util/CMakeFiles/cogutil.dir/build.make:592: recipe for target 'opencog/util/cygcogutil.dll' failed
make[2]: *** [opencog/util/cygcogutil.dll] Error 1
make[2]: *** Deleting file 'opencog/util/cygcogutil.dll'
CMakeFiles/Makefile2:155: recipe for target 'opencog/util/CMakeFiles/cogutil.dir/all' failed
make[1]: *** [opencog/util/CMakeFiles/cogutil.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

Rename cogutils repository to cogutil

The library is libcogutil, the include path is opencog/util, while this repo name is cogutils. The confusion was mentioned a couple of times on the mailing list. For these reasons I suggest to rename this repo cogutil.

Error while building cogutils for MOSES

Based on the recent changes of the Opencog codebase, I think its possible to run MOSES separately from Opencog. But when I try to build the only prerequisite Cogutils, I encountered the following problem.

:~/Downloads/OPENCOG/cogutils-master/build$ make

Scanning dependencies of target cogutil
[ 5%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/ansi.cc.o
[ 10%] Building C object opencog/util/CMakeFiles/cogutil.dir/backtrace-symbols.c.o
[ 15%] Building C object opencog/util/CMakeFiles/cogutil.dir/cluster.c.o
[ 20%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Config.cc.o
In file included from /home/addis-ai/Downloads/OPENCOG/cogutils-master/opencog/util/Config.cc:50:0:
/home/addis-ai/Downloads/OPENCOG/cogutils-master/opencog/util/exceptions.h:72:32: error: expected ‘;’ at end of member declaration
/home/addis-ai/Downloads/OPENCOG/cogutils-master/opencog/util/exceptions.h:72:38: error: ‘_GLIBCXX_USE_NOEXCEPT’ does not name a type
/home/addis-ai/Downloads/OPENCOG/cogutils-master/opencog/util/exceptions.h:72:25: error: looser throw specifier for ‘virtual const char* opencog::StandardException::what() const’
/usr/include/c++/4.6/exception:69:25: error: overriding ‘virtual const char* std::exception::what() const throw ()’
make[2]: *** [opencog/util/CMakeFiles/cogutil.dir/Config.cc.o] Error 1
make[1]: *** [opencog/util/CMakeFiles/cogutil.dir/all] Error 2
make: *** [all] Error 2

Any suggestions?

Breakage with Binutils 2.35 (or maybe 2.34?)

Looks like #ifdef bfd_section_flags trick in opencog/util/backtrace-symbols.c doesn't work anymore with Binutils 2.35 (or did it work with 2.34?)

#ifndef bfd_get_section_flags works, but I'm not sure it's the way to go. If it's okay, I can provide a PR.

build failure

[ 13%] Linking CXX shared library libpatternminer-types.dylib
ld: file not found: libcogutil.dylib for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [opencog/learning/PatternMiner/types/libpatternminer-types.dylib] Error 1
make[1]: *** [opencog/learning/PatternMiner/types/CMakeFiles/patternminer-types.dir/all] Error 2
make: *** [all] Error 2

Using Mac OS.

Failed to opam install cogutil

As I'm busy checking the status of ocaml integration with atomspace, I attempted to opam install . the cogutil.opam file. I get:

mini-me@virtucon ~/h/c/cogutil (master)> opam install .
[cogutil.opam-1.0] synchronised (git+file:///home/mini-me/home/cellar/cogutil#master)
[WARNING] Failed checks in opam file from upstream of cogutil:
    error 39: Command 'make' called directly, use the built-in variable instead
[ERROR] Package conflict!
  * Missing dependency:
    - g++
    unknown package

No solution found, exiting

This missing g++ package seems rather unexpected: g++ is of course installed on my system.

Anyway. Anything that may make me progress in cleaning up some bitrot would be welcome.

Crash in logger during shutdown.

When the CogServer is shut down, there is a shared-library dtor race condition, where the cogutil logger threads are still running, even though the shared library is now gone. This looks like a crash, but the crash occurs only after the cogserver has exited (and after all unit tests have passed.) This makes test passes look like failures.

This only happens once out of every ten runs.

I first spotted this many years ago, and have repeatedly spent a lot of time trying to fix it, by adding more locks, a few sleep()s here and there, and any other trick I could think of, including not calling delete and making class dtors into no-ops. Despite great effort, I've been unable to find a fix. It seems appropriate to report this as a formal bug.

This is most easily demonstrated with the unit tests in https://github.com/opencog/atomspace-cog/ which "always" consistently pass... and then commonly crash during the shared library unload when the cogserver is stopped. This is ugly and undesired. (Out of 24 unit tests, it is likely that at least one will crash due to this bug.)

Hardwired DEFAULT_MODULE_PATHS

The list of paths to look for modules is entirely hardwired in

<COGUTILS_ROOT>/opencog/util/files.cc

Both the atomspace and opencog repos rely on it (which is why it is in cogutils) but it prevents from running the cogserver from certain places like

<OPENCOG_ROOT>/scripts

which contains run_cogserver.sh, thus failing to run the cogserver..

I guess there are 2 ways to properly deal with that

  1. have it look for a certain environment variable like OPENCOG_MODULE_PATHS
  2. add a config variable MODULES_PATH in opencog*.conf

meanwhile I've added ../build in the list of hardwired default module paths which I suppose should accommodate 90% of the users wanting to run the cogserver from that script.

Wrong interaction between stdout flag of different loggers

Problem

Setting the stdout flag of a logger consequently, and incorrectly, sets the stdout flags of other loggers to that same value.

Reproducibility

Enable LoggerUTest::xtestLoggerStdoutFlagInteraction (i.e. remove x)

void xtestLoggerStdoutFlagInteraction()
{
Logger my_logger;
// Set different stdout flags for my_logger and the default logger
logger().set_print_to_stdout_flag(false);
my_logger.set_print_to_stdout_flag(true);
// Make sure their flags differ
TS_ASSERT_DIFFERS(logger().get_print_to_stdout_flag(),
my_logger.get_print_to_stdout_flag());
}

Error Building Cogutils on OS X 10.10.5

David-Laxers-MacBook-Pro:cogutils davidlaxer$ mkdir build
David-Laxers-MacBook-Pro:cogutils davidlaxer$ cd build
David-Laxers-MacBook-Pro:build davidlaxer$ cmake ..
-- The C compiler identification is AppleClang 6.1.0.6020053
-- The CXX compiler identification is AppleClang 6.1.0.6020053
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build type: Release
-- Looking for include file bfd.h
-- Looking for include file bfd.h - not found
-- BFD not found
-- Binutils-dev missing: No pretty stack-trace printing.
-- Boost version: 1.59.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- program_options
-- regex
-- serialization
-- system
-- thread
-- Boost version 105900 found.
-- Found PythonInterp: /users/davidlaxer/anaconda/bin/python (found version "2.7.10")
-- Looking for include file libiberty.h
-- Looking for include file libiberty.h - not found
-- IBERTY not found
-- Libiberty-dev missing: No pretty stack-trace printing.
CMake Warning (dev) at CMakeLists.txt:271 (ADD_CUSTOM_TARGET):
Policy CMP0037 is not set: Target names should not be reserved and should
match a validity pattern. Run "cmake --help-policy CMP0037" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

The target name "test" is reserved or not valid for certain CMake features,
such as generator expressions, and may result in undefined behavior.
This warning is for project developers. Use -Wno-dev to suppress it.

-- Found Doxygen: /opt/local/bin/doxygen (found version "1.8.9.1")

The following components will be built:

Doxygen - Code documentation.
Unit tests - Unit tests.
Util - General utility library.

The following components WILL NOT be built:

StackPrint - Pretty printing of stack traces.

-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

cogutil

This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/davidlaxer/cogutils/build
David-Laxers-MacBook-Pro:build davidlaxer$ make
Scanning dependencies of target cogutil
[ 4%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/ansi.cc.o
[ 8%] Building C object opencog/util/CMakeFiles/cogutil.dir/backtrace-symbols.c.o
[ 13%] Building C object opencog/util/CMakeFiles/cogutil.dir/cluster.c.o
[ 17%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Config.cc.o
[ 21%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/exceptions.cc.o
In file included from /Users/davidlaxer/cogutils/opencog/util/exceptions.cc:35:
In file included from /Users/davidlaxer/cogutils/opencog/util/Logger.h:36:
/Users/davidlaxer/cogutils/opencog/util/concurrent_queue.h:53:49: warning:
deleted function definitions are a C++11 extension [-Wc++11-extensions]
concurrent_queue(const concurrent_queue&) = delete; // disable copying
^
/Users/davidlaxer/cogutils/opencog/util/concurrent_queue.h:54:60: warning:
deleted function definitions are a C++11 extension [-Wc++11-extensions]
concurrent_queue& operator=(const concurrent_queue&) = delete; // no assign
^
/Users/davidlaxer/cogutils/opencog/util/concurrent_queue.h:72:22: warning:
rvalue references are a C++11 extension [-Wc++11-extensions]
void push(Element&& item)
^
3 warnings generated.
[ 26%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/files.cc.o
/Users/davidlaxer/cogutils/opencog/util/files.cc:55:39: error: non-aggregate
type 'const std::vectorstd::string' cannot be initialized with an
initializer list
static const std::vectorstd::string paths =
^
1 error generated.
make[2]: *** [opencog/util/CMakeFiles/cogutil.dir/files.cc.o] Error 1
make[1]: *** [opencog/util/CMakeFiles/cogutil.dir/all] Error 2
make: *** [all] Error 2
David-Laxers-MacBook-Pro:build davidlaxer$

minimize/avoid using boost in cogutil

Boost header files in the cogutils header files are polluting downstream code (atomspace, opencog). We should try hard to avoid using boost. Its low-quality code, buggy, with assorted issues. In most cases, we don't actually need it for anything.

LoggerUTest fails

Currently, LoggerUTest got SegFault and fails on Debian sid. 8/31 snapshot (efa8e3b) can be built and pass the test in the same environment, so recent commits broke something.

cmake can't find boost

I have installed libboost-dev at the default location /usr/include but still getting this error. All the libraries mentioned below are present in /usr/include/boost.

CMake Error at /usr/share/cmake-2.8/Modules/FindBoost.cmake:1131 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.54.0

  Boost include path: /usr/include

  Could not find the following static Boost libraries:

          boost_date_time
          boost_filesystem
          boost_program_options
          boost_regex
          boost_serialization
          boost_system
          boost_thread

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
Call Stack (most recent call first):
  CMakeLists.txt:151 (FIND_PACKAGE)


CMake Error at CMakeLists.txt:160 (MESSAGE):
  Boost 1.46 or newer is needed to build OpenCog!


-- Configuring incomplete, errors occurred!
See also "/home/sanuj/Projects/opencog-full/cogutils/build/CMakeFiles/CMakeOutput.log".

Add laziness in Logger

I did test

http://www.boost.org/doc/libs/1_59_0/libs/log/doc/html/log/tutorial/trivial_filtering.html

and indeed it doesn't evaluate the message if the log is filtered out!!! I've tried to decipher the code to steal the idea and implement it in our Logger (cause I think replacing opencog's Logger by boost's would be too much work), but I can't understand what's going on, it looks like magic.

Anyway, I'm confident we can add lazy evaluation one way or another in our Logger class. I've already 2 ideas:

  1. Overload log(), fine(), debug(), etc to take a lambda
logger().fine([&](){h->toString()});  // string version
logger().fine() << [&](){h->toString()}; // stream version

instead of

logger().fine(h->toString());  // string version
logger().fine() << h->toString(); // stream version

It's a bit more verbose but it's lazy.
2. Write marcos LAZY_LOGGER_FINE, LAZY_LOGGER_DEBUG, etc

#define LAZY_LOGGER_FINE if(logger().isFineEnabled()) logger().fine()
...

which would be used that way

LAZY_LOGGER_FINE << h->toString();

It's more limited but perhaps clearer.

Ultimately it wouldn't be hard to implement both (I've already started).

What do you think?

Build errors: `not declared in this scope`

When I follow the cogutils build instructions and get to make, it only gets as far as 16% and then outputs the following errors:

[ 16%] Building CXX object opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/PatternMiner.cc.o
~/opencog/opencog/learning/PatternMiner/PatternMiner.cc: In member function ‘unsigned int opencog::PatternMining::PatternMiner::getAllEntityCountWithSamePredicatesForAPattern(const HandleSeq&)’:
~/opencog/opencog/learning/PatternMiner/PatternMiner.cc:2028:9: error: ‘HandleSetSeq’ was not declared in this scope
         HandleSetSeq allEntitiesForEachPredicate;
         ^
~/opencog/opencog/learning/PatternMiner/PatternMiner.cc:2043:13: error: ‘allEntitiesForEachPredicate’ was not declared in this scope
             allEntitiesForEachPredicate.push_back(allEntitiesForThisPredic
             ^
~/opencog/opencog/learning/PatternMiner/PatternMiner.cc:2049:33: error: ‘allEntitiesForEachPredicate’ was not declared in this scope
         boost::set_intersection(allEntitiesForEachPredicate[0],
                                 ^
opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/build.make:110: recipe for target 'opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/PatternMiner.cc.o' failed
make[2]: *** [opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/PatternMiner.cc.o] Error 1
CMakeFiles/Makefile2:779: recipe for target 'opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/all' failed
make[1]: *** [opencog/learning/PatternMiner/CMakeFiles/PatternMiner.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

libcogutil.so installed in incorrect location.

It appears that libcogutil is being installed into /usr/local/lib/libcogutil.so instead of /usr/local/lib/opencog/libcogutil.so and this might (??) explain some of the weird behavior in various unit tests (e.g. failure to deal with the logger correctly).

Suggest that it should get installed into /usr/local/lib/opencog, where everything else goes.

Add component support to Logger

As we're moving towards a more integrated and synergistic system, we really need to add some multi-component support in the logger.

I suggest a simple mechanism:

  1. Derive a logger from the factory logger and specifying a certain
    component name [Note: derive is used in metaphorical sense, not necessarily a C++ sense]. This derived logger, when used would insert this component name between the log level and the log message. For instance, if the component name is ForwardChainer the following call of the derived logger fc_log
    c++ fc_log.debug("%u rule to be searched", n_rules);
    would write in the log file
    [2016-01-22 13:59:32:832] [DEBUG] [ForwardChainer] 1 rules to be searched
  2. Code some scripts to grep all the log messages pertaining to a certain component. Note that this script will have to account for multi-line messages, that may not contain any logger prefixes.

Organise OpenCog .cmake files

Raising this issue here as it is across many opencog repos but most of the changes should be done in cogutil package.

  1. .cmake find-module packages for 3rd party libs are copied and duplicated in few repositories. For instance opencog/atomspace/lib and opencog/opencog/lib contains FindProtobuf, FindPython, FindGuile, etc modules. It leads to code duplication and necessity fixing modules in each repository independently.

    All of such modules should be copied in single place. For instance we can keep them in opencog/cogutil repo, install them during cogutil installation and use installed versions from other repositories.

  1. .cmake find-module packages for OpenCog modules (for instance FindAtomspace.cmake) should be located near the library code.

    They should be kept in the repo which contains corresponding library and installed with the library. It makes sense to convert them into config-file packages (difference between find-module and config-file packages is described here) to make them compatible with 3rd party software which uses OpenCog as upstream.

Breakage with Binutils 2.34

Seems some macros have been changed in Binutils 2.34.

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=fd3619828e94a24a92cddec42cbc0ab33352eeb4

To build cogutil with it, changes like the following needed (should make it conditional?)

--- a/opencog/util/backtrace-symbols.c
+++ b/opencog/util/backtrace-symbols.c
@@ -121,14 +121,14 @@
       if (spot->found)
             return;
 
-      if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+      if ((bfd_section_flags(section) & SEC_ALLOC) == 0)
             return;
 
-      vma = bfd_get_section_vma(abfd, section);
+      vma = bfd_section_vma(section);
       if (spot->pc < vma)
             return;
 
-      size = bfd_section_size(abfd, section);
+      size = bfd_section_size(section);
       if (spot->pc >= vma + size)
             return;

OC_OMP support is incorrect.

Follow-on to pull-req #217

So: FIND_PACKAGE(ParallelSTL) works as designed, and cmake sets it correctly:

FIND_PACKAGE(ParallelSTL)
IF (PARALLEL_STL_FOUND)
   ADD_DEFINITIONS(-DHAVE_PARALLEL_STL)
ENDIF (PARALLEL_STL_FOUND)

However, the users of oc_omp.h (or at least, this user) do not have a -DHAVE_PARALLEL_STL in their code, nor do they have any #define OC_OMP either. As a result, those wonderful parallel loops are not actually .. parallel.

Moving to c++17 per #177 seems a little more important, now.

OSX build CMake error

Have a problem on Mac OS 10.13.1
CMakeOutput.log

$ cmake ..
CMake Deprecation Warning at CMakeLists.txt:21 (CMAKE_POLICY):
The OLD behavior for policy CMP0005 will be removed from a future version
of CMake.

The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.

-- The C compiler identification is AppleClang 9.0.0.9000038
-- The CXX compiler identification is AppleClang 9.0.0.9000038
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/gcc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/g++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:48 (MESSAGE):
Only the gcc compiler is supported at this time

Same if I add

$ export CC=/usr/bin/gcc
$ export CXX=/usr/bin/g++

before cmake

Gcc looks like this

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Could you please tell me what can be done about it?
Thank you!

using logger().error() in excpetion crashes

when catching an exception, it appears to be OK to use logger().info("blah") and it works fine, but using logger().error("blah") will segfault. The only difference between these two is the printing of the stack frame, so the best guess is that it has something to do with printing the stack in an exception context.

... although this may have something to do with boost. This bug is seen when adding logger prints to the exception handles in this code: https://github.com/opencog/opencog/blob/master/opencog/cogserver/server/ServerSocket.cc#L167-L173

OSX build error: "/etc/os-release" does not exist

cmake/Summary.cmake:8 reads /etc/os-release which does not exist on OSX, making the cmake fail. Simply commenting out the lines introduced in 264a199 allows the build to succeed.
With apologies for the noise in #98, I did not read the error messages properly.

Find* cmake files installation path variable

currently it's installed to DATADIR/cmake but it's better to use CMAKE_INSTALL_PREFIX/cmake because during compiling the intended data path and the installation path may be different. when building packages and crosscompiling this is a problem. I think it's the entire point of having CONFDIR and DATADIR they're usually similar to CMAKE_INSTALL_PREFIX but they get embedded in C source files and the path is needed to be right on the target system rather than the host.

${DATADIR}/cmake/)

CMake BFD_FOUND false

On Ubuntu 14.04 LTS, even with binutils-dev installed, cmake is not detecting it (and BFD_FOUND is false in the CMakeLists.txt).

Manually commenting out the #IF (BFD_FOUND) check works to enable pretty print, so binutils-dev is indeed installed.

instructions are wrong

cd to project root dir
mkdir build
cd build
cmake ..
make

When I mkdir build && cd build the cmake .. doesn't put anything into the build diretory. At the end it says
-- Build files have been written to: /home/samantha/work/cogutils
in my case. That is the parent directory. So I went there and did a make and sudo make install. Still no CogUtils which other parts of system complain about. This is on ubuntu 17.01.

MacOS: Some tests are failing

Hi,
After I built cogutil (looks like it was successfully built)

Scanning dependencies of target cogutil
[ 4%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/ansi.cc.o
[ 9%] Building C object opencog/util/CMakeFiles/cogutil.dir/backtrace-symbols.c.o
[ 13%] Building C object opencog/util/CMakeFiles/cogutil.dir/cluster.c.o
[ 18%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Config.cc.o
[ 22%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/exceptions.cc.o
[ 27%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/files.cc.o
[ 31%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_normal_selector.cc.o
[ 36%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_random_selector.cc.o
[ 40%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/lazy_selector.cc.o
[ 45%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/log_prog_name.cc.o
[ 50%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Logger.cc.o
/Users/anastasia/Development/GitHub/cogutil/opencog/util/Logger.cc: In member function 'void opencog::Logger::log(opencog::Logger::Level, const string&)':
/Users/anastasia/Development/GitHub/cogutil/opencog/util/Logger.cc:422:60: warning: format '%ld' expects argument of type 'long int', but argument 5 has type '__darwin_suseconds_t {aka int}' [-Wformat=]
"[%s:%03ld] ",timestamp, stv.tv_usec / 1000);
~~~~~~~~~~~~~~~~~~^
[ 54%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/misc.cc.o
[ 59%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/mt19937ar.cc.o
[ 63%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/oc_assert.cc.o
[ 68%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/oc_omp.cc.o
[ 72%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/octime.cc.o
[ 77%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/platform.cc.o
/Users/anastasia/Development/GitHub/cogutil/opencog/util/platform.cc: In function 'size_t opencog::getMemUsage()':
/Users/anastasia/Development/GitHub/cogutil/opencog/util/platform.cc:179:21: warning: 'void* sbrk(int)' is deprecated [-Wdeprecated-declarations]
void *p = sbrk(0);
^
In file included from /Users/anastasia/Development/GitHub/cogutil/opencog/util/platform.cc:172:0:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:587:7: note: declared here
void *sbrk(int);
^~~~
[ 81%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/StringTokenizer.cc.o
[ 86%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/tree.cc.o
[ 90%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/strndup.cc.o
[ 95%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/strnlen.cc.o
[100%] Linking CXX shared library libcogutil.dylib
[100%] Built target cogutil

When I run 'make test'
Some tests are failing

[ 37%] Built target cogutil
[ 38%] Generating iostreamContainerUTest.cpp
Scanning dependencies of target iostreamContainerUTest
[ 40%] Building CXX object tests/util/CMakeFiles/iostreamContainerUTest.dir/iostreamContainerUTest.cpp.o
[ 42%] Linking CXX executable iostreamContainerUTest
[ 42%] Built target iostreamContainerUTest
[ 44%] Generating rankingUTest.cpp
Scanning dependencies of target rankingUTest
[ 45%] Building CXX object tests/util/CMakeFiles/rankingUTest.dir/rankingUTest.cpp.o
[ 47%] Linking CXX executable rankingUTest
[ 47%] Built target rankingUTest
[ 49%] Generating randomUTest.cpp
Scanning dependencies of target randomUTest
[ 50%] Building CXX object tests/util/CMakeFiles/randomUTest.dir/randomUTest.cpp.o
[ 52%] Linking CXX executable randomUTest
[ 52%] Built target randomUTest
[ 54%] Generating ConfigUTest.cpp
Scanning dependencies of target ConfigUTest
[ 55%] Building CXX object tests/util/CMakeFiles/ConfigUTest.dir/ConfigUTest.cpp.o
[ 57%] Linking CXX executable ConfigUTest
[ 57%] Built target ConfigUTest
[ 59%] Generating lazy_selectorUTest.cpp
Scanning dependencies of target lazy_selectorUTest
[ 61%] Building CXX object tests/util/CMakeFiles/lazy_selectorUTest.dir/lazy_selectorUTest.cpp.o
[ 62%] Linking CXX executable lazy_selectorUTest
[ 62%] Built target lazy_selectorUTest
[ 64%] Generating StringTokenizerUTest.cpp
Scanning dependencies of target StringTokenizerUTest
[ 66%] Building CXX object tests/util/CMakeFiles/StringTokenizerUTest.dir/StringTokenizerUTest.cpp.o
[ 67%] Linking CXX executable StringTokenizerUTest
[ 67%] Built target StringTokenizerUTest
[ 69%] Generating KLDUTest.cpp
Scanning dependencies of target KLDUTest
[ 71%] Building CXX object tests/util/CMakeFiles/KLDUTest.dir/KLDUTest.cpp.o
[ 72%] Linking CXX executable KLDUTest
[ 72%] Built target KLDUTest
[ 74%] Generating CounterUTest.cpp
Scanning dependencies of target CounterUTest
[ 76%] Building CXX object tests/util/CMakeFiles/CounterUTest.dir/CounterUTest.cpp.o
[ 77%] Linking CXX executable CounterUTest
[ 77%] Built target CounterUTest
[ 79%] Generating functionalUTest.cpp
Scanning dependencies of target functionalUTest
[ 81%] Building CXX object tests/util/CMakeFiles/functionalUTest.dir/functionalUTest.cpp.o
[ 83%] Linking CXX executable functionalUTest
[ 83%] Built target functionalUTest
[ 84%] Generating comprehensionUTest.cpp
Scanning dependencies of target comprehensionUTest
[ 86%] Building CXX object tests/util/CMakeFiles/comprehensionUTest.dir/comprehensionUTest.cpp.o
[ 88%] Linking CXX executable comprehensionUTest
[ 88%] Built target comprehensionUTest
[ 89%] Generating lru_cacheUTest.cpp
Scanning dependencies of target lru_cacheUTest
[ 91%] Building CXX object tests/util/CMakeFiles/lru_cacheUTest.dir/lru_cacheUTest.cpp.o
[ 93%] Linking CXX executable lru_cacheUTest
[ 93%] Built target lru_cacheUTest
[ 94%] Generating LoggerUTest.cpp
Scanning dependencies of target LoggerUTest
[ 96%] Building CXX object tests/util/CMakeFiles/LoggerUTest.dir/LoggerUTest.cpp.o
[ 98%] Linking CXX executable LoggerUTest
[ 98%] Built target LoggerUTest
Scanning dependencies of target tests
[ 98%] Built target tests
Scanning dependencies of target test
[100%] Running tests...
Test project /Users/anastasia/Development/GitHub/cogutil/build/tests
Start 1: ConfigUTest
1/12 Test #1: ConfigUTest ......................***Exception: Child aborted 0.03 sec
Start 2: LoggerUTest
2/12 Test #2: LoggerUTest ...................... Passed 1.02 sec
Start 3: StringTokenizerUTest
3/12 Test #3: StringTokenizerUTest ............. Passed 0.01 sec
Start 4: lazy_selectorUTest
4/12 Test #4: lazy_selectorUTest ............... Passed 0.01 sec
Start 5: lru_cacheUTest
5/12 Test #5: lru_cacheUTest ...................***Exception: Child aborted 0.01 sec
Start 6: iostreamContainerUTest
6/12 Test #6: iostreamContainerUTest ...........***Exception: Child aborted 0.01 sec
Start 7: functionalUTest
7/12 Test #7: functionalUTest .................. Passed 0.01 sec
Start 8: KLDUTest
8/12 Test #8: KLDUTest ......................... Passed 4.98 sec
Start 9: randomUTest
9/12 Test #9: randomUTest ...................... Passed 3.10 sec
Start 10: comprehensionUTest
10/12 Test #10: comprehensionUTest ............... Passed 0.01 sec
Start 11: CounterUTest
11/12 Test #11: CounterUTest ..................... Passed 0.01 sec
Start 12: rankingUTest
12/12 Test #12: rankingUTest ..................... Passed 0.01 sec

75% tests passed, 3 tests failed out of 12

Total Test time (real) = 9.24 sec

The following tests FAILED:
1 - ConfigUTest (Child aborted)
5 - lru_cacheUTest (Child aborted)
6 - iostreamContainerUTest (Child aborted)
Errors while running CTest
make[3]: *** [CMakeFiles/test] Error 8
make[2]: *** [CMakeFiles/test.dir/all] Error 2
make[1]: *** [CMakeFiles/test.dir/rule] Error 2
make: *** [test] Error 2

Would appreciate any help on how to fix\debug it
Thanks!

Doesn't build on debian

gareth@sexy:~/cogutils/trunk/build$ make
[ 5%] Building CXX object opencog/util/CMakeFiles/cogutil.dir/Config.cc.o
In file included from /home/gareth/cogutils/trunk/opencog/util/Config.cc:50:0:
/home/gareth/cogutils/trunk/opencog/util/exceptions.h:71:13: error: looser throw specifier for ‘virtual opencog::StandardException::~StandardException()’
In file included from /usr/include/c++/4.7/new:42:0,
from /usr/include/c++/4.7/ext/new_allocator.h:34,
from /usr/include/c++/4.7/x86_64-linux-gnu/bits/c++allocator.h:34,
from /usr/include/c++/4.7/bits/allocator.h:48,
from /usr/include/c++/4.7/string:43,
from /home/gareth/cogutils/trunk/opencog/util/Config.h:28,
from /home/gareth/cogutils/trunk/opencog/util/Config.cc:25:
/usr/include/c++/4.7/exception:66:13: error: overriding ‘virtual std::exception::~exception() noexcept (true)’
make[2]: *** [opencog/util/CMakeFiles/cogutil.dir/Config.cc.o] Error 1
make[1]: *** [opencog/util/CMakeFiles/cogutil.dir/all] Error 2
make: *** [all] Error 2

gareth@sexy:~/cogutils/trunk/build$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)

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.