This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Undefined Reference Trying to invoke Java from C++ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Undefined Reference Trying to invoke Java from C++" Watch "Undefined Reference Trying to invoke Java from C++" New topic
Author

Undefined Reference Trying to invoke Java from C++

Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

I am trying to create a Java virtual machine from C++ and invoke the main method passing a String argument to the main method of the Java program. I am following this example found on Sun's website: http://java.sun.com/docs/books/jni/html/invoke.html#11202

Here is the simple Java Program:



Here is the C++ program I am using to (try to) invoke the JVM:



Anyway If I just compile the file with:



It compiles fine, but when I try to compile and link:



I get two weird errors that I don't understand:

TestJNIInvoke.cpp:18: undefined reference to `operator new[](unsigned int)'
TestJNIInvoke.cpp:26: undefined reference to `_imp__JNI_CreateJavaVM@12'
collect2: ld returned 1 exit status



I marked the lines in the above code where the error is occuring, has anyone encountered this problem before?

Any ideas/links would be great

Thanks


Also posted here: http://stackoverflow.com/questions/7547206/undefined-reference-trying-to-invoke-java-from-c

"If the facts don't fit the theory, get new facts" --Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Undefined Reference Trying to invoke Java from C++
 
Similar Threads
Invoking JVM through C++ code
JNI : undefined reference to JNI_CreateJavaVM()
Undefined reference in JNI
Undefined reference in JNI
Here is how to create process and Image APPName.exe file instead of java or javaw