C++ 无法安装RNNLIB(http://sourceforge.net/p/rnnl/wiki/Home/)在Mac OSX上(约塞米蒂)

C++ 无法安装RNNLIB(http://sourceforge.net/p/rnnl/wiki/Home/)在Mac OSX上(约塞米蒂),c++,compiler-errors,C++,Compiler Errors,说明如下: 我在RNNLIb文件夹的根目录中键入./configure 输出: 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...

说明如下:

我在RNNLIb文件夹的根目录中键入./configure

输出:

   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
似乎令人不安的是

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

所有报税表号码

然后我输入make,得到:

  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
g++-DHAVE\u CONFIG\u H-I.-I-g-O2-MT DataExporter.o-MD-MP-MF.deps/DataExporter.Tpo-c-o DataExporter.o DataExporter.cpp
在DataExporter.cpp:18中包含的文件中:
在包含于./DataExporter.hpp:24的文件中:
./Helpers.hpp:724:18:错误:预期表达式

OUT 看起来是针对GNU C++编译器(而不是优诗美地国家公园中的冒充为代码> G++<代码>的CLAN编译器),因此编译程序更容易编译。 如果您没有,可以通过执行以下命令来安装:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
现在通过运行以下命令安装gcc 4.9:

brew install gcc49

GNU C++编译器现在可以作为代码:G+++-4.9 < /COD> < < /P> 接下来,必须安装兼容版本的

netcdf
库(不是最新版本)。看,或者直接下载

一旦解压缩了该版本的
netcdf
,将
cd
放入输出目录,并运行以下操作(注意
CXX=g++-4.9
以使用该编译器而不是默认编译器进行编译):

现在回到
rnnlib
本身:

您仍然需要应用一些补丁来获得
rnnlib
,以使用
g++-4.9
进行编译(但修补的数量要比使用Clang时少),如上所述

src/Helpers.hpp
中首次使用四个
range\u min\u size
模板函数之前,需要移动它们的定义。还需要一个小补丁来
src/Container.hpp
调用
resize()
方法作为
this->resize()
。以下是补丁:

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)));
(将
patch.txt
替换为上述补丁文件的名称)

现在,您必须再次运行
configure
,指定
g++-4.9
(因此它将拾取我们刚刚构建的
netcdf
库),然后
make

CXX=g++-4.9 ./configure
make
现在,您将拥有一个工作的
bin/rnnlib
可执行文件(如果您愿意,可以使用
makeinstall
进行安装)

如果您确实需要Clang,那么将涉及导致问题中显示的编译错误的问题,因此需要更新
src/Helpers.hpp
,以将
t.get
之类的调用替换为
t.template get
,但除此之外还有更多的编译问题,所以用GNU C++构建更容易。 似乎令人不安的是

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

你不必为此担心
malloc.h
不是标准头文件(
malloc
stdlib.h
中声明)。请参见示例。

我没有遵循执行修补程序部分需要运行的命令。现在它说我没有Helpers.hpp文件。这个文件rnnlib_gcc_test/src/Container.hpp在哪里?我没有任何看起来像rnnlib\u gcc\u测试的东西。如果您的rnnlib目录被调用,比如说
rnnlib\u source\u forge\u version
,那么在包含上述补丁的目录旁边创建一个名为
patch.txt
的文件。然后将
cd
放入
rnnlib\u源代码\u伪造版本
。运行
ls src/Helpers.hpp
,它将显示display
src/Helpers.hpp
(如果没有,则您位于错误的位置)。然后,在仍在该目录中的同时,准确地运行命令
patch-p1<../patch.txt
。这应该是说它正在修补
src/Container.hpp
src/Helpers.hpp
rnnlib_gcc_测试
并不重要,它只是碰巧被称为我的目录;
-p1
参数to
patch
意味着顶级目录名将被忽略,只需按照我提到的其他步骤操作即可。如果您仍然有问题,请告诉我,我会带您解决。另一个快速问题:“四个范围的最小尺寸模板函数”。。。他们在哪里?
patch -p1 < ../patch.txt
CXX=g++-4.9 ./configure
make
checking malloc.h usability... no
checking malloc.h presence... no