rnso
rnso

Reputation: 24623

Simple Fltk application not cross-compiling with MinGW

I am trying to do cross-compiling on Linux to create exe file for 32bit Windows. I use following code:

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

But I get an output with many errors:

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

Where is the problem and how can it be solved? Thanks for your help.

Upvotes: 1

Views: 347

Answers (1)

jacob
jacob

Reputation: 1630

The problem is in

-I/usr/include/

This path contains headers for libraries configured for and installed in your Linux system. But you want to use headers specific to the Windows libraries. These are installed in the MinGW compiler "system" include directory (most likely /usr/share/mingw-w64/include given that from there all the collisions come).

You need to install Fltk into your MinGW. For example, in openSUSE, this would be the package mingw64-fltk-devel.

Upvotes: 1

Related Questions