Fix for Dalvik compile error on CyanogenMod 9

I started getting this error while compiling CyanogenMod 9 (Android 4.0.x) last week:

dalvik/vm/native/dalvik_system_Zygote.cpp: In function ‘int setrlimitsFromArray(ArrayObject*)’:
dalvik/vm/native/dalvik_system_Zygote.cpp:199:19: error: aggregate ‘setrlimitsFromArray(ArrayObject*)::rlimit rlim’ has incomplete type and cannot be defined
     struct rlimit rlim;
dalvik/vm/native/dalvik_system_Zygote.cpp:222:43: error: ‘setrlimit’ was not declared in this scope
         err = setrlimit(contents[0], &rlim);
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1
make: *** Waiting for unfinished jobs....

I’m not sure if it’s due to a recent Arch Linux change or what, but it seems the fix is simply to add #include <sys/resource.h> to dalvik/vm/native/dalvik_system_Zygote.cpp. Here’s a diff:

diff --git a/vm/native/dalvik_system_Zygote.cpp b/vm/native/dalvik_system_Zygote.cpp
index 8224656..f4102e8 100644
--- a/vm/native/dalvik_system_Zygote.cpp
+++ b/vm/native/dalvik_system_Zygote.cpp
@@ -19,6 +19,7 @@
 #include "Dalvik.h"
 #include "native/InternalNativePriv.h"
+#include <sys/resource.h>
 #if (__GNUC__ == 4 && __GNUC_MINOR__ == 7)

5 thoughts on “Fix for Dalvik compile error on CyanogenMod 9

  1. Unrelated to the post,

    Thanks for getting rid of the blue overlays on the blog. Much more readable (I’m blue-colorblind). At least these weird greyish hues that made reading the blog’s text a pain in the past are gone.

Comments are closed.