Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to support MSYS2/GCC #875

Merged
merged 5 commits into from
Jan 27, 2025
Merged

Conversation

jalius
Copy link
Contributor

@jalius jalius commented Nov 27, 2024

Adding build support for MSYS2/GCC and cleaning up some various build errors.

  • Fix implementation of osal_thread_create() to match declaration.
  • Fix missing timezone struct declaration.
  • Add GCC style struct packing
  • Update CMakeLists with non-MSVC win32 build instructions
  • Address some compiler warnings arising from unused parameters and variables.
  • Remove stdint.h and inttypes.h which are MSVC specific. The compiler should find these standard library files based on the target rather than including them in the project.

It now builds properly on MSYS2/GCC using cmake generators "MSYS Makefiles" and "Ninja".

I didn't get a chance to build it again with MSVC, so should probably do that before merging.

@jalius
Copy link
Contributor Author

jalius commented Nov 28, 2024

Wondering if we should change
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
parameter void *thandle to OSAL_THREAD_HANDLE *thandle
for clarity in all implementations.

@jalius
Copy link
Contributor Author

jalius commented Jan 24, 2025

MSVC needed a small tweak to headers to make it build happily with Visual Studio 17 2022.

Developer Command Prompt for VS 2022

SOEM\build-msvc> cmake .. -G "Visual Studio 17 2022"
SOEM\build-msvc> msbuild SOEM.sln

cmd.exe

SOEM\build-gnuc> cmake .. -G "MSYS Makefiles"
SOEM\build-gnuc> make

Build succeeds for both and I can run the simple_test.exe successfully on a hardware target:

GNUC Simple Test:

SOEM\build-gnuc\test\linux\simple_test>simple_test.exe \Device\NPF_{0710CB60-EDF7-4356-BE31-2C366A43D984}
SOEM (Simple Open EtherCAT Master)
Simple test
Starting simple test
ec_init on \Device\NPF_{0710CB60-EDF7-4356-BE31-2C366A43D984} succeeded.
1 slaves found and configured.
Slaves mapped, state to SAFE_OP.
segments : 1 : 687 0 0 0
Request operational state for all slaves
Calculated workcounter 3
Operational state reached for all slaves.
Processdata cycle  162, WKC 3 , O: 00 00 00 00 00 00 00 00 I: 30 00 03 00 0^C02 02 00 T:791067700875279400

MSVC Simple Test:

SOEM\build-msvc\test\linux\simple_test>Debug\simple_test.exe \Device\NPF_{0710CB60-EDF7-4356-BE31-2C366A43D984}
SOEM (Simple Open EtherCAT Master)
Simple test
Starting simple test
ec_init on \Device\NPF_{0710CB60-EDF7-4356-BE31-2C366A43D984} succeeded.
1 slaves found and configured.
Slaves mapped, state to SAFE_OP.
segments : 1 : 687 0 0 0
Request operational state for all slaves
Calculated workcounter 3
Operational state reached for all slaves.
^Cocessdata cycle  262, WKC 3 , O: 00 00 00 00 00 00 00 00 I: 30 00 03 00 00 02 02 00 T:791067756981503160

@ArthurKetels Any concerns on merging this to support cross-tool building on windows? The change should not interfere with existing project, I kept it as minimal as possible to get MSYS/GNUC working.

@ArthurKetels ArthurKetels merged commit 2752dc2 into OpenEtherCATsociety:master Jan 27, 2025
4 of 5 checks passed
@ArthurKetels
Copy link
Contributor

Thanks for the work and testing. Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants