dcsimg
Compiling with C++ Builder Command Line Tools
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adolfo_Aladro
Posted On:   Monday, February 18, 2002 11:45 AM

Hi, I'm making a program that invokes the JVM: #include #include #include #define MAIN_CLASS "test" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { JNIEnv* env; JavaVM* jvm; JDK1_1InitArgs vmargs; jint rc; jclass cls; jmethodID mainId; char* szClasspath = getenv("CLASSPATH"); vmargs.version = 0x00010001; JNI_GetDefaultJavaVMInitArgs( &vmargs );    More>>

Hi,


I'm making a program that invokes the JVM:



#include

#include

#include

#define MAIN_CLASS "test"



int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

{

JNIEnv* env;

JavaVM* jvm;

JDK1_1InitArgs vmargs;

jint rc;

jclass cls;

jmethodID mainId;



char* szClasspath = getenv("CLASSPATH");

vmargs.version = 0x00010001;

JNI_GetDefaultJavaVMInitArgs( &vmargs );



vmargs.classpath = szClasspath;

rc = JNI_CreateJavaVM( &jvm, &env, &vmargs );

if( rc < 0 )

return 1;

cls = (*env)->FindClass( env, MAIN_CLASS );

if( cls == 0 )

return 1;

mainId = (*env)->GetStaticMethodID(env, cls, "main", "([Ljava/lang/String;)V");

if( mainId == 0 )

return 1;

(*env)->CallStaticVoidMethod(env, cls, mainId, 0);

(*jvm)->DestroyJavaVM( jvm );

return 0;

}



I use the following command line:



bcc32 -IC:JDK11~1.8include -IC:JDK11~1.8includewin32 -LC:JDK11~1.8lib -tW test.c


but I always end up getting the same error message:



Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'JNI_GetDefaultJavaVMInitArgs' referenced from C:TEMPTEST.OBJ
Error: Unresolved external 'JNI_CreateJavaVM' referenced from C:TEMPTEST.OBJ


Which way should I compile this program?


Thanks in advance.

   <<Less

Re: Compiling with C++ Builder Command Line Tools

Posted By:   Laurent_Mihalkovic  
Posted On:   Tuesday, February 19, 2002 04:58 PM

check http://www.borland.com/techpubs/borlandcpp/v55/updates/cmd.html for a complete reference of the command line tools from C++ builder.


assuming that %JDK_HOME% points to your J2SE sdk,

bcc32 .... -L%JDK_HOME%libjvm.lib

on the 1.4 VM, your two missing functions are listed as 12 and 4 in the export table

Re: Compiling with C++ Builder Command Line Tools

Posted By:   Shashi_Sharma  
Posted On:   Tuesday, February 19, 2002 03:27 PM

You should add the jvm library in the command line. I myself dont know what is that lib. But if you go to the directory jdk1.1.1lib and do dir *.lib you can find it. Let says you find jvm.lib in the above directory then add
bcc32 .......-LC:jdk1.1.1lib jvm.lib...
About | Sitemap | Contact