| | |
Linker Error>Undefined reference error to xyz
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2005
Posts: 4
Reputation:
Solved Threads: 0
I am using Dev-C++ to create a dll file which will link Java-JNI-C-Fortran
The project contains CCode.C and JavaCode.h and when I compile, I find the following error: Linker Error>Undefined referece to 'sumsqauredf'
The CCode.C file is
<< moderator edit: added [code][/code] tags >>
The JavaCode.h is
<< moderator edit: added [code][/code] tags >>
The Fortran file FortranCode.f is
C FortranCode.f
<< moderator edit: added [code][/code] tags >>
How can I solve this prob?
Thanks
Rony
The project contains CCode.C and JavaCode.h and when I compile, I find the following error: Linker Error>Undefined referece to 'sumsqauredf'
The CCode.C file is
C++ Syntax (Toggle Plain Text)
// CCode with documentation #include <stdio.h> #include "JavaCode.h" // Required header for JNI // FORTRAN routines have to be prototyped as extern, and parameters are // passed by reference. Note also that for g77 the function name in C by // default must be prefixed by a "_". extern int sumsquaredf_(int *, int []); // When calling C code from Java, main() must be replaced by a declaration // similar to below, where the function name is given by "Java_" + the name // of the class in the Java code that calls this C code, in this case // "JavaCode", + "_" + the name of this C function called from Java, in this // case "sumsquaredc". This is followed by at least two parameters as below, // plus possibly more if more are required. JNIEXPORT jint JNICALL Java_JavaCode_sumsquaredc(JNIEnv *env, jobject obj, jintArray ja) { // Data from any additional parameters are passed via special pointers as // shown here. jsize n = (*env)->GetArrayLength(env, ja); jint *a = (*env)->GetIntArrayElements(env, ja, 0); int i,result; printf("-- We are now in the C program CCode --\n"); printf("Print contents of array a[] copied from arr[] in Java\n"); for (i=0; i<n; i++) printf("%2d %5d\n",i,a[i]); printf("Call the FORTRAN code\n"); // The data are passed to the FORTRAN program, then the results are returned // in a way similar to this. result = sumsquaredf(&n,a); printf("-- We have now returned back to the C program --\n"); printf("Print contents of array a[]\n"); for (i=0; i<n; i++) printf("%2d %5d\n",i,a[i]); printf("Sum of squares in array = %d\n",result); // Instead of ending as a normal C program, the pointers must be cleared // before returning to Java. (*env)->ReleaseIntArrayElements(env, ja, a, 0); return result; }
The JavaCode.h is
C++ Syntax (Toggle Plain Text)
/* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class JavaCode */ #ifndef _Included_JavaCode #define _Included_JavaCode #ifdef __cplusplus extern "C" { #endif #undef JavaCode_MAXSIZE #define JavaCode_MAXSIZE 10L /* * Class: JavaCode * Method: sumsquaredc * Signature: ([I)I */ JNIEXPORT jint JNICALL Java_JavaCode_sumsquaredc (JNIEnv *, jobject, jintArray); #ifdef __cplusplus } #endif #endif
The Fortran file FortranCode.f is
C FortranCode.f
C++ Syntax (Toggle Plain Text)
INTEGER FUNCTION SUMSQUAREDF(N,A) INTEGER A(*) WRITE(6,'("-- We are now in the FORTRAN program FortranCode --")') WRITE(6,'("Print contents of array A() copied from a[] in C " 1 "program - note the unit offset")') DO I=1,N WRITE(6,'(2I5)')I,A(I) ENDDO WRITE(6,'("Calculate then print out squares of elements with " 1 "accumulated sums")') ISUM=0 DO I=1,N A(I)=A(I)*A(I) ISUM=ISUM+A(I) WRITE(6,'(3I5)')I,A(I),ISUM ENDDO SUMSQUAREDF=ISUM END
How can I solve this prob?
Thanks
Rony
![]() |
Similar Threads
- Dev C++ linker errors, undefined reference (C++)
- [Linker error] undefined reference to `CQTMovieFile::CQTMovieFile()' (C++)
- newmat linker error (C++)
- What is it meaned [Linker error] undefined reference to `MAPILogon@24' (C++)
- Dev-C++, GLUI linker error, undefined reference (C++)
- Linker Error in derived class initialization (C++)
Other Threads in the C++ Forum
- Previous Thread: MAPI Unicode problem
- Next Thread: C++ How do you create multifile project
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion convert count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






