我正在尝试编译 mgiza。它需要提升,所以我安装了 boost_1_52_0。
我一般搜索过stackoverflow和谷歌,但我仍然无法解决这些问题。
最初我的编译错误如下:
按照 Joachim 的建议,要添加 boost 库,我已将其添加到 Makefiles.am
AM_CPPFLAGS = $(BOOST_CPPFLAGS)
AM_LDFLAGS = $(LDFLAGS_BOOST) \
$(LDFLAGS_BOOST_LIBS)
LIBS += $(LIBS_BOOST)
ACLOCAL_AMFLAGS = -I m4
LDFLAGS_BOOST = \
$(BOOST_SYSTEM_LDFLAGS) \
$(BOOST_PROGRAM_OPTIONS_LDFLAGS)
LIBS_BOOST = \
$(BOOST_SYSTEM_LIBS) \
$(BOOST_PROGRAM_OPTIONS_LIBS) \
$(BOOST_FILESYSTEM_LIBS)
我还在 configure.ac 中添加了这样的行:
dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard.
AC_INIT(mgiza, 1.0)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_ISC_POSIX
AC_PROG_CXX
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_PROG_RANLIB
AM_PROG_LIBTOOL
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR(m4)
BOOST_REQUIRE([1.52.0])
BOOST_FILESYSTEM
BOOST_SYSTEM
BOOST_PROGRAM_OPTIONS
BOOST_REGEX
BOOST_THREAD
AC_OUTPUT([
Makefile
src/Makefile
src/mkcls/Makefile
])
然后我跑了
autoreconf -ifv
以下是留言:
autoreconf-2.68:进入目录“。” autoreconf-2.68:configure.ac:不使用 Gettext autoreconf-2.68:运行:aclocal --force -I m4 autoreconf-2.68:configure.ac:跟踪 autoreconf-2.68:运行:libtoolize --copy --force libtoolize:将辅助文件放在“.”中。 libtoolize:复制文件“./ltmain.sh” libtoolize:将宏放入 AC_CONFIG_MACRO_DIR, `m4'。 libtoolize:复制文件“m4/libtool.m4” libtoolize:复制文件“m4/ltoptions.m4” libtoolize:复制文件“m4/ltsugar.m4” libtoolize:复制文件“m4/ltversion.m4” libtoolize:复制文件“m4/lt~obsolete.m4” libtoolize: `AC_PROG_RANLIB' 被 `LT_INIT' 废弃 autoreconf-2.68:运行:/usr/bin/autoconf-2.68 --force autoreconf-2.68:运行:/usr/bin/autoheader-2.68 --force autoreconf-2.68: 运行: automake --add-missing --copy --force-missing autoreconf-2.68:离开目录“。”
然后我跑了
configure --with-boost=/home/Jelita/boost_1_52_0
以下是运行结果:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
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 library containing strerror... none required
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -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 ranlib... ranlib
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-cygwin file names to i686-pc-cygwin format... fu
nc_convert_file_noop
checking how to convert i686-pc-cygwin file names to toolchain format... func_co
nvert_file_noop
checking for /usr/i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|
^x86 DLL
checking for dlltool... dlltool
checking how to associate runtime and link libraries... func_cygming_dll_for_imp
lib
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... (cached) ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
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 for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared
libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared
libraries... yes
checking for g++ option to produce PIC... -DDLL_EXPORT -DPIC
checking if g++ PIC flag -DDLL_EXPORT -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/i686-pc-cygwin/bin/ld.exe) supports shared
libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking for Boost headers version >= 1.52.0... /home/Jelita/boost_1_52_0
checking for Boost's header version... 1_52
checking for the toolset name used by Boost for g++... gcc45 -gcc
checking boost/system/error_code.hpp usability... yes
checking boost/system/error_code.hpp presence... yes
checking for boost/system/error_code.hpp... yes
checking for the Boost system library... yes
checking boost/filesystem/path.hpp usability... yes
checking boost/filesystem/path.hpp presence... yes
checking for boost/filesystem/path.hpp... yes
checking for the Boost filesystem library... yes
checking for boost/system/error_code.hpp... (cached) yes
checking for the Boost system library... (cached) yes
checking boost/program_options.hpp usability... yes
checking boost/program_options.hpp presence... yes
checking for boost/program_options.hpp... yes
checking for the Boost program_options library... yes
checking boost/regex.hpp usability... yes
checking boost/regex.hpp presence... yes
checking for boost/regex.hpp... yes
checking for the Boost regex library... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/mkcls/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
同时,我在 config.log 中得到以下信息:
configure:16123: checking boost/system/error_code.hpp usability
configure:16123: g++ -c -g -O2 -I/home/Jelita/boost_1_52_0 conftest.cpp >&5
configure:16123: $? = 0
configure:16123: result: yes
configure:16123: checking boost/system/error_code.hpp presence
configure:16123: g++ -E -I/home/Jelita/boost_1_52_0 conftest.cpp
configure:16123: $? = 0
configure:16123: result: yes
configure:16123: checking for boost/system/error_code.hpp
configure:16123: result: yes
configure:16150: checking for the Boost system library
configure:16192: g++ -c -g -O2 -I/home/Jelita/boost_1_52_0 conftest.cpp >&5
configure:16192: $? = 0
configure:16243: re-using the existing conftest.o
configure:16249: g++ -o conftest.exe -g -O2 -I/home/Jelita/boost_1_52_0 -L/usr/local/lib conftest.o -lboost_system-gcc45-mt-1_52 >&5
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lboost_system-gcc45-mt-1_52
collect2: ld returned 1 exit status
configure:16258: $? = 1
configure:16243: re-using the existing conftest.o
configure:16249: g++ -o conftest.exe -g -O2 -I/home/Jelita/boost_1_52_0 -L/usr/lib conftest.o -lboost_system-gcc45-mt-1_52 >&5
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lboost_system-gcc45-mt-1_52
collect2: ld returned 1 exit status
现在我在编译时收到此错误:
libtool: link: g++ -MT -MD -MP -MF -O6 -g -O2 -o .libs/mgiza.exe mgiza-main.o -
L. -lgiza -lpthread
mgiza-main.o: In function `__static_initialization_and_destruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
mgiza-main.o: In function `main':
/home/Jelita/moses/tools/mgiza/src/main.cpp:1099: undefined reference to `boost:
:thread::hardware_concurrency()'
./libgiza.a(libgiza_a-model3.o): In function `__static_initialization_and_destru
ction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-reports.o): In function `__static_initialization_and_destr
uction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-hmm.o): In function `__static_initialization_and_destructi
on_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-getSentence.o): In function `__static_initialization_and_d
estruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-getSentence.o): In function `thread_exception':
/home/Jelita/moses/tools/mgiza/src/../boost/thread/exceptions.hpp:49: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model1.o): In function `__static_initialization_and_destru
ction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model2.o): In function `__static_initialization_and_destru
ction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model2to3.o): In function `__static_initialization_and_des
truction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-parse.o): In function `__static_initialization_and_destruc
tion_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model3_viterbi_with_tricks.o): In function `__static_initi
alization_and_destruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model3_viterbi.o): In function `__static_initialization_an
d_destruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-model345-peg.o): In function `__static_initialization_and_
destruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
./libgiza.a(libgiza_a-MoveSwapMatrix.o): In function `__static_initialization_an
d_destruction_0':
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:214: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:215: undefined
reference to `boost::system::generic_category()'
/home/Jelita/moses/tools/mgiza/src/../boost/system/error_code.hpp:216: undefined
reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make[3]: *** [mgiza.exe] Error 1
make[3]: Leaving directory `/home/Jelita/moses/tools/mgiza/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/Jelita/moses/tools/mgiza/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/Jelita/moses/tools/mgiza'
make: *** [all] Error 2