Game Development Reference
In-Depth Information
for ( i = 0 ; i < argc ; i++ ) {
printf("Main argv[%d]=%s\n", i, argv[i]);
}
printf("Starting Lib main sub\n");
lib_main(argc, argv) ;
exit (0);
}
Compile the program with make testlib , or manually using the helper scripts, as follows:
agcc -c testlib.c
ald -o testlib testlib.o -L. -lch02
Note that you must link with -L. -lch02 , which tells the compiler to link against libch02.so and
search for the library in the current folder.
Now, start your emulator and let's test the library.
Testing the Dynamic Library on the Device
To test the library, upload the files to the device using make pushlib , which expands to the following
commands:
adb push libcg02.so /data
adb push testlib /data
Then log in to the device, change to the /data folder, and execute the test program:
$ adb shell
# cd /data
# chmod 777 lib * test*
# ./testlib
bionic/linker/linker.c:1581| ERROR: 833 could not load 'libch02.so'
bionic/linker/linker.c:1641| ERROR: failed to link ./testlib
bionic/linker/linker.c:1741| ERROR: CANNOT LINK EXECUTABLE './testlib'
Here, you have run the program in the version 1.5 of the emulator. As you see, the library fails to
load. The next section provides tips to figure out what is going on. If you try this process in the SDK
version 1.0 R2, it will work.
Note that this doesn't mean the library will fail to load from the Java app. It simply tells you there is
a problem with the native linker /system/bin/linker .
 
Search WWH ::




Custom Search