简体   繁体   English

MinGW包含路径冲突

[英]MinGW include paths conflict

I'm trying to cross-compile on Linux for Win64 using MinGW-w64. 我正在尝试使用MinGW-w64在Linux for Win64上交叉编译。 Here's my code 这是我的代码

#include <cstdlib>
#include <iostream>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>

int main(int argc, char** argv)
{
    if (argc > 1)
        std::cout << std::atoi(argv[1]) << std::endl;

    std::cout << boost::uuids::random_generator()() << std::endl;

    return 0;
}

A simple compile fails with the error 简单编译失败并显示错误

$ x86_64-w64-mingw32-c++ hello.cpp
hello.cpp:4:31: fatal error: boost/uuid/uuid.hpp: No such file or directory
 #include <boost/uuid/uuid.hpp>
                               ^

Boost is installed in /usr/include which apparently the MinGW compiler doesn't search. Boost安装在/usr/include ,显然MinGW编译器不会搜索。 If I add that path, then... 如果我添加该路径,那么...

$ x86_64-w64-mingw32-c++ -I/usr/include hello.cpp
In file included from /usr/include/stdlib.h:314:0,
             from /usr/x86_64-w64-mingw32/include/c++/4.9.1/cstdlib:72,
             from hello.cpp:1:
/usr/include/sys/types.h:109:19: error: conflicting declaration ‘typedef __ssize_t ssize_t’
 typedef __ssize_t ssize_t;
                   ^

MinGW's cstdlib is including /usr/include/stdlib.h instead of /usr/x86_64-w64-mingw32/include/stdlib.h ! MinGW的cstdlib包含/usr/include/stdlib.h 而不是 /usr/x86_64-w64-mingw32/include/stdlib.h How do I solve this? 我该如何解决? I need the -I in order to include Boost, but then MinGW includes other headers incorrectly. 我需要-I才能包含Boost,但是MinGW会错误地包含其他标头。

You cannot use boost headers from /usr/include to cross-compile windows binaries. 您不能使用/ usr / include中的boost标头交叉编译Windows二进制文件。

You should also cross-compile boost. 您还应该交叉编译boost。

See this guide for details about how to cross-compile boost on linux (it's for vle, but the first part is about boost): 有关如何在Linux上交叉编译boost的详细信息,请参阅本指南(这是针对vle的,但第一部分是关于boost的):

http://www.vle-project.org/wiki/Cross_compilation_Win32 http://www.vle-project.org/wiki/Cross_compilation_Win32

Update: Given that the guide is a little bit old, makes sense to link to boost documentation: 更新:鉴于该指南有点旧,可以链接到boost文档:

http://www.boost.org/boost-build2/doc/html/bbv2/tasks/crosscompile.html http://www.boost.org/boost-build2/doc/html/bbv2/tasks/crosscompile.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM