Thread: How to generate an DLL file in Eclipse?

  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    4

    Question How to generate an DLL file in Eclipse?

    I just re-installed my OS some days ago,which contained Visual Studio.But I don't want to use the VS any more(at least in my computer) as the interminable installing process.Then I take Eclipse as my C/C++ IDE by MinGW and CDT.
    My Java program need to load an DLL file which wrote by C.But when I generating the DLL file,I got some errors.It seems that the compiler cannot find the header files.
    By the way,I just want to implement the hello-world program in C and invoke it in the Java program.
    This is my Java testing program:
    Code:
    public class HelloWorld{    public native void printHelloWorld();
        static{
            System.loadLibrary("hello"); 
        }
        public static void main(String[] args){
            new HelloWorld().printHelloWorld();
        }
    }
    And this is the header file generating by "javah HelloWorld":
    Code:
    /* DO NOT EDIT THIS FILE - it is machine generated */#include <jni.h>
    /* Header for class HelloWorld */
    
    
    #ifndef _Included_HelloWorld
    #define _Included_HelloWorld
    #ifdef __cplusplus
    extern "C" {
    #endif
    /*
     * Class:     HelloWorld
     * Method:    printHelloWorld
     * Signature: ()V
     */
    JNIEXPORT void JNICALL Java_HelloWorld_printHelloWorld
      (JNIEnv *, jobject);
    
    
    #ifdef __cplusplus
    }
    #endif
    #endif

    And this is the C file:
    Code:
    #include "jni.h"#include "HelloWorld.h"
    
    
    #include<stdio.h>
    
    
    JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)
    {
        printf("Hello world!\n");
        return;
    
    }

    And this is the screenshot of error:
    How to generate an DLL file in Eclipse?-20131116202217-jpg

  2. #2
    Registered User
    Join Date
    Oct 2013
    Posts
    4
    I have solved the problem but I'm not sure whether it's the standard way:I copy the "jni_md.h" file into my project because "jni.h" includes "jni_md.h" and then it compiled successfully.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Eclipse CDT: Binary File Not Found
    By hqt in forum C++ Programming
    Replies: 4
    Last Post: 04-05-2012, 08:05 AM
  2. Generate asm listing file with CL
    By keira in forum C Programming
    Replies: 2
    Last Post: 08-24-2008, 10:12 AM
  3. Replies: 2
    Last Post: 03-13-2008, 05:45 AM
  4. how to generate data from file
    By vearns in forum C++ Programming
    Replies: 7
    Last Post: 12-27-2006, 08:59 PM
  5. Generate Excel-file using C/C++. How?
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 08-01-2002, 01:57 AM

Tags for this Thread