I am writing a Java program on Suse Linux 11 using JavaSE-1.6 and I am having a problem building using javac.
I am following the tutorial on
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html
and have so far written the following:
package com.ctest;
class CTest
{
// Native method declaration
native int testCall();
// Load the library
static
{
System.loadLibrary("fpdpReaderLib");
}
public static void main(String args[])
{
int retVal;
// Create class instance
CTest cLangTest = new CTest();
// Call native method
retVal = cLangTest.testCall();
System.out.println(retVal);
}
}
When I run javac CTest.java i get an error:
/usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: in function '_start':
/usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to 'main'
/tmp/cc97kcJu.o:(.data+0x28) undefined reference to 'hidden alias for int com::ctest::CTest::testCall()'
/tmp/cc97kcJu.o:(.data+0x74) undefined reference to 'hidden alias for int com::ctest::CTest::testCall()'
collect2: ld returned 1 exit status
I am suspecting it is using gcc rather than the java version of javac but I'm not sure.
Any ideas what the problem could be?
I have tried using the "--main=" option mentioned here:
http://gcc.gnu.org/java/faq.html#4_1
but instead of the error before I now just get:
/tmp/ccwfugWq.o:(.data+0x28) undefined reference to 'hidden alias for int com::ctest::CTest::testCall()'
/tmp/ccwfugWq.o:(.data+0x74) undefined reference to 'hidden alias for int com::ctest::CTest::testCall()'
collect2: ld returned 1 exit status