1

Instructions are Here: http://sourceforge.net/p/rnnl/wiki/Home/

I type ./configure in root directory of RNNLIb folder.

Output:

   checking for a BSD-compatible install... /usr/bin/install -c
   checking whether build environment is sane... yes
   checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
   checking for gawk... no
   checking for mawk... no
   checking for nawk... no
   checking for awk... awk
   checking whether make sets $(MAKE)... yes
   checking for g++... g++
   checking for C++ compiler default output file name... a.out
   checking whether the C++ compiler works... yes
   checking whether we are cross compiling... no
   checking for suffix of executables... 
   checking for suffix of object files... o
   checking whether we are using the GNU C++ compiler... yes
   checking whether g++ accepts -g... yes
   checking for style of include used by make... GNU
   checking dependency style of g++... gcc3 
   checking for gcc... gcc
   checking whether we are using the GNU C compiler... yes
   checking whether gcc accepts -g... yes
   checking for gcc option to accept ISO C89... none needed
   checking dependency style of gcc... gcc3
   checking for a BSD-compatible install... /usr/bin/install -c
   checking for main in -lstdc++... yes
   checking for exp in -lm... yes
   checking for main in -lnetcdf... yes
   checking for main in -lnetcdf_c++... no
   checking how to run the C++ preprocessor... g++ -E
   checking for grep that handles long lines and -e... /usr/bin/grep
   checking for egrep... /usr/bin/grep -E
   checking for ANSI C header files... yes
   checking for sys/types.h... yes
   checking for sys/stat.h... yes
   checking for stdlib.h... yes
   checking for string.h... yes
   checking for memory.h... yes
   checking for strings.h... yes
   checking for inttypes.h... yes
   checking for stdint.h... yes
   checking for unistd.h... yes
   checking time.h usability... yes
   checking time.h presence... yes
   checking for time.h... yes
   checking malloc.h usability... no
   checking malloc.h presence... no
   checking for malloc.h... no
   configure: creating ./config.status
   config.status: creating Makefile
   config.status: creating src/Makefile
   config.status: creating config.h
   config.status: config.h is unchanged
   config.status: executing depfiles commands

It seems troubling that

    checking malloc.h usability... no
    checking malloc.h presence... no

and

    checking for main in -lnetcdf_c++... no

all return no.

Then I type make, and I get:

  g++ -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT DataExporter.o -MD -MP -MF     .deps/DataExporter.Tpo -c -o DataExporter.o DataExporter.cpp
  In file included from DataExporter.cpp:18:
  In file included from ./DataExporter.hpp:24:
 ./Helpers.hpp:724:18: error: expected expression
    out << t.get<0>() << " " << t.get<1>();
                    ^
 ./Helpers.hpp:724:39: error: expected expression
    out << t.get<0>() << " " << t.get<1>();
 ... A bunch more similar error messages ...
 In file included from DataExporter.cpp:18:
 In file included from ./DataExporter.hpp:25:
 In file included from ./SeqBuffer.hpp:21:
 In file included from ./MultiArray.hpp:31:
 ./Container.hpp:113:14: warning: reference 'front' is not yet bound   
 to a value
  when used within its own initialization [-Wuninitialized]
            T& front = front();
               ~~~~~   ^~~~~
 1 warning and 14 errors generated.
 make[2]: *** [DataExporter.o] Error 1
 make[1]: *** [all-recursive] Error 1
 make: *** [all] Error 2

I'm not sure how to fix this. What is causing these errors and how do I get rid of them?

user678392
  • 1,981
  • 3
  • 28
  • 50

1 Answers1

0

Looks like this was intended for the GNU C++ compiler (not the Clang compiler masquerading as g++ in Yosemite), so it will be easier to get this compiling with that compiler.

If you don't have the Homebrew package manager, you can install it by executing:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Now install gcc 4.9 by running:

brew install gcc49

The GNU C++ compiler will now be available as g++-4.9.

Next, a compatible version of the netcdf library will have to be installed (not the latest one). See this Stackoverflow question, or just download ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz

Once that version of netcdf has been extracted, cd into the output directory and run the following (note the CXX=g++-4.9 to build with that compiler instead of the default):

CXX=g++-4.9 ./configure
make
make install
make check

Now back to rnnlib itself:

You'll still need to apply some patches to get rnnlib to compile with g++-4.9 (but less patching than if you used Clang), as mentioned on this sourceforge thread.

The definition of the four range_min_size template functions need to be moved before they are first used in src/Helpers.hpp. A small patch is also needed to src/Container.hpp to call the resize() method as this->resize(). Here's the patch:

diff -Naur rnnlib_orig/src/Container.hpp rnnlib_gcc_test/src/Container.hpp
--- rnnlib_orig/src/Container.hpp   2013-08-16 11:00:38.000000000 +0100
+++ rnnlib_gcc_test/src/Container.hpp   2015-03-18 21:30:11.000000000 +0000
@@ -154,7 +154,7 @@
    }
    template<class R> Vector<T>& operator =(const R& r)
    {
-       resize(boost::size(r));
+       this->resize(boost::size(r));
        copy(r, *this);
        return *this;
    }
diff -Naur rnnlib_orig/src/Helpers.hpp rnnlib_gcc_test/src/Helpers.hpp
--- rnnlib_orig/src/Helpers.hpp 2013-08-20 10:39:39.000000000 +0100
+++ rnnlib_gcc_test/src/Helpers.hpp 2015-03-18 21:29:47.000000000 +0000
@@ -296,6 +296,22 @@
    }
    return count;
 }
+template<class R1, class R2> static size_t range_min_size (const R1& a, const R2& b)
+{
+        return min(boost::size(a), boost::size(b));
+}
+template<class R1, class R2, class R3> static size_t range_min_size (const R1& a, const R2& b, const R3& c)
+{
+        return min(min(boost::size(a), boost::size(b)), boost::size(c));
+}
+template<class R1, class R2, class R3, class R4> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d)
+{
+        return min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d));
+}
+template<class R1, class R2, class R3, class R4, class R5> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d, const R5& e)
+{
+        return min(min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d)), boost::size(e));
+}
 template <class R1, class R2> static pair<zip_iterator<tuple<typename range_iterator<R1>::type, typename range_iterator<R2>::type> >,
                                            zip_iterator<tuple<typename range_iterator<R1>::type, typename range_iterator<R2>::type> > > 
 zip(R1& r1, R2& r2)
@@ -529,22 +545,6 @@
        delete *it;
    }
 }
-template<class R1, class R2> static size_t range_min_size (const R1& a, const R2& b)
-{
-   return min(boost::size(a), boost::size(b));
-}
-template<class R1, class R2, class R3> static size_t range_min_size (const R1& a, const R2& b, const R3& c)
-{
-   return min(min(boost::size(a), boost::size(b)), boost::size(c));
-}
-template<class R1, class R2, class R3, class R4> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d)
-{
-   return min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d));
-}
-template<class R1, class R2, class R3, class R4, class R5> static size_t range_min_size (const R1& a, const R2& b, const R3& c, const R4& d, const R5& e)
-{
-   return min(min(min(min(boost::size(a), boost::size(b)), boost::size(c)), boost::size(d)), boost::size(e));
-}
 template <class R> static int arg_max(const R& r)
 {
    return distance(boost::begin(r), max_element(boost::begin(r), boost::end(r)));

Or download this patch from Github gist as it will be less error-prone: https://gist.github.com/0David/13d872c88172c75d4663

You can apply this by cd-ing into your rnnlib directory and running:

patch -p1 < ../patch.txt

(replacing patch.txt with whatever you named the above patch file).

Now you'll have to run configure again specifying g++-4.9 (and so it will pick up the netcdf library we just built), and then make:

CXX=g++-4.9 ./configure
make

And you'll now have a working bin/rnnlib executable (which you can install with make install if you wish).

If you do need Clang, then this Stackoverflow question touches on the issue that's causing the compilation error that you show in the question, so src/Helpers.hpp will need to be updated to replace calls like t.get<0> with t.template get<0>, but there are further compilation problems beyond that, so it's easier just to build with GNU C++.

It seems troubling that

checking malloc.h usability... no
checking malloc.h presence... no

You don't need to worry about that; malloc.h isn't a standard header file (malloc is declared in stdlib.h). See for example this Stackoverflow answer.

Community
  • 1
  • 1
softwariness
  • 4,022
  • 4
  • 33
  • 41
  • I'm not following what commands do I need to run to do the patch part. It now says that I don't have a Helpers.hpp file. – user678392 Mar 22 '15 at 20:04
  • Also where is this file rnnlib_gcc_test/src/Container.hpp? I don't have anything that looks remotely like rnnlib_gcc_test. – user678392 Mar 22 '15 at 20:17
  • If your rnnlib directory is called, let's say `rnnlib_source_forge_version`, then make a file called `patch.txt` beside that directory containing the patch above. Then `cd` into `rnnlib_source_forge_version`. Run `ls src/Helpers.hpp`, that should show display `src/Helpers.hpp` (if not, you're in the wrong place). Then, whilst still in that directory, run exactly the command `patch -p1 < ../patch.txt`. This should say it's patching `src/Container.hpp` and `src/Helpers.hpp`. – softwariness Mar 22 '15 at 20:20
  • The `rnnlib_gcc_test` isn't important, it's just what my directory happened to be called; the `-p1` parameter to `patch` means the top-level directory name will be ignored anyway, just follow the other steps I mentioned. Let me know if you're still having trouble and I'll walk you through it. – softwariness Mar 22 '15 at 20:20
  • Another quick question: the "four range_min_size template functions" ... where are they located? – user678392 Mar 22 '15 at 20:22
  • The `range_min_size` template functions are in `src/Containers.hpp`, but the patch takes care of the code changes that are needed. Did you run the `patch` command as I described in my comment above? Like I said, the name of your directory isn't important if you `cd` into the directory being patched - the `rnnlib_gcc_test` will be stripped from the path if you run `patch` as I described. – softwariness Mar 22 '15 at 20:28
  • I run this command: "diff -Naur RNNLIB/src/Container.hpp rnnlib_gcc_test/src/Container.hpp". I get --- RNNLIB/src/Container.hpp 2013-08-16 06:00:38.000000000 -0400 +++ rnnlib_gcc_test/src/Container.hpp 1969-12-31 19:00:00.000000000 -0500 @@ -1,205 +0,0 @@ ... as the first couple of lines. Also, every line from running the command has a '-' appended to the front of it. – user678392 Mar 22 '15 at 20:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73541/discussion-between-softwariness-and-user678392). – softwariness Mar 22 '15 at 20:30