Skip to content

Build fails on Linux "fatal error: sys/sysctl.h: No such file or directory" #359

@r-a-sattarov

Description

@r-a-sattarov

The full error is:

lcc: "/root/dev/native-platform-0.22-milestone-28/native-platform/src/main/cpp/posix.cpp", line 38: catastrophic error #1696:
          cannot open source file "sys/sysctl.h"
  #include <sys/sysctl.h>
                         ^

1 catastrophic error detected in the compilation of "/root/dev/native-platform-0.22-milestone-28/native-platform/src/main/cpp/posix.cpp".
Compilation terminated.

And sure enough, there is no /usr/include/sys/sysctl.h, but /usr/include/linux/sysctl.h
However, the following patch fixed the compilation issue for me:

diff --git a/native-platform/src/main/cpp/posix.cpp b/native-platform/src/main/cpp/posix.cpp
index fd69af8..a736fec 100644
--- a/native-platform/src/main/cpp/posix.cpp
+++ b/native-platform/src/main/cpp/posix.cpp
@@ -35,7 +35,7 @@
 #include <sys/utsname.h>
 #include <termios.h>
 #include <unistd.h>
-#include <sys/sysctl.h>
+#include <linux/sysctl.h>
 
 jmethodID fileStatDetailsMethodId;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions