【问题标题】:Simple Fltk application not cross-compiling with MinGW简单的 Fltk 应用程序不与 MinGW 交叉编译
【发布时间】:2019-09-23 17:02:03
【问题描述】:

我正在尝试在 Linux 上进行交叉编译以创建 32 位 Windows 的 exe 文件。我使用以下代码:

i686-w64-mingw32-g++ rnfltk_simplest.cpp -static-libgcc -static-libstdc++ -o rnfltk_simplest.exe -lfltk -I/usr/include/

但我得到的输出有很多错误:

In file included from /usr/share/mingw-w64/include/winsock.h:32:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/_timeval.h:10:8: error: redefinition of ‘struct timeval’
 struct timeval
        ^~~~~~~
In file included from /usr/include/sys/select.h:47:0,
                 from /usr/include/sys/types.h:219,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/bits/time.h:30:8: error: previous definition of ‘struct timeval’
 struct timeval
        ^~~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:21:16: error: using typedef-name ‘fd_set’ after ‘struct’
 typedef struct fd_set
                ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
   } fd_set;
     ^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:25:3: error: conflicting declaration ‘typedef int fd_set’
 } fd_set;
   ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: previous declaration as ‘typedef struct fd_set fd_set’
   } fd_set;
     ^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:104:16: error: using typedef-name ‘fd_set’ after ‘struct’
 typedef struct fd_set FD_SET;
                ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
   } fd_set;
     ^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:105:16: error: using typedef-name ‘fd_set’ after ‘struct’
 typedef struct fd_set *PFD_SET;
                ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
   } fd_set;
     ^~~~~~
In file included from /usr/share/mingw-w64/include/winsock.h:36:0,
                 from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/psdk_inc/_fd_types.h:106:16: error: using typedef-name ‘fd_set’ after ‘struct’
 typedef struct fd_set *LPFD_SET;
                ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:77:5: note: ‘fd_set’ has a previous declaration here
   } fd_set;
     ^~~~~~
In file included from /usr/share/mingw-w64/include/windows.h:92:0,
                 from /usr/include/Fl/Fl_Window.H:26,
                 from rnfltk_simplest.cpp:4:
/usr/share/mingw-w64/include/winsock.h:299:34: error: conflicting declaration of C function ‘int select(int, fd_set*, fd_set*, fd_set*, PTIMEVAL)’
   WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
                                  ^~~~~~
In file included from /usr/include/sys/types.h:219:0,
                 from /usr/include/stdlib.h:275,
                 from /usr/include/FL/fl_utf8.h:36,
                 from /usr/include/FL/Fl.H:32,
                 from rnfltk_simplest.cpp:2:
/usr/include/sys/select.h:108:12: note: previous declaration ‘int select(int, fd_set*, fd_set*, fd_set*, timeval*)’
 extern int select (int __nfds, fd_set *__restrict __readfds,
            ^~~~~~

问题出在哪里,如何解决?感谢您的帮助。

【问题讨论】:

    标签: linux windows g++ mingw cross-compiling


    【解决方案1】:

    问题出在

    -I/usr/include/
    

    此路径包含为您的Linux 系统配置和安装的库的标头。但是您想使用特定于 Windows 库的标头。它们安装在 MinGW 编译器“系统”包含目录中(很可能是 /usr/share/mingw-w64/include,因为所有冲突都来自那里)。

    您需要将 Fltk 安装到您的 MinGW 中。例如,在 openSUSE 中,这将是包 mingw64-fltk-devel

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多