我试图使用以下命令行从linux64位到windows7 64位交叉编译一些源代码
x86_64-w64-mingw32-g ++ eval-table.cc -o hello7.exe -static-libgcc -static-libstdc ++ -Wl,-Bstatic -lstdc ++ -lpthread -Wl,-Bdynamic -I / usr / include -I / usr / include / x86_64-linux-gnu -I / usr / local / include -std = gnu ++ 11
错误看起来像这样
其中一个典型错误是
error: conflicting declaration ‘typedef __time_t time_t’
typedef __time_t time_t;
In file included from /usr/include/c++/4.8/cstdint:41:0,
from /usr/include/c++/4.8/bits/char_traits.h:376,
from /usr/include/c++/4.8/string:40,
from /usr/include/boost/program_options/errors.hpp:12,
from /usr/include/boost/program_options/options_description.hpp:12,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/include/stdint.h:122:27: error: conflicting declaration ‘typedef long unsigned int uintptr_t’
typedef unsigned long int uintptr_t;
^
In file included from /usr/share/mingw-w64/include/crtdefs.h:10:0,
from /usr/share/mingw-w64/include/stddef.h:7,
from /usr/lib/gcc/x86_64-w64-mingw32/4.8/include/stddef.h:1,
from /usr/include/c++/4.8/cstddef:42,
from /usr/include/boost/config/select_stdlib_config.hpp:18,
from /usr/include/boost/config.hpp:40,
from /usr/include/boost/program_options/config.hpp:10,
from /usr/include/boost/program_options/options_description.hpp:11,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/share/mingw-w64/include/_mingw.h:412:44: error: ‘uintptr_t’ has a previous declaration as ‘typedef long long unsigned int uintptr_t’
__MINGW_EXTENSION typedef unsigned __int64 uintptr_t;
^
In file included from /usr/include/sched.h:32:0,
from /usr/include/pthread.h:23,
from /usr/include/c++/4.8/x86_64-w64-mingw32/bits/gthr-default.h:35,
from /usr/include/c++/4.8/x86_64-w64-mingw32/bits/gthr.h:148,
from /usr/include/c++/4.8/ext/atomicity.h:35,
from /usr/include/c++/4.8/bits/basic_string.h:39,
from /usr/include/c++/4.8/string:52,
from /usr/include/boost/program_options/errors.hpp:12,
from /usr/include/boost/program_options/options_description.hpp:12,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/include/time.h:75:18: error: conflicting declaration ‘typedef __time_t time_t’
typedef __time_t time_t;
^
In file included from /usr/share/mingw-w64/include/crtdefs.h:10:0,
from /usr/share/mingw-w64/include/stddef.h:7,
from /usr/lib/gcc/x86_64-w64-mingw32/4.8/include/stddef.h:1,
from /usr/include/c++/4.8/cstddef:42,
from /usr/include/boost/config/select_stdlib_config.hpp:18,
from /usr/include/boost/config.hpp:40,
from /usr/include/boost/program_options/config.hpp:10,
from /usr/include/boost/program_options/options_description.hpp:11,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/share/mingw-w64/include/_mingw.h:481:20: error: ‘time_t’ has a previous declaration as ‘typedef __time64_t time_t’
typedef __time64_t time_t;
^
In file included from /usr/include/stdlib.h:314:0,
from /usr/include/c++/4.8/cstdlib:72,
from /usr/include/c++/4.8/ext/string_conversions.h:41,
from /usr/include/c++/4.8/bits/basic_string.h:2815,
from /usr/include/c++/4.8/string:52,
from /usr/include/boost/program_options/errors.hpp:12,
from /usr/include/boost/program_options/options_description.hpp:12,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/include/x86_64-linux-gnu/sys/types.h:109:19: error: conflicting declaration ‘typedef __ssize_t ssize_t’
typedef __ssize_t ssize_t;
^
In file included from /usr/share/mingw-w64/include/crtdefs.h:10:0,
from /usr/share/mingw-w64/include/stddef.h:7,
from /usr/lib/gcc/x86_64-w64-mingw32/4.8/include/stddef.h:1,
from /usr/include/c++/4.8/cstddef:42,
from /usr/include/boost/config/select_stdlib_config.hpp:18,
from /usr/include/boost/config.hpp:40,
from /usr/include/boost/program_options/config.hpp:10,
from /usr/include/boost/program_options/options_description.hpp:11,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/share/mingw-w64/include/_mingw.h:387:35: error: ‘ssize_t’ has a previous declaration as ‘typedef long long int ssize_t’
__MINGW_EXTENSION typedef __int64 ssize_t;
^
In file included from /usr/include/c++/4.8/cwctype:50:0,
from /usr/include/c++/4.8/bits/locale_facets.h:39,
from /usr/include/c++/4.8/bits/basic_ios.h:37,
from /usr/include/c++/4.8/ios:44,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from /usr/include/boost/assert.hpp:82,
from /usr/include/boost/function/function_base.hpp:20,
from /usr/include/boost/function/detail/prologue.hpp:17,
from /usr/include/boost/function/function_template.hpp:13,
from /usr/include/boost/function/detail/maybe_include.hpp:18,
from /usr/include/boost/function/function1.hpp:11,
from /usr/include/boost/program_options/value_semantic.hpp:13,
from /usr/include/boost/program_options/options_description.hpp:13,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/include/wctype.h:52:27: error: conflicting declaration ‘typedef long unsigned int wctype_t’
typedef unsigned long int wctype_t;
^
In file included from /usr/share/mingw-w64/include/crtdefs.h:10:0,
from /usr/share/mingw-w64/include/stddef.h:7,
from /usr/lib/gcc/x86_64-w64-mingw32/4.8/include/stddef.h:1,
from /usr/include/c++/4.8/cstddef:42,
from /usr/include/boost/config/select_stdlib_config.hpp:18,
from /usr/include/boost/config.hpp:40,
from /usr/include/boost/program_options/config.hpp:10,
from /usr/include/boost/program_options/options_description.hpp:11,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/share/mingw-w64/include/_mingw.h:444:24: error: ‘wctype_t’ has a previous declaration as ‘typedef short unsigned int wctype_t’
typedef unsigned short wctype_t;
^
In file included from /usr/include/boost/math/special_functions/sign.hpp:18:0,
from /usr/include/boost/lexical_cast.hpp:167,
from /usr/include/boost/program_options/value_semantic.hpp:14,
from /usr/include/boost/program_options/options_description.hpp:13,
from /usr/include/boost/program_options.hpp:15,
from eval-table.cc:23:
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:236:65: warning: left shift count >= width of type [enabled by default]
static const uint64_t sign = ((uint64_t)0x80000000u) << 32;
^
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:237:64: warning: left shift count >= width of type [enabled by default]
static const uint64_t exponent = ((uint64_t)0x7ff00000) << 32;
^
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:240:38: warning: left shift count >= width of type [enabled by default]
= (((uint64_t)0x000fffff) << 32) + ((uint64_t)0xffffffffu);
^
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:296:63: warning: left shift count >= width of type [enabled by default]
static const uint64_t sign = (uint64_t)0x80000000u << 32;
^
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:297:62: warning: left shift count >= width of type [enabled by default]
static const uint64_t exponent = (uint64_t)0x7ff00000 << 32;
^
/usr/include/boost/math/special_functions/detail/fp_traits.hpp:300:36: warning: left shift count >= width of type [enabled by default]
= ((uint64_t)0x000fffff << 32) + (uint64_t)0xffffffffu;
^
In file included from /usr/include/c++/4.8/chrono:38:0,
from /usr/include/c++/4.8/mutex:39,
from /usr/local/include/opencog/util/Logger.h:31,
from eval-table.h:31,
from eval-table.cc:31:
/usr/include/c++/4.8/ratio:214:7: error: static assertion failed: This library calls __builtin_clzll on uintmax_t, which is unsafe on your platform. Please complain to http://gcc.gnu.org/bugzilla/
static_assert(sizeof (uintmax_t) == sizeof (unsigned long long),
^
In file included from /usr/include/boost/ratio/ratio.hpp:47:0,
from /usr/include/boost/chrono/duration.hpp:41,
from /usr/include/boost/chrono/system_clocks.hpp:62,
from /usr/include/boost/thread/win32/thread_data.hpp:16,
from /usr/include/boost/thread/thread_only.hpp:15,
from /usr/include/boost/thread/thread.hpp:12,
from /usr/include/boost/thread.hpp:13,
from /usr/local/include/moses/comboreduct/combo/enum_type.h:31,
from ../table/../interpreter/../combo/vertex.h:43,
from ../table/../interpreter/eval.h:35,
from ../table/table.h:45,
from ../table/table_io.h:40,
from eval-table.h:33,
from eval-table.cc:31:
/usr/include/boost/ratio/ratio_fwd.hpp:64:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto;
^
/usr/include/boost/ratio/ratio_fwd.hpp:65:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto;
^
/usr/include/boost/ratio/ratio_fwd.hpp:66:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico;
^
/usr/include/boost/ratio/ratio_fwd.hpp:77:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera;
^
/usr/include/boost/ratio/ratio_fwd.hpp:78:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta;
^
/usr/include/boost/ratio/ratio_fwd.hpp:79:81: warning: overflow in implicit constant conversion [-Woverflow]
typedef ratio<BOOST_RATIO_INTMAX_C(1000000000000000000), BOOST_RATIO_INTMAX_C(1)> exa;
^
我在互联网上搜索了为什么会发生这种情况,似乎交叉编译器正在搜索本机gcc库。但我不知道如何通过重命名linux共享库中的某个文件夹或临时更改PATH变量来解决这个问题。谁能告诉我该怎么做?
我知道我可以使用MXE交叉编译器(我不是Linux的专家,可以快速弄清楚如何使用它)但我已经花了很多天试图解决这个问题,并希望尽快结束这个传奇。
非常感谢任何帮助。
提前致谢!