SOEM icon indicating copy to clipboard operation
SOEM copied to clipboard

Issues compiling SOEM with MinGW on Windows 10

Open MarcoMuellner opened this issue 3 years ago • 11 comments

Hi everyone!

I need to compile SOEM (through the desired usecase) with MinGW, but i stumbled upon a couple of issues along the way.

This my cmake call:

cmake .. -G "MinGW Makefiles"
-- The C compiler identification is GNU 5.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Qt/Qt5.9.8/Tools/mingw530_32/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
OS is win32
LIB_DIR: lib
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Marco/Documents/code/psystem-ethercat/ethercat/soem/build

which seems fine at a first glance. However, when building i get the following error (this already includes me changing /D _CRT_SECURE_WARNINGS to -D _CRT_SECURE_WARNINGS:

mingw32-make
[  5%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.obj
gcc.exe: error: unrecognized command line option '-WX'
CMakeFiles\soem.dir\build.make:75: recipe for target 'CMakeFiles/soem.dir/soem/ethercatbase.c.obj' failed
mingw32-make[2]: *** [CMakeFiles/soem.dir/soem/ethercatbase.c.obj] Error 1
CMakeFiles\Makefile2:134: recipe for target 'CMakeFiles/soem.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/soem.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Afterwards i removed the WX flag, which lead to the following errors:

mingw32-make
[  5%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.obj
ethercatbase.c:1:0: warning: -fPIC ignored for target (all code is position independent)
 /*
 ^
In file included from soem/osal/osal.h:15:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
 #error "Use this header only with Microsoft Visual C++ compilers!"
  ^
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:24:31: error: unknown type name 'pack'
 #define PACKED_BEGIN __pragma(pack(push, 1))
                               ^
ethercattype.h:90:1: note: in expansion of macro 'PACKED_BEGIN'
 PACKED_BEGIN
 ^
In file included from soem/oshw/win32/oshw.h:19:0,
                 from ethercatbase.c:19:
ethercattype.h:99:3: warning: data definition has no type or storage class
 } ec_etherheadert;
   ^
ethercattype.h:99:3: warning: type defaults to 'int' in declaration of 'ec_etherheadert' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercattype.h:100:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:19:0,
                 from ethercatbase.c:19:
ethercattype.h:123:3: warning: data definition has no type or storage class
 } ec_comt;
   ^
ethercattype.h:123:3: warning: type defaults to 'int' in declaration of 'ec_comt' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercattype.h:124:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:19:0,
                 from ethercatbase.c:19:
ethercattype.h:152:3: warning: data definition has no type or storage class
 } ec_err;
   ^
ethercattype.h:152:3: warning: type defaults to 'int' in declaration of 'ec_err' [-Wimplicit-int]
In file included from soem/oshw/win32/wpcap/Include/pcap-stdinc.h:72:0,
                 from soem/oshw/win32/wpcap/Include/pcap/pcap.h:41,
                 from soem/oshw/win32/wpcap/Include/pcap.h:45,
                 from soem/oshw/win32/nicdrv.h:21,
                 from soem/oshw/win32/oshw.h:20,
                 from ethercatbase.c:19:
soem/osal/win32/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"
 #error "Use this header only with Microsoft Visual C++ compilers!"
  ^
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:24:31: error: unknown type name 'pack'
 #define PACKED_BEGIN __pragma(pack(push, 1))
                               ^
ethercatmain.h:52:1: note: in expansion of macro 'PACKED_BEGIN'
 PACKED_BEGIN
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:65:4: warning: data definition has no type or storage class
 }  ec_fmmut;
    ^
ethercatmain.h:65:4: warning: type defaults to 'int' in declaration of 'ec_fmmut' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:66:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:75:3: warning: data definition has no type or storage class
 } ec_smt;
   ^
ethercatmain.h:75:3: warning: type defaults to 'int' in declaration of 'ec_smt' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:76:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:84:3: warning: data definition has no type or storage class
 } ec_state_status;
   ^
ethercatmain.h:84:3: warning: type defaults to 'int' in declaration of 'ec_state_status' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:85:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:143:4: error: expected specifier-qualifier-list before 'ec_smt'
    ec_smt           SM[EC_MAXSM];
    ^
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:24:31: error: unknown type name 'pack'
 #define PACKED_BEGIN __pragma(pack(push, 1))
                               ^
ethercatmain.h:315:1: note: in expansion of macro 'PACKED_BEGIN'
 PACKED_BEGIN
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:322:3: warning: data definition has no type or storage class
 } ec_mbxheadert;
   ^
ethercatmain.h:322:3: warning: type defaults to 'int' in declaration of 'ec_mbxheadert' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:323:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:332:3: warning: data definition has no type or storage class
 } ec_alstatust;
   ^
ethercatmain.h:332:3: warning: type defaults to 'int' in declaration of 'ec_alstatust' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:333:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:344:3: warning: data definition has no type or storage class
 } ec_idxstackT;
   ^
ethercatmain.h:344:3: warning: type defaults to 'int' in declaration of 'ec_idxstackT' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:24:31: error: unknown type name 'pack'
 #define PACKED_BEGIN __pragma(pack(push, 1))
                               ^
ethercatmain.h:355:1: note: in expansion of macro 'PACKED_BEGIN'
 PACKED_BEGIN
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:361:3: warning: data definition has no type or storage class
 } ec_SMcommtypet;
   ^
ethercatmain.h:361:3: warning: type defaults to 'int' in declaration of 'ec_SMcommtypet' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:362:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:371:3: warning: data definition has no type or storage class
 } ec_PDOassignt;
   ^
ethercatmain.h:371:3: warning: type defaults to 'int' in declaration of 'ec_PDOassignt' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:372:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:381:3: warning: data definition has no type or storage class
 } ec_PDOdesct;
   ^
ethercatmain.h:381:3: warning: type defaults to 'int' in declaration of 'ec_PDOdesct' [-Wimplicit-int]
In file included from soem/osal/osal.h:14:0,
                 from ethercattype.h:26,
                 from soem/oshw/win32/oshw.h:19,
                 from ethercatbase.c:19:
soem/osal/win32/osal_defs.h:26:29: error: unknown type name 'pack'
 #define PACKED_END __pragma(pack(pop))
                             ^
ethercatmain.h:382:1: note: in expansion of macro 'PACKED_END'
 PACKED_END
 ^
In file included from soem/oshw/win32/oshw.h:21:0,
                 from ethercatbase.c:19:
ethercatmain.h:433:8: error: unknown type name 'ecx_contextt'
 extern ecx_contextt  ecx_context;
        ^
ethercatmain.h:486:20: error: unknown type name 'ecx_contextt'
 void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec);
                    ^
ethercatmain.h:487:22: error: unknown type name 'ecx_contextt'
 boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec);
                      ^
ethercatmain.h:488:21: error: unknown type name 'ecx_contextt'
 boolean ecx_iserror(ecx_contextt *context);
                     ^
ethercatmain.h:489:22: error: unknown type name 'ecx_contextt'
 void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode);
                      ^
ethercatmain.h:490:14: error: unknown type name 'ecx_contextt'
 int ecx_init(ecx_contextt *context, const char * ifname);
              ^
ethercatmain.h:491:24: error: unknown type name 'ecx_contextt'
 int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, const char *ifname, char *if2name);
                        ^
ethercatmain.h:492:16: error: unknown type name 'ecx_contextt'
 void ecx_close(ecx_contextt *context);
                ^
ethercatmain.h:493:22: error: unknown type name 'ecx_contextt'
 uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address);
                      ^
ethercatmain.h:494:19: error: unknown type name 'ecx_contextt'
 int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat);
                   ^
ethercatmain.h:495:20: error: unknown type name 'ecx_contextt'
 void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn);
                    ^
ethercatmain.h:496:20: error: unknown type name 'ecx_contextt'
 uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt* FMMU);
                    ^
ethercatmain.h:497:18: error: unknown type name 'ecx_contextt'
 uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM);
                  ^
ethercatmain.h:498:22: error: unknown type name 'ecx_contextt'
 uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt* SM, uint16 n);
                      ^
ethercatmain.h:499:19: error: unknown type name 'ecx_contextt'
 uint32 ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt* PDO, uint8 t);
                   ^
ethercatmain.h:500:19: error: unknown type name 'ecx_contextt'
 int ecx_readstate(ecx_contextt *context);
                   ^
ethercatmain.h:501:20: error: unknown type name 'ecx_contextt'
 int ecx_writestate(ecx_contextt *context, uint16 slave);
                    ^
ethercatmain.h:502:23: error: unknown type name 'ecx_contextt'
 uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout);
                       ^
ethercatmain.h:503:18: error: unknown type name 'ecx_contextt'
 int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout);
                  ^
ethercatmain.h:504:17: error: unknown type name 'ecx_contextt'
 int ecx_mbxsend(ecx_contextt *context, uint16 slave,ec_mbxbuft *mbx, int timeout);
                 ^
ethercatmain.h:505:20: error: unknown type name 'ecx_contextt'
 int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout);
                    ^
ethercatmain.h:506:18: error: unknown type name 'ecx_contextt'
 void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf);
                  ^
ethercatmain.h:507:23: error: unknown type name 'ecx_contextt'
 uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout);
                       ^
ethercatmain.h:508:21: error: unknown type name 'ecx_contextt'
 int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout);
                     ^
ethercatmain.h:509:23: error: unknown type name 'ecx_contextt'
 int ecx_eeprom2master(ecx_contextt *context, uint16 slave);
                       ^
ethercatmain.h:510:20: error: unknown type name 'ecx_contextt'
 int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave);
                    ^
ethercatmain.h:511:25: error: unknown type name 'ecx_contextt'
 uint64 ecx_readeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, int timeout);
                         ^
ethercatmain.h:512:23: error: unknown type name 'ecx_contextt'
 int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout);
                       ^
ethercatmain.h:513:25: error: unknown type name 'ecx_contextt'
 uint64 ecx_readeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout);
                         ^
ethercatmain.h:514:23: error: unknown type name 'ecx_contextt'
 int ecx_writeeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, uint16 data, int timeout);
                       ^
ethercatmain.h:515:22: error: unknown type name 'ecx_contextt'
 void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma);
                      ^
ethercatmain.h:516:24: error: unknown type name 'ecx_contextt'
 uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout);
                        ^
ethercatmain.h:517:40: error: unknown type name 'ecx_contextt'
 int ecx_send_overlap_processdata_group(ecx_contextt *context, uint8 group);
                                        ^
ethercatmain.h:518:35: error: unknown type name 'ecx_contextt'
 int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout);
                                   ^
ethercatmain.h:519:26: error: unknown type name 'ecx_contextt'
 int ecx_send_processdata(ecx_contextt *context);
                          ^
ethercatmain.h:520:34: error: unknown type name 'ecx_contextt'
 int ecx_send_overlap_processdata(ecx_contextt *context);
                                  ^
ethercatmain.h:521:29: error: unknown type name 'ecx_contextt'
 int ecx_receive_processdata(ecx_contextt *context, int timeout);
                             ^
ethercatmain.h:522:32: error: unknown type name 'ecx_contextt'
 int ecx_send_processdata_group(ecx_contextt *context, uint8 group);
                                ^
ethercatbase.c: In function 'ecx_setupdatagram':
ethercatbase.c:70:13: error: 'datagramP' undeclared (first use in this function)
    ec_comt *datagramP;
             ^
ethercatbase.c:70:13: note: each undeclared identifier is reported only once for each function it appears in
ethercatbase.c:76:25: error: expected expression before ')' token
    datagramP = (ec_comt*)&frameP[ETH_HEADERSIZE];
                         ^
ethercatbase.c: In function 'ecx_adddatagram':
ethercatbase.c:108:13: error: 'datagramP' undeclared (first use in this function)
    ec_comt *datagramP;
             ^
ethercatbase.c:115:25: error: expected expression before ')' token
    datagramP = (ec_comt*)&frameP[ETH_HEADERSIZE];
                         ^
ethercatbase.c:121:25: error: expected expression before ')' token
    datagramP = (ec_comt*)&frameP[prevlength - EC_ELENGTHSIZE];
                         ^
CMakeFiles\soem.dir\build.make:75: recipe for target 'CMakeFiles/soem.dir/soem/ethercatbase.c.obj' failed
mingw32-make[2]: *** [CMakeFiles/soem.dir/soem/ethercatbase.c.obj] Error 1
CMakeFiles\Makefile2:134: recipe for target 'CMakeFiles/soem.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/soem.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

I find this one especially odd:

soem/osal/win32/stdint.h:33:2: error: #error "Use this header only with Microsoft Visual C++ compilers!"

Can anyone help me with this? Do you have any experience with building the code with MinGW on Windows?

MarcoMuellner avatar May 17 '21 21:05 MarcoMuellner

MinGW is an odd toolchain. It behaves like Linux, but targets Windows. SOEM does not have support for MinGW. I guess you could make it work. But take the Linux target as basis and only modify for Windows libs where necessary. SOEM has a very good OS abstraction layer, but it gets confused by MinGW. Neither Linux nor Windows target fits.

ArthurKetels avatar May 18 '21 19:05 ArthurKetels

I don't think the ethercat code itself is the issue, but rather the abstraction through osal and oshw. These are, as far as i am gathering, platform specific and hence cause the error above. So when trying to just use the sources for linux on windows, i get the following error:

C:\SOEM-master\build>mingw32-make
[  4%] Building C object CMakeFiles/soem.dir/soem/ethercatbase.c.obj
[  9%] Building C object CMakeFiles/soem.dir/soem/ethercatcoe.c.obj
[ 14%] Building C object CMakeFiles/soem.dir/soem/ethercatconfig.c.obj
[ 19%] Building C object CMakeFiles/soem.dir/soem/ethercatdc.c.obj
[ 23%] Building C object CMakeFiles/soem.dir/soem/ethercateoe.c.obj
[ 28%] Building C object CMakeFiles/soem.dir/soem/ethercatfoe.c.obj
[ 33%] Building C object CMakeFiles/soem.dir/soem/ethercatmain.c.obj
[ 38%] Building C object CMakeFiles/soem.dir/soem/ethercatprint.c.obj
[ 42%] Building C object CMakeFiles/soem.dir/soem/ethercatsoe.c.obj
[ 47%] Building C object CMakeFiles/soem.dir/osal/linux/osal.c.obj
C:\SOEM-master\osal\linux\osal.c: In function 'osal_timer_start':
C:\SOEM-master\osal\linux\osal.c:72:4: error: implicit declaration of function 'timeradd' [-Werror=implicit-function-declaration]
    timeradd(&start_time, &timeout, &stop_time);
    ^
cc1.exe: all warnings being treated as errors
CMakeFiles\soem.dir\build.make:210: recipe for target 'CMakeFiles/soem.dir/osal/linux/osal.c.obj' failed
mingw32-make[2]: *** [CMakeFiles/soem.dir/osal/linux/osal.c.obj] Error 1
CMakeFiles\Makefile2:152: recipe for target 'CMakeFiles/soem.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/soem.dir/all] Error 2
Makefile:134: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Because timeradd doesn't exist in the windows header files for mingw. Do you have any suggestions to circumvent this?

MarcoMuellner avatar May 21 '21 21:05 MarcoMuellner

You can find the macro definition of timeradd() here : https://github.com/OpenEtherCATsociety/SOEM/blob/master/osal/win32/osal_win32.h But it won't help you much. Do you know what the MinGW implementations are of mutex, time, and raw sockets? That is what the SOEM abstraction layer is trying to capture. And even if the API of MinGW is similar of that of Linux, the underlying implementation can/will still be Windows. How do you want to implement nicdrv.c? It is the most important module of SOEM that sends and receives raw ethernet packets through the network card.

As far as I know MinGW uses the winsock v2 driver. And as of windows Vista it no longer supports raw packets. It is possible to use WinPcap, and that is exactly the path nicdrv.c for windows takes.

Also windows timing capabilities are nowhere near those of other OS. Even when you can glue it all together so it compiles, the performance will be mediocre.

I need to compile SOEM (through the desired usecase) with MinGW

So here is your real problem. You first need to answer the question if MinGW is capable to do what you want. You could also build with VisualC and use the resulting library in MinGW. Still lousy performance, but much quicker to implement.

ArthurKetels avatar May 22 '21 12:05 ArthurKetels

Well, if i could choose i'd use a different compiler as well. Sadly due to customer requirements MinGW is required. Just building the Lib with the MSVC compiler probably won't work either, simply due to how the header files are included. I would probably need to move another layer between soem and the actual code to make this work i guess.

I am accutly aware that the timing under windows is abhorent in comparison to Linux and Unix systems, and the application i am building is cross plattform anyway. So yeah, this requires some more work on my side to make it work :(

MarcoMuellner avatar May 23 '21 19:05 MarcoMuellner

Short update on this:

It seems that due to the different name wrangling of the mvsc compiler and mingw, it seems impossible to link the library. So if i can't build the library with MinGW, i don't seem to be able to come to a satisfying result.

Do you have any more suggestions that i could try?

MarcoMuellner avatar Jun 22 '21 10:06 MarcoMuellner

For posterities sake, and for future visitors to this issue, i was able to fix the problem and create a working version of SOEM, that is buildable with MinGW. It is actually rather straight forward, and if the Maintainers of this repo would be okay with it, i would make a fork, and link it with this issue?

MarcoMuellner avatar Sep 07 '21 07:09 MarcoMuellner

Of course you can make a fork, that is the whole point of open source software. And if the changes are maintainable I would not mind a pull request either.

For curiosity's sake, how do you rate the performance of the MinGW port?

ArthurKetels avatar Sep 07 '21 08:09 ArthurKetels

Well the point would be to link it here in this issue for people to find it.

The changes are a bit crude (and they break the MSCV building of the code, which i don't mind cause i don't need that), so a pull request probably won't make much sense. Maybe at some future point this could be expanded in order for it to work properly with both compilers at the same code base.

I should note that the current application of the code isn't on something to demanding (yet), so i can't really talk much about performance (yet). From my first experiences though it seems roughly similar to what i get when i run the same code on linux.

MarcoMuellner avatar Sep 07 '21 10:09 MarcoMuellner

Well the point would be to link it here in this issue for people to find it.

The changes are a bit crude (and they break the MSCV building of the code, which i don't mind cause i don't need that), so a pull request probably won't make much sense. Maybe at some future point this could be expanded in order for it to work properly with both compilers at the same code base.

I should note that the current application of the code isn't on something to demanding (yet), so i can't really talk much about performance (yet). From my first experiences though it seems roughly similar to what i get when i run the same code on linux.

@MarcoMuellner I'm also interested in building SOEM using MinGW, but I haven't been able to find any resource on how to do so successfully.

Could you please publish the changes you've made to SOEM in order to make it successfully compile using MinGW?

Thanks!

zivke avatar Apr 19 '23 15:04 zivke

We’ve received a patch offline for MinGW not yet commited due to lack of time. It was from a non GitHub user provided ASIS. If you’d like you can get it and complete it here om GitHub?

nakarlsson avatar Apr 19 '23 16:04 nakarlsson

@nakarlsson Yes, I would very much like to take a look at the patch, and yes, maybe even create a PR if everything turns out well enough.

zivke avatar Apr 19 '23 16:04 zivke