The majority of problems encountered during these tests are related to the compilation and linking stage of the Contiki libraries. Below follows a number of configurations that work for different users. Linux users with the GNU toolchain may try: PATH_C_COMPILER = gcc COMPILER_ARGS = LINK_COMMAND_1 = gcc -shared -Wl,-Map=$(MAPFILE) -o $(LIBFILE) LINK_COMMAND_2 = PARSE_WITH_COMMAND=false Windows users with recent Cygwin may try: PATH_C_COMPILER = gcc COMPILER_ARGS = -mno-cygwin -Wall -I'$(JAVA_HOME)/include' -I'$(JAVA_HOME)/include/win32' LINK_COMMAND_1 = gcc -mno-cygwin -shared -Wl,-Map=$(MAPFILE) -Wl,--add-stdcall-alias -o $(LIBFILE) LINK_COMMAND_2 = -L/usr/lib/mingw -lmsvcrt Windows users with older Cygwin may try: PATH_C_COMPILER = gcc COMPILER_ARGS = -mno-cygwin -I'$(JAVA_HOME)/include' -I'$(JAVA_HOME)/include/win32' LINK_COMMAND_1 = ld -Map=$(MAPFILE) -shared --add-stdcall-alias /usr/lib/mingw/dllcrt2.o -o $(LIBFILE) LINK_COMMAND_2 = -L/usr/lib/mingw -lmingw32 -lmingwex -lmsvcrt Windows users with recent Cygwin and separate MinGW tools may try: In recent (early 2007) MinGW-Cygwin versions, the JNI support has been limited. This may cause COOJA not to be able to load libraries generated using gcc's -mno-cygwin flag. One possible solution is to download "real" MinGW (http://www.mingw.org), and install it separately from Cygwin (for example in c:\mingw). Try using the following settings: PATH_C_COMPILER = gcc COMPILER_ARGS = -Wall -D_JNI_IMPLEMENTATION_ -I'$(JAVA_HOME)/include' -I'$(JAVA_HOME)/include/win32' LINK_COMMAND_1 = gcc -shared -Wl,-Map=$(MAPFILE) -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at -o $(LIBFILE) LINK_COMMAND_2 = Mac users may try (see Mac note below): PATH_C_COMPILER = gcc PARSE_WITH_COMMAND = true PARSE_COMMAND = nmandsize $(LIBFILE) COMPILER_ARGS = -Wall -I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers -dynamiclib -fno-common LINK_COMMAND_1 = gcc -dynamiclib -fno-common -o $(LIBFILE) LINK_COMMAND_2 = -framework JavaVM Mac note: The Mac OS X support is experimental, and currently depends on an external script to work. The script 'nmandsize' is available in the subdirectory 'mac_users' and depends on both 'nm' and 'size'. The purpose of the script is to gather information which COOJA uses to determine the memory sections addresses. Observe that, if used, this script must be in the path. The COOJA Simulator - JNI Tests ------------------------------- These tests can be used to help understand COOJA errors, and to configure COOJA for new users. For COOJA to compile JNI libraries successfully, tests 2-5 must be completed. In level3, only level3a or level3b is necessary to pass. You may have to change the configuration in the file 'exttools.cfg'. When all tests pass, these settings should be entered into the COOJA External tool settings dialog. Before running the tests, the COOJA JAR file must be created: > ant compile_cooja To run the first test: > ant level2 For more information including configuration examples: > ant help > ant level2 [compilation test] Compiles level2.c to level2.library, using both c compiler and linker. Java class loads the library and calls a simple native function. > ant level3a [address parsing using map file] > ant level3b [address parsing using command] > ant level4 [fetching reference var] Calculates offset between relative and absolute memory. A simple native function increases two counters (from both data and bss sections). > ant level5 [fetches and restores memory segments - the final test] A simple native function increases two counters (from both data and bss sections). The current memory (data+bss sections) is fetched and restored between function calls. The counters should be restored with the memory! Run either > ant level3a or > ant level3b 3a tests parsing library addresses using the map file generated at link time. 3b tests parsing library addresses using a command. At least one of the tests must pass. After passing, the 'exttools.cfg' must be updated. The external tools setting: PARSE_WITH_COMMAND=true causes COOJA (and the following tests) to use the command to parse library addresses, and should be used if test 3b passed. PARSE_WITH_COMMAND=false causes COOJA to parse the generated map file, and should be used if test 3a passed.