无法在 Mac OSX (Yosemite) 上安装 RNNLIB (http://sourceforge.net/p/rnnl/wiki/Home/)
Cannot install RNNLIB (http://sourceforge.net/p/rnnl/wiki/Home/) on Mac OSX (Yosemite)
说明在这里:http://sourceforge.net/p/rnnl/wiki/Home/
我在 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
和
checking for main in -lnetcdf_c++... no
所有 return 没有。
然后我输入 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
我不确定如何解决这个问题。是什么导致了这些错误,我该如何摆脱它们?
看起来这是为 GNU C++ 编译器设计的(不是在 Yosemite 中伪装成 g++
的 Clang 编译器),所以用那个编译器编译会更容易。
如果你没有Homebrew package manager,你可以通过执行安装它:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
现在通过 运行ning 安装 gcc 4.9:
brew install gcc49
GNU C++ 编译器现在可用 g++-4.9
。
接下来,必须安装 netcdf
库的兼容版本(不是最新版本)。参见 this Whosebug question, or just download ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz
提取 netcdf
版本后,cd
进入输出目录,运行 以下内容(注意 CXX=g++-4.9
使用该编译器构建而不是默认值):
CXX=g++-4.9 ./configure
make
make install
make check
现在回到 rnnlib
本身:
您仍然需要应用一些补丁才能使 rnnlib
与 g++-4.9
一起编译(但比使用 Clang 时补丁更少),如 this sourceforge thread 中所述。
需要移动四个 range_min_size
模板函数的定义,然后才能在 src/Helpers.hpp
中首次使用它们。 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)));
或者从 Github 要点下载这个补丁,因为它不太容易出错:https://gist.github.com/0David/13d872c88172c75d4663
您可以通过 cd
-ing 进入您的 rnnlib
目录并 运行ning:
来应用它
patch -p1 < ../patch.txt
(将 patch.txt
替换为您命名的上述补丁文件)。
现在您必须再次 运行 configure
指定 g++-4.9
(因此它将选择我们刚刚构建的 netcdf
库),然后 make
:
CXX=g++-4.9 ./configure
make
现在您将拥有一个可用的 bin/rnnlib
可执行文件(如果您愿意,可以使用 make install
安装)。
如果您确实需要 Clang,那么 this Whosebug question 会涉及导致您在问题中显示的编译错误的问题,因此需要更新 src/Helpers.hpp
以替换 t.get<0>
与 t.template get<0>
,但除此之外还有进一步的编译问题,因此仅使用 GNU C++ 构建更容易。
It seems troubling that
checking malloc.h usability... no
checking malloc.h presence... no
你不用担心这个; malloc.h
不是标准头文件(malloc
在 stdlib.h
中声明)。例如参见 [=52=].
说明在这里:http://sourceforge.net/p/rnnl/wiki/Home/
我在 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
和
checking for main in -lnetcdf_c++... no
所有 return 没有。
然后我输入 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
我不确定如何解决这个问题。是什么导致了这些错误,我该如何摆脱它们?
看起来这是为 GNU C++ 编译器设计的(不是在 Yosemite 中伪装成 g++
的 Clang 编译器),所以用那个编译器编译会更容易。
如果你没有Homebrew package manager,你可以通过执行安装它:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
现在通过 运行ning 安装 gcc 4.9:
brew install gcc49
GNU C++ 编译器现在可用 g++-4.9
。
接下来,必须安装 netcdf
库的兼容版本(不是最新版本)。参见 this Whosebug question, or just download ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz
提取 netcdf
版本后,cd
进入输出目录,运行 以下内容(注意 CXX=g++-4.9
使用该编译器构建而不是默认值):
CXX=g++-4.9 ./configure
make
make install
make check
现在回到 rnnlib
本身:
您仍然需要应用一些补丁才能使 rnnlib
与 g++-4.9
一起编译(但比使用 Clang 时补丁更少),如 this sourceforge thread 中所述。
需要移动四个 range_min_size
模板函数的定义,然后才能在 src/Helpers.hpp
中首次使用它们。 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)));
或者从 Github 要点下载这个补丁,因为它不太容易出错:https://gist.github.com/0David/13d872c88172c75d4663
您可以通过 cd
-ing 进入您的 rnnlib
目录并 运行ning:
patch -p1 < ../patch.txt
(将 patch.txt
替换为您命名的上述补丁文件)。
现在您必须再次 运行 configure
指定 g++-4.9
(因此它将选择我们刚刚构建的 netcdf
库),然后 make
:
CXX=g++-4.9 ./configure
make
现在您将拥有一个可用的 bin/rnnlib
可执行文件(如果您愿意,可以使用 make install
安装)。
如果您确实需要 Clang,那么 this Whosebug question 会涉及导致您在问题中显示的编译错误的问题,因此需要更新 src/Helpers.hpp
以替换 t.get<0>
与 t.template get<0>
,但除此之外还有进一步的编译问题,因此仅使用 GNU C++ 构建更容易。
It seems troubling that
checking malloc.h usability... no checking malloc.h presence... no
你不用担心这个; malloc.h
不是标准头文件(malloc
在 stdlib.h
中声明)。例如参见 [=52=].