Простое приложение Fltk без кросс-компиляции с MinGW - PullRequest
1 голос
/ 23 сентября 2019

Я пытаюсь сделать кросс-компиляцию в Linux, чтобы создать исполняемый файл для 32-битной Windows.Я использую следующий код:

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,
            ^~~~~~

Где проблема и как ее можно решить?Спасибо за вашу помощь.

1 Ответ

1 голос
/ 23 сентября 2019

Проблема в

-I/usr/include/

Этот путь содержит заголовки для библиотек, настроенных и установленных в вашей Linux системе.Но вы хотите использовать заголовки, специфичные для библиотек Windows .Они устанавливаются в директорию «system» компилятора MinGW (скорее всего, /usr/share/mingw-w64/include, учитывая, что оттуда происходят все коллизии).

Вам необходимо установить Fltk в MinGW.Например, в openSUSE это будет пакет mingw64-fltk-devel.

...