Previous


Compile the C Code into a Dynamically Loadable Library

UNIX
% cc -G HelloWorld.c HelloWorldImp.c -o libhello.so

Note: You may need to use the -I flag to indicate to the compiler where to find the various header files. For example
cc -G -I$JAVAHOME/include -I$JAVAHOME/include/solaris HelloWorld.c HelloWorldImp.c -o libhello.so
where $JAVAHOME is the directory where you installed the Java release. The C compiler will create a file libhello.so in the current directory.

DOS shell (Windows 95/NT)
C:\> cl HelloWorld.c HelloWorldImp.c -Fehello.dll -MD -LD javai.lib
Note: You must have Microsoft Visual C++ Version 2.x to compile and link DLLs (Dynamic Link Libraries).

Note: javai.lib must be the last argument to the C compiler.

Note: To inform the compiler of the location of the Java C header files, add %JAVAHOME%\include to the environment variable INCLUDE:

C:\> set INCLUDE=%JAVAHOME%\include;%INCLUDE%

Note: To inform the linker of the location of the Java libraries, add %JAVAHOME%\lib to the environment variable LIB:

C:\> set LIB=%JAVAHOME%\lib;%LIB%


Previous