-
Notifications
You must be signed in to change notification settings - Fork 77
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
Build fails on Windows: Cannot open include file: 'sched.h'
#131
Comments
Windows support: we do have all the boilerplate for DLLs in place. Everything else should be handled by ament but we don't have a windows CI so no means really to keep things building. You are welcome to propose a fix, the Linux CIs should help guide you to a compatible solution. |
Please no |
I found a simple solution, using cygwin/mingw (aka anything coming from gcc and the POSIX world) will have compatible versions: https://stackoverflow.com/questions/27667552/porting-sched-h-to-windows |
Sorry to comment on an old issue, but if someone is in my shoes I got things to at least build with msvc with a tiny bit of cheap hackery. diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4743d98..06e5e6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,9 @@ project(realtime_tools LANGUAGES CXX)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra)
+elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ # windows needs a .lib with all of the exported symbols to link to a shared library
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
set(THIS_PACKAGE_INCLUDE_DEPENDS
diff --git a/src/thread_priority.cpp b/src/thread_priority.cpp
index 72749e3..04e6960 100644
--- a/src/thread_priority.cpp
+++ b/src/thread_priority.cpp
@@ -28,7 +28,10 @@
#include "realtime_tools/thread_priority.hpp"
+#ifdef __linux__
#include <sched.h>
+#elif _WIN32
+#endif
#include <cstring>
#include <fstream>
@@ -37,20 +40,29 @@ namespace realtime_tools
{
bool has_realtime_kernel()
{
+#ifdef __linux__
std::ifstream realtime_file("/sys/kernel/realtime", std::ios::in);
bool has_realtime = false;
if (realtime_file.is_open()) {
realtime_file >> has_realtime;
}
return has_realtime;
+#elif _WIN32
+ return false; // TODO: is it possible to configure windows for realtime?
+#endif
}
bool configure_sched_fifo(int priority)
{
+#ifdef __linux__
struct sched_param schedp;
memset(&schedp, 0, sizeof(schedp));
schedp.sched_priority = priority;
return !sched_setscheduler(0, SCHED_FIFO, &schedp);
+#elif _WIN32
+ return false; // TODO: maybe add the ability to set proccess priority to realtime?
+ // see https://stackoverflow.com/questions/27732280/porting-set-fifo-to-windows
+#endif
}
} // namespace realtime_tools |
Hello @RobertoRoos! I think we solve this problem with the #170 , #179 and #180 PRs. Can you please check if this work to you? Thank you |
Great to hear fixes have been merged, but unfortunately I cannot test this anymore, I don't have this software stack anymore. I'll leave it up to you close this issue. |
I am trying to build and run the ROS2Control demo, but during building I run into the following error:
Cannot open include file: 'sched.h'
I am following the instructions here: https://control.ros.org/master/doc/getting_started/getting_started.html#building-from-source
Using ROS2 Humble, with Windows 10.
The full build output is:
stdout_stderr.log
I am not sure to what extend Windows is even supported for ROS2Control, I hope this issue won't do any harm. Thanks!
The text was updated successfully, but these errors were encountered: