- Header <mntent.h> does not exist
- Header <linux/rtc.h> does not exist
- Header <sys/sysinfo.h> does not exist
- In <string.h>, function strndup() does not exist
- In <unistd.h>, function ftruncate64() does not exist
- In <netinet/in.h>, struct ip_mreqn does not exist
- Struct statfs requires <sys/param.h> and <sys/mount.h>
- Variable environ doest not exists, but you can "access" it using function _NSGetEnviron() defined in <crt_externs.h>
- To retrieve full path of current executable, use function _NSGetExecutablePath() defined in <mach-o/dyld.h>
Wednesday, June 9, 2010
OSX C/C++ Header Differences with Linux
ラベル:
iPhone,
iPhone Development
Android NDK Differences with Linux
C++ STL is not includedUpdate: stlport is included since revision 5- In <mntent.h>, function setmntent() does not exist
- In <dirent.h>, functions seekdir(), telldir() does not exist
Macro INET_ADDRSTRLEN is not defined in <netinet/in.h>Update: added since revision 5b- Macro PTHREAD_EXPLICIT_SCHED is not defined in <pthread.h>
- Marcos WEXITSTATUS, WTERMSIG, WIFSIGNALED, etc are only defined in <sys/wait.h> (One can also find them in <stdlib.h> for Linux)
- Although function ftruncate64() is included in header <unistd.h>, it is not included in the prebuilt libraries. Hence it causes linking error while this function is used
- Although you can include <sys/sysinfo.h>, struct sysinfo does not exist (it is disabled in the header file). If you have to use it, try this way.
ラベル:
Android,
Android Development
Monday, June 7, 2010
Android NDK Development
Some remarks I would like to make while developing on Android NDK:
- Package, class and function names in Java are specified by function name in C/C++
- For all JNI wrapper functions, remember to add JNIEnv *env and jobject object to the front of the parameter list. They represent the environment pointer and the Java class object which calls this function.
- Parameters are passed into wrapper functions by value. To the best of my knowledge, there is no way to pass in parameters by reference.
- If the wrapper source is in cpp, remember to include all function prototypes in
- Include all source files in subdirectory src: LOCAL_SRC_FILES := $(addprefix src/,$(notdir $(wildcard $(LOCAL_PATH)/src/*.cpp $(LOCAL_PATH)/src/*.c)))
- Make use of include $(call all-subdir-makefiles) to make a recursive building hierarchy
- While using variable LOCAL_STATIC_LIBRARIES, try putting the highest level libraries in the front to prevent linking error
In order tot check the output of stdout and stderr, you have to set by using adb (included in Android SDK), and then you can view them using ./adb logcat
./adb shell stop
./adb shell setprop log.redirect-stdio true
./adb shell start
Update: Stopping and starting the shell may cause the whole emulator hangs now. To redirect stdout/stderr, add "log.redirect-stdio=true" to /data/local.prop on the device (create one if the file does not exist) and restart the deviceSTL library is not included in NDK. If you need to use STL library in your NDK code, you have to use stlport- DO NOT create thread inside NDK
- Directory /tmp DOES NOT exist in Android. I have tried to search for it for hours without any luck. According to what I found, applications should manage their own files (temp or non-temp) within the local filesystem sandbox on their own
- There is a script to let you build a NDK toolchain since NDK revision 5
- Linking with "-lpthread" is not required, including that will cause error
ラベル:
Android,
Android Development
Subscribe to:
Posts (Atom)