Creating dll for JNI

hi,
anyone know how to create a dll in visual studio.net for JNI dynamic shared link library?

I think cl.exe is available even in Visual Studio .NET
So,
cl -Ic:\java\include -Ic:\java\include\win32
      -LD HelloWorldImp.c -Fehello.dllshould work
$

Similar Messages

  • How to compile a dll for JNI in the CMD correctly

    Now I find alot of old threads on using the mno command in cygwin to created dlls to use as an interface between c and Java, however I know this command is no longer available in cygwin and so I took the advid of downloading minGW and using this in the CMD instead.
    However every example I try to compile and run this way throws the unsatified link error when the native function is to be called by the Java program. I believe it must be a compiling error creating a mismatch between the native function and the function to be called.
    Here is the method I'm using to comile dlls for JNI, it is from the FAQ section of the minGw website:
    gcc -Wall -D_JNI_IMPLEMENTATION_ -Wl,--kill-at
    -Ic:/j2sdk1.4.1_02/include -Ic:/j2sdk1.4.1_02/include/win32
    -shared someJavaImp.c -o JavaImp.dll
    Is this how dll should be compiled? If not any suggestions?

    sudsey wrote:
    I know how to program well in C and Java, I just need to know the proper way to compile a dll for JNI.1. Get the MS IDE
    2. Create a dll project - it must NOT be a managed dll
    3. All done.

  • Problem in creating DLL for a LabVIEW VI

    Hi
    I am facing problems in creating DLL for a LabVIEW VI. Previously i had no problems in creating DLL for the VI that transmits a message from serial port to NI - PXI 7831-R Reconfigurable I/O card (configured by FPGA MOdule). When i try the same VI with a customized port developed using IVI drivers i am not able to create the DLL. It gives me error as follows:
    Fatal Internal error: "datamgr.cpp", Line No: 1882
    Please somebody help me out to fix this error.
    Regards,
    Subramania Bharathi

    Hi,
    Thanks for your curiosity in replying my questions. I am really sorry for replying so late. Actually the problem was with the NI SWITCH 2503 functions. Actually i was multiplexing the channels of my customized serial port using NI Switch module. This switching is done before i start my communication. My VI follows a sequence as follows.
    1. Connect two channelss using Switch functions
    2. configuration of both FPGA and the customized port
    3. Transmit data from the port
    4. Receive it in FPGA.
    5. Reset the channels using Switch functions
    I never expected that the error was because of NI Switch. When i removed them from my VI i was able to create the DLL and able to create sequence successfully to run in the Testsand. And
    further i am using Switch Executive for swithcing the channels in TestStand.
    But now i am very curious why it posted me that error when i used my NI Switch function?? I tried to create DLL for a VI that switches two channels and i was successful. But the error occurs only when i combine i with my FPGA functions!! If you could trace out the reason, please let me know
    Once again thanks a lot for your support
    Regards,
    Subramania Bharathi

  • Cannot create dll with JNI

    hi all,
    i have a c++ coding for a softphone. I opened that file in vc++ and i'm able to create a .exe file from that.
    the .exe file is running fine( it is searching for the server and is getting registered there).
    now i wanted to add jni to it.
    so i have written a java program to one of the methods in the c++ program( void pjstart() ), compiled it and created a header file.
    now i replaced the c++ function with the stuff generated in the header file,( JNIEXPORT void JNICALL Java_test_pjstart(JNIEnv *env, jobject jobj) )
    now i'm unable to build that file in vc++. it is showing some errors..

    You need to start by creating a dll project in VC using a wizard. That should compile, build and you can even load it in java although it won't do anything.
    Then you implement the signatures provided in the h file that you get from javah.

  • Create dll from labview

    Hi all:
    I am using labview 8.5 , i want to create dll for spacific vi , to use its output in another program like C++,
    can any one help me to learn the steps to create dll from labview
    thanks

    You need the application builder (which is part of the professional distro).
    In general you should every VI that you want as a function set to 'top-level'
    If you right click on the builds in your project you have an option to build a DLL (if you have the application builder), from there on the help is available.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • UnsatisfiedLinkError for JNI DLL compiled with vs2008 express

    I am trying to create a JNI DLL using Visual Studio 2008 Express.
    I have read several places where -MD causes JNI problems but from what I've read, I need this option to create the DLL properly.
    The DLL does get built cleanly and I have created a simple C application (obviously not calling the JNI functions themselves but the other functions that are in the DLL). This application runs with no problems.
    As soon as I try to use the DLL with JNI, I get an UnsatisfiedLinkError: Can't find dependent libraries.
    I have used Dependency Walker on the C application I created and it finds no errors; however, if I run it on the DLL itself, it does report an error trying to find msvcr90.dll which is in the winsxs directory under c:\windows so I assume this is the problem dependency.
    I am running this on the same computer that has Visual Studio 2008 Express SP1 installed. This is a Windows XP Service Pack 3 computer running JDK 1.6.0_14.
    Any help would be greatly appreciated.
    Thanks

    Right or wrong, I include some library files into my link statement (it's the only way I could find to clear up your question). I link in some standard window libraries as well as some of my own DLL whose functions are used by this DLL. I use a makefile to build my code.
    Here is a compile statement and the link statement for my DLL:
    cl.exe -I c:\progra~1\micros~1.0\vc\include -I c:\progra~1\mi2578~1\windows\v7.0\include -I c:/progra~1/java/jdk1.6.0_14/include -I c:/progra~1/java/jdk1.6.0_14/include/Win32 -I S:/wlw/Develop/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/Include -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/Example -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Client/Include/User -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/System -I S:/wlw/Products/Src/LibSrc/RTA/Server/Include/User -DRTA_DLL -D_BIND_TO_CURRENT_VCLIBS_VERSION -Zp4 -DWIN32 -D__WIN32__ -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -D_USE_32BIT_TIME_T -D_CRT_SECURE_NO_WARNINGS -nologo -W3 -Od -EHsc -MD -Z7 -c buildDate.c
    link.exe -incremental:no -nologo -debug kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib -dll -out:S:/wlw/Products/Obj/Win32/Lib/rta.dll -implib:S:/wlw/Products/Obj/Win32/Lib/rta.lib eipc_client.obj eipc_usersys.obj eips_pccc.obj eips_cnxn.obj eips_cpf.obj eips_encap.obj eips_iomsg.obj eips_rtasys.obj eips_timer.obj rta_utils.obj eips_userdf1.obj eips_userobj.obj eips_usersock.obj eips_usersys.obj jniRta.obj jniRtaPlc.obj jniRtaPlcAddress.obj qcRta.obj qcRtaPlcAddressLink.obj qcRtaPlcLink.obj qcRtaProcess.obj qcRtaRead.obj qcRtaSlcRead.obj qcRtaSlcWrite.obj qcRtaState.obj qcRtaTimer.obj qcRtaWrite.obj Q:/Develop/Obj/Win32/Lib/tcpipNet.lib Q:/Develop/Obj/Win32/Lib/linkList.lib Q:/Develop/Obj/Win32/Lib/stdUtils.lib buildDate.obj
    mt -manifest S:/wlw/Products/Obj/Win32/Lib/rta.dll.manifest -outputresource:S:/wlw/Products/Obj/Win32/Lib/rta.dll;2

  • Help creating .dll with c using JNI

    Hi. I have created a JNI application that uses C to call Java. Now, I am trying to create the .dll for windows. I am using VS C++ compiler. My program compiles; however, it doesn't seem to start the JVM. I am not sure how to pass the arguments in VS C++ while builiding and running. Please let me know. Thanks.

    Hey,
    Thanks. I apologize for not being clear. I have created the dll file and an application that links to that dll and executes the code. It creates the .exe file and when I execute it, it goes through the sample() function that just prints "Hello", and then it goes through the startJVM() function where the JVM is intended to start; however, the status of JVM is returning -1. It's not able to start JVM. I have included the path for the jvm.dll and jvm.lib. But, still won't work. Please reply with suggestions/comments. Thanks again.

  • How to create the C++ DLL for Windows Mobile and how to import it in C#

    Hi All,
         Please can u guide me for creating DLL on C++ and using it in C#
         1) Steps to create the DLL using C++ for Windows Mobile
         2) And where to place the DLL after builiding to make use of it in my C# project
    Thanks in Advance!!!
    Thanks & Regards,
    Sharan

    Hello all,
    I know this is an old thread but i have to give it a try ( i am stuck with an almost identical problem but cant solve it since 5 days googling and reading.
    I am developing an app for Unitech HT660e which has Win CE. THe app is complete but now i need some more control over the barcode scanner. In order to gain controll i need to use USI.dll which is explained in this documentation (chapter 2 has the link to
    the SDK which contains the USI.dll ) :
    http://www.datacol.co.nz/pdf/uni_prog-guide_1.21.pdf
    But i also get : Cant find PInvoke DLL 'USI.dll'.
    In chapter 4 is SysIOAPI.DLL mentioned which i cant fin.
    Chapter 17 has USICF.dll which may be interesting bcos this one can be added as reference and "using USICF" . I am using compact framework 3.5 for this and the emulator is "usa windows mobile 5.0 pocket pc r2 emulator". 
    Reading your post i noticed i can use the "Pocket PC 2003 SE Emulator" but it gives me the same error.
    Maybe i need to include a path in my code but i tried this as well...and get the same problem. Maybe i am missing something.
    Here is my code:
    using USICF;
    using System.Runtime.InteropServices;
    namespace SmartDeviceProjectzaDLLtesting
        public partial class Form1 : Form
            [DllImport("USI.dll", EntryPoint = "VibrationOn")]   //ignorethis?:,CallingConvention=CallingConvention.Winapi)]//Cdecl)]    //EntryPoint = "VibrationOn")]
            public static extern void VibrationOn(bool bEnable);
            public Form1()
                InitializeComponent();
            private void Form1_Load(object sender, EventArgs e)
               // USICF.USIClass usiba = new USICF.USIClass(this); // this gives an exception as well
               VibrationOn(true); // thiis causes the exception
     //           VibrationOn(false);

  • JNI: experience in creating DLLs with G++ (mingw32)?

    Hello.
    I'm trying to create a DLL:
    --------------/HelloWorld.cpp/------
    #include <jni.h>
    #include "HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj)
    printf("Hello world!\n");
    return;
    I previously created 'HelloWorld.java'
    class HelloWorld
    public native void displayMessage();
    static
    System.loadLibrary("HelloWorldImp");
    I created 'HelloWorld.class'.
    I created the header file 'HelloWorld.h':
    c:> javah -jni HelloWorld
    But I do not have any idea to create the DLL.
    I tried with:
    c:> g++ -I"D:\j2sdk\include" -I"D:\j2sdk\include\win32" HelloWorld.cpp -shared -o HelloWorldImp.dll
    But I get this error message when calling from 'Main.java':
    Exception in thread "main" java.lang.UnsatisfiedLinkError: displayMessage
    at HelloWorld.displayMessage(Native Method)
    at Main.main(Main.java:6)
    In order to get this message I created 'Main.java':
    class Main
    public static void main(String[] args)
    HelloWorld hello = new HelloWorld();
    hello.displayMessage();
    Does anybody have any experience in creating DLLs with G++???
    Thank you very much.

    Or is it better GCC?

  • Creating DLL and identifyin​g LVRTE for 32bit/64bi​t/WinXP/Wi​n7

    I have a labVIEW 2010 application (created on 32bitXP) to be distributed
    for
    -Windows XP 32 bit
    -Windows XP 64 bit
    -Windows 7  32 bit
    -Windows 7  64 bit.
    What kind of runtime engine will I need?
    I also found that
    - there is no runtime engine available for WinXP64 bit, what do I do for
    this
    OS?
    - there are multiple runtime engines for LV2010 (min/std/64bit).
    Can someone pls help me to dentify,
    Which link to use for which OS/bit combination with LV 2010.
    Also can someone help me to identify, if I need to build the application
    (EXE
    or DLL) in 4 different ways, for these 4 OS?
    regards
    Sandeep
    NI Software :  LabVIEW  version 2010
    NI Hardware :  None device

    Hi Greg,
    Thank you for your response too.
    Yes, I must have 32 bit RTE for running 32 bit DLL.
    And also I do want to have 32 bit DLL only (& not 64 bit one).
    To explain, let me propose the following case.
    I have a C# created (built in 32 bit mode for x86) parent EXE .
    I have C# created (built in 32 bit mode for x86) child DLL.
    The child DLL gets called successfully by parent EXE. In all 4 possible OS combinations. ie. 32bitWinXP,64bitWinXP,32bitWin64,64bitWin64.
    But..
    When I create a 32 bit DLL from 32 bit LabVIEW on XP32bit,
    it never gives me success to be called by 32 bit C# parent in 64bitWinXP, 32bitWin7, 64bitWin7.
    I am aware that I must not create 64bit DLL, becasue my C# EXE is built in 32 bit (& That's how it must be to be able to run in all 4 OS combinations).
    Below is my thread
    http://forums.ni.com/t5/LabVIEW/Creating-DLL-and-i​dentifying-LVRTE-for-32bit-64bit-WinXP-Win7/m-p/13​...
    Thanks for reading thru.

  • Creating Labview Host DLL for FPGA

    I have created a DLL for the FPGA host VI.
    The host VI neads a loop to keep the FPGA running in labview but a call to the DLL function will not return while the loop is running.
    If I change host VI to one shot I asume that the FPGA start and stop with each call.
    I could load FPGA vi into flash set to run but I think that it will stop after first call from DLL.
    Seem like a catch 22.
    Thanks

    I found that I could run without the loop OK by closing the FPGA reference but not stopping the FPGA card running.
    My problem now is, that the DLL does not seem to work.
    I included a control updating an indicater and exported just those peramiters in the DLL but I can not get it to work with Borland C++Bulder 5.
    Other DLL's that I create with Labview work OK.
    Is there a broblem creating DLL's from host vi?

  • Create CVI DLL for HP Basic

    I was asked to create a DLL from my CVI project to use in HP/HT
    Basic.  How do I go about in creating one and using it in HP/HT
    Basic?  Is there any particular settings in CVI I need to
    configure to be compatible with HP/HT Basic? 
    Gary Z.

    Hello Gary Z.
    After doing a little research it looks like HT-Basics requires that you
    use the _cdecl calling convention when creating DLLs.  So in CVI,
    navigate to Options >> Build Options and select cdecl as your
    default calling convention.  Some other things you need to
    consider is how you declare your data type in your C DLL, and how you
    call them in HT-Basic.  Some websites I found helpful were: Using
    a DLL in HTBasic and DLL Rules.
    Hope that helps.
    Wendy L
    LabWindows/CVI Developer Newsletter - ni.com/cvinews

  • Dll for java help...

    I 'd like to create a specific dll usable by java and i just have one dll not usable with java.
    i need your help if you know a routine, program .. that create automatically my dll for my java use.

    So im'going to be clear for people of all the world
    I'm working on a project in which i have to communicate with an video acquire board. I must retrieve video signal send by the camera to the video acquire board.
    Video acquire board constructor gives me a dll and a lib with functions but has not anticipated that maybe somebody will use a java program (Bad for me to be polite...)
    My problem is to call the methods of the constructor dll in java .I must use jni to generate a specific dll undertsood by java (dll containing a c and a h file with JNIEXPORT syntax.)
    But the constructor dll is not correctly written by the constructor to be interpreted by java.
    So the dll i must generate has to communicate with constructor dll and there, it is the dark side...
    Can you help me or have i lost you?

  • Using gcc (in Cygwin) for JNI - resource.h not found. drand48 not found

    Hello,
    I am trying to use gcc for JNI. I have successfully executed simple programs like Hello World and Message Box. Now I have a C project that I am trying to use in JNI (Its FOIL 6.4 by Quinlan).
    I have written the .java file and the .c (wrapper) file and am calling the top level function from FOIL. Whenever I try to run it I get several errors.
    sys/resource.h: No such file or directory.
    /tmp/ccGi67I4.o:state.c:(.text+0x4cb): undefined reference to `_drand48'
    /tmp/ccGi67I4.o:state.c:(.text+0x85a): undefined reference to `_drand48'
    I have the resource.h file in C:\cygwin\usr\include\sys but it still doesnt find it.
    And drand48 is present in one of the include files, but it still gives me this error.
    the way I use gcc to create the dll is:
    $CYGWINBIN/gcc-3.exe -mno-cygwin -I$jdk/include -I$jdk/include/win32 -Wl,--add-stdcall-alias -shared -o foilJNI.dll foilJNI.c global.c main.c input.c output.c state.c literal.c evaluatelit.c search.c determinate.c order.c join.c utility.c finddef.c interpret.c prune.c constants.c
    where $CYGWINBIN is C:\cygwin\bin
    and $jdk is C:\Java\jdk1.6.0_20
    Can anyone please tell me where the problem is.
    Any suggestions are welcome.
    Thanks
    Nick

    lahscin wrote:
    (Its FOIL 6.4 by Quinlan).
    Any suggestions are welcome.You want to do some task using a C library and then interface that to java.
    Two parts, not one.
    So
    1. Define the task. This has nothing to do with code (java or C.)
    2. Write C code that represents a library/API to achieve that task. This has nothing to do with java nor JNI.
    3. Unit test 2 until it works.
    4. Write JNI code to use the API from 2. This involves JNI/java.
    Until you reach step 4 none of your questions have anything to do with JNI/Java. So you ask them on C forums, C compiler forums and forums specific to the library you are using.

  • How to create dll in Visual Studio 2008 in Visual C++

    Hello,
    I have insatlled Visual Studio 2008. I have to create DLL in Project
    type Visual C++.
    Which Template i have to select to reate dll, MFC DLL or Class
    Library?.
    I have to call or import this dll in Windows Forms Application. How
    can i do this. Please give details procedure to do this.

    If we look at how  AFX_CLASS_EXPORT and AFX_CLASS_IMPORT  are defined in afxv_dll.h we see the following.
    #define AFX_CLASS_EXPORT __declspec(dllexport)
    #define AFX_CLASS_IMPORT __declspec(dllimport)
    So, when exporting our classes from our DLL we want the class declarations from the DLL to look like this:-
    class __declspec(dllexport) CMyClass : public CObject
    And, when importing our C++ classes into our application we want the class declarations from the DLL to look like this:-
    class __declspec(dllimport) CMyClass : public CObject
    OK, so here's how I do things.
    In the stdafx.h file for the export DLL, include two #defines at the bottom of the file like this:-
    #define _MYLIB_DLLAPI_
    #define _MYLIB_NOAUTOLIB_
    Now, in the main header file for your DLL, say mylib.h (the main 'point of entry' header for your DLL that you will include in you application later), add the following at the top:-
    // The following will ensure that we are exporting our C++ classes when
    // building the DLL and importing the classes when build an application
    // using this DLL.
    #ifdef _MYLIB_DLLAPI_
        #define MYLIB_DLLAPI  __declspec( dllexport )
    #else
        #define MYLIB_DLLAPI  __declspec( dllimport )
    #endif
    // The following will ensure that when building an application (or another
    // DLL) using this DLL, the appropriate .LIB file will automatically be used
    // when linking.
    #ifndef _MYLIB_NOAUTOLIB_
    #ifdef _DEBUG
    #pragma comment(lib, "mylibd.lib")
    #else
    #pragma comment(lib, "mylib.lib")
    #endif
    #endif
    Now, just declare all the C++ classes you want exported from the DLL like this:-
    (Note: Any C++ classes not declared with MYLIB_DLLAPI will not be exported from the DLL)
    class MYLIB_DLLAPI CMyClass : public CObject
    regards,
    Matt John
    complete variety of quilts is availabale here!
     PR: wait...
     I: wait...
     L: wait...
     LD: wait...
     I: wait...
    wait...
     Rank: wait...
     Traffic: wait...
     Price: wait...
     C: wait...

Maybe you are looking for

  • Archiving and backing up.

    I have recently had a nasty crash in which i lost everything on my system hard drive. now i want to start archiving and backing up to cd. i started archiving with my itunes folder which was around 6gig but the zip file was around 5.8gig. Aren't the z

  • I get the message " user name orginization or serial numberi is invalid"

    When I try to launch Photoshop elements I get a message stating that there is a problem with the organization  or user name or the serial number and must shut down. I have an older computer running Microsoft XP 64.  This product has been working fine

  • Fetching the value of a BOL attribute.

    Hi All, I have a requirement where I need to enable some field (say A) on the basis of the value which  I enter in some other attribute(say B) of the same context node. That means, if value of B = " some value" then A should be enabled, and by defaul

  • Photo Quality gone bad

    Yesterday upgraded my Ipohone3GS to IOS 4 software. All went off smoothly but have realised the quality of the existing pictures has gone bad except the ones in the Camera Roll folder. All are looking blurred. Any ideas!!!

  • Transaction Value with negative inventory

    Dear Experts, I need some help understanding why negative quantity inventory can result in a huge transaction value for an inventory item. Let me give an example. We do allow negative inventory. We manage inventory by item group and we use FIFO. We h