Creating JNI DLL on WinXP using MinGW and GCC

Ohh man, I spent entire day fighting with "UnsatisfiedLinkError "while trying to cal my native method. After reading all the posts with similar problems, and checking for every little thing that was suggested I figured it out. So I'm reposting the solution here since no one else had suggested this.
The solution to my problem was that g++/gcc compiler needed an option "-Wl,--add-stdcall-alias". This was the killer. I had the "-shared", but it wouldn't link without the "-Wl,--add-stdcall-alias" option!!!
As a summary, while its fresh in my mind, here are the trouble shooting steps I used:
1) Check package names and the generated .h file using javah. I checked and rechecked the names, even created simpler static void method to try and get it to link.
2) Make sure to use the "jobject" parameter for dynamic methods and "jclass" for static methods in the signature as second argument.
3) That method name starts with "Java_" and I stress the CAPITAL "J", can not be lowercase. Although if you are using javah, that should not be the problem, since javah can not ommit this kind of detail. The only thing that you need to check for is that if you change method from dynamic to static, and don't rerun the javah, or javah doesn't replace the previous file. So make sure you restart clean and that javah regenerated the file with "jclass" or "jobject" whichever is the case.
4) Used the "java -verbose:jni" debug flag to see my native method loaded. In my case when it wasn't working I couldn't see the method load, but there were no error messages from "System.loadLibrary" or from the verbose output. Only the UnsatisfiedLinkError. Frustrating. After the fix it loads perfectly:
[Dynamic-linking native method org.jnetpcap.Pcap.openVoid ... JNI]5) I used "nm" found at "c:/MinGW/bin/nm.exe" to dump the symbol table, and I could see all my methods, with the appropriate named marked as text (T) flag. They were not being loaded when viewed using "java -verbose:jni" though.
6) I put "extern "C" {}" around all my JNI C++ methods.
7) Tried a gazilion other gcc options, posted in various messages, none worked.
8) Finally came accross the "-Wl,--add-stdcall-alias" flag which fixed it.
Here is a portion of my Makefile for reference:
     g++ \
          -shared \
          -Wl,--add-stdcall-alias \
          -o [email protected] $^ \
          $(LIBDIRS) $(LIBS)LIBDIR and LIBS point to a single external library dependency.
My IDE environment is Eclipse 3.2, but I run everything from Makefiles as external programs.
I wish this was documented somewhere, would have saved me an entire day of troubleshooting.
Message was edited by:
voytechs - added CODE tags

Glad my post helped out at least a few people.
Believe it or not, I'm in the same boat now on Linux.
Atleast I know its the name mangling problem again. I
see a few symbols unmangled with nm, but most are,
and those are then one's JNI is complaining about
with UnsatisfiedLinkError.
So now I'm going through various post related to
linux and trying to find the same type of flag. The
"alias" flag doesn't work with RH4 g++ version
4.0.2.You should not need a flag on Linux. A typical compile for me on my Linux box is:
gcc -shared -o -I/usr/java/jdk1.6.0_01/include -I/usr/java/jdk1.6.0_01/include/linux jnitest.c>
Window builds perfectly fine, but now I'm creating a
new platform target. Everything compiles and creates
the shared library, just can't get JNI to be happy.
BTW, my project:
Ah. You have .cpp extensions on your filenames. Are you using gcc or g++ to compile? If you don't use g++, you can get errors such as:
undefined symbol: __gxx_personality_v0
Jim S.

Similar Messages

  • To add the JNI dll to the jar file and use the dll inside the jar file

    Hi to everybody,
    I am new to java.
    I want to add the JNI dll to the jar file and use it in the java class.
    How can I achieve it.
    Please help me.
    Thanks in advance.

    can't be done because none of the known operating systems support reading binary libraries from .jar files ... you can add the binary to the jar but then you have to extract it...
    besides, mixing platform specific and platfrom independent components is not a very good idea, i'd keep the dll out of the jar to begin with

  • Creating a DLL in Labview 8.6 and calling it from Visual Basic 6.0

    Dear friends,
    I need to create a DLL in Labview 8.6 and call it from Visual Basic 6.0. The system works as follows:
    I made an application using Labview 8.6 + Vision Assistant 8.6 where I can obtain the x,y coordinates of a template in an certain image being captured by an USB camera. The template coordinates change every time it moves and Visual Basic 6.0 must read these x,y values in real time. I found some information in the link, but it works for version 6.x of Labview and 8.6 version is different. Am I in the right path? If you have an updated tutorial like the one in the link above but for Labview 8.6 It would be very nice. Please help me.
    Kind regards.
    João Júnior

    Hello Osvaldo,
    I analysed the updated tutorial you sent me, but the thing is that it doen't show how to create the DLL in LV 8.6 but only show how to accessing the DLL from VB6. My problem is really HOW TO CREATE THE DLL IN LV8.6. In the link there is detailed information about how to do this in LV6.x, the problem is that I don't find the path Tools»Build Application or Shared Library (DLL) in LV8.6, I think the procedure in LV8.6 is a little bit different. Don´t you have an updated tutorial on how to build a dll in LV8.6?How could you help me?
    Kind regards.
    João Júnior

  • I am creating a slideshow with elements using photos and videos but the video sound doesnt play?

    I am creating a slideshow with elements using photos and videos but the video sound doesnt play?

     Hello jive
         I am playing it back in the slideshow editor/setting up part of
    programme where you determine photos/video to be included gaps between
    slides, music to play etc This goes through each phot and when comes
    to a video the background sound doesnt play, I am using windows 7 and
    elements 10.
         regards gins51

  • Developer-Online: Create a Digg login style using jQuery and CSS

    Create a Digg login style using jQuery and CSS
    Hello Friend, today We'll see how to create a Digg Login panel using only CSS3 and a bit of jQuery script. You'll see how is simple present a login feature using a modal window creates by js. You'll find the .ZIP tutorial visiting:
    Tags:    tips & tricks | JS
    Author: patrizio Quatrini
    Posted: 2010-02-04 10:57:48
    Brought to you by: Developer-Online

    Thanks Leonard
    On the surface that looks a mighty powerful product that probably goes far beyond what we require. Looking at the system requirements, it seems that some specific Application Servers are needed (is this correct?), which we won't have. Am I correct in thinking this is a modular based product, in that I buy a base product (being LiveCycle ES ... not sure what this product does on it's own) and then add a module such as PDF Generator to it?
    It's difficult to glean from the product web site exactly what this product is all about but my gut feel is it'll be a few steps beyond what we need to achieve. I might be wrong, so feel free to pull me up there but it seems this is along the lines of a total back-end Adobe solution.
    If you have any other suggestions I'd be grateful, otherwise I may need to continue down the "clunky yet serviceable" HTML to PDF route

  • Creating a DLL Driver for Use in VB

    I am trying to export a dll file for use in VB.  I used the build > dll option within my project to create a dll, but when I try to add the reference to Visual Studio, it says that it is not a valid assembly or COM component and I cannot add it.  Is there a setting I should set in the build settings to ensure this works?
    Billy Maier

    You aren't creating a .NET assembly or COM component so you are calling it incorrectly.

  • Create a new Buffered Image using Raster and ColorModel

    Sorry , I crosspost this message,because no one reply.
    Recently,I write a programme combining C++ and Java .
    The C++ part create a array containing image data in form of BI_RGB and biBitCount==32.
    The java part create a image using Raster and ColorModel like this:
       static int[] data ;
       DataBuffer db = new DataBufferInt(data, data.length);
       WritableRaster wr =Raster.createPackedRaster(db, 1024,768, 32, null);
       ColorModel cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
       img = new BufferedImage(cm, wr, false, null);But it doesn't work .
    it report this:
    Exception in thread "main" java.lang.IllegalArgumentException: Raster
    [email protected] is incompatible with ColorModel DirectColorModel: r
    mask=ff0000 gmask=ff00 bmask=ff amask=0
    at java.awt.image.BufferedImage.<init>(
    at monitor.test.Perform2.main(

    hey epico
    compiles & runs 4 me
    see javadocs for SinglePixelPackedSampleModel
    import java.awt.image.*;
    public class Tester {
    DataBuffer db;
    WritableRaster wr;
    ColorModel cm;
    BufferedImage im;
    int[] data;
    int[] masks;
    int w = 768;
    int h = 576;
      public Tester() {
        data = new int[768*576];
        for (int i = 0;i < w*h ;i++ ) {
          data[i] = 0;
        masks = new int[3];
        masks[0] = 0xff0000;
        masks[1] = 0x00ff00;
        masks[2] = 0x0000ff;
        db = new DataBufferInt(data,data.length);
        SinglePixelPackedSampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,w,h,masks);
        cm = new DirectColorModel(32,0xff0000,0x00ff00,0x0000ff);
        wr = Raster.createWritableRaster(sm,db,null);
        im = new BufferedImage(cm,wr,false,null);
      public static void main(String[] args) {
        Tester tester1 = new Tester();

  • Problem in Creating new row & inserting data using CreateInsert and Commit

    Hello All,
    I have created a page there are few input text and i want to insert the data into a database table. I have created an Application Module I am using CreateInsert and Commit operation but there is one problem.
    At first it created a row in database after that it is not creating the new row instead it is updating the same row with the new values.
    In bindings of my jspx page I have created two binding for action (1) CreateInsert for the VO of that Application Module (2) Commit operation of that Application Module.
    Here is the code snippet of my application:
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert");
    Object result = operationBinding.execute();
    *if (!operationBinding.getErrors().isEmpty()) {*
    return null;
    OperationBinding operationBinding1 = bindings.getOperationBinding("Commit");
    Object result1 = operationBinding1.execute();
    *if (!operationBinding1.getErrors().isEmpty()) {*
    return null;
    I have tried using Execute+Commit and Insert+Commit case also in every case it is updating the same row and not inserting a new row.
    Is there anything I am missing?
    Please Help.

    hi user,
    i dono. why are trying with codes. adf provides zero lines codes.
    a wonderful drag and drop functionality provide by the framework.
    while double click the button the codes are  registered in your bean
        public String cb6_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("CreateInsert");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        public String cb8_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("Commit");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        public String cb7_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding = bindings.getOperationBinding("Delete");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        public String cb14_action() {
            BindingContainer bindings = getBindings();
            OperationBinding operationBinding =
                bindings.getOperationBinding("Delete4");   // some different here. after deleting usually do commit
            OperationBinding operationBinding1 =  
                bindings.getOperationBinding("Commit");    // so here commit operation.
            Object result = operationBinding.execute();
            Object result1 = operationBinding1.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            if (!operationBinding1.getErrors().isEmpty()) {
                //add error handling here
                return null;
            return null;
        }if am not understud correctly. please some more explanation need.

  • Creating an Order Processing System Using XML and JavaBean/EJB

    I'm looking to design a solution for the following problem:
    A distributor creates a purchase order from a home grown system. This purchase order is sent to the company as a flat text file. This file must then be validated for both syntax and data values and then processed by their ERP system running on an AS/400.
    The solution I would like to provide is to place the data from this text file into an XML file and then create a system composed of server side components (either Java Beans or Enterprise Java Beans) that would parse the information and call the back end ERP processes (using business methods from within the beans). I have already developed a web app that processes orders using JSP and Java Beans. In this case however, the order will never be seen by a human unless it fails validation. I figured using XML to do this would not only be good for this part but also improve the e-commerce side as well. My only question is how to submit an XML document to a bean for processing without user intervention. Any information you can give me on this or even to point me in the right direction would be greatly appreciated. Thank you for your time.

    Thank you for responding to my question. I have several books here on XML but have not gotten very far in them as of yet. I understand how to create an XML document and a DTD, but I guess I haven't gotten far enough to understand how "submit" per say an XML page like you would an HTML form and then proceed to retrieve the data from the request parameters. I will research this further.

  • Portege S100 - Reinstall WinXP using F6 and RAID drivers

    I posting this in the hope that it helps somebody.
    Well my hard disk died, so got a replacement one. I did not have the original dvd so innocently I thought, just down load the drivers from the website.
    Well did all that and the raid was still not seen! Changed raid settins in the bios which you get to by pressing escape, then set to default settings, restart and go back into bios goto page 3 - which is then visible. Ensure the disk is set to1raid0 - download the manual, but you have to accept any changes by entering 1234 when it asks you for a string from the manual. Anyway did all that - still no drive visible - so whats going on.
    Well apparently there are 2 sets of drivers kr10n and kr10i - what the site givesyou is the kr10n drivers. Which may work for the newer ones but not mine! My laptop needs the kr10i Which I cant find on the tosiba website. BUT or you can google for raid-drv-20070719134547
    So the steps for me were use nlite to add the kr10i drivers to a patched WinXP SP3 cd and boot using that. It worked seamlessley.
    After that it all went great! Well I didnt have much hair to begin with, but even less after the process finished.
    Good luck

    Thanks for this posting mate;
    Additionally Ive found this nice Toshiba article about RAID installation on G20 and S100 units
    +S-ATA and Toshiba RAID Driver: "Setup did not find any hard disk drives installed in your computer" Error Message During Manual Installations+
    Check it out!

  • Creating Statement of Cash Flows using FSGs and ADI

    Has anyone tried to create a SCF in FSG's using ADI for customizations and macros? I am realizing that I can automate a few things for the client like some of the variances needed from B/S accounts.For the most part, it seems thatI cannot create a report directly from FSG's. I have had to create supporting reports and with macros I have tried to automate as much as possible to create the SCF from the supporting reports. The accountants will still have a few manual things to do but it should be much faster than initially. Is this the only way with FSG's or has someone gotten much closer to the real McCoy?

    Yes, ik did look at the Cash Flow report.
    What I need is similar to the Comparison Report, where you will take 2 Balance Sheets of 2 years and compare them. But I need to take this further, by then taking the Diufference between these 2 Balance Sheets and creating the 'Statement of Cash Flows'. This will not use all theBalance Sheet accounts, only certain ones.
    Thanks for your help.

  • Creating Deskband for Windows 8 using C++ and its communication with C++/Qt application

    I've already found described way of creating deskbands here -- and respective sources on SDK like
    But can't find any simple and straight article on how to use it for example in/from Qt-written application.
    Can someone recommend any resource where I can find way to implement own deskband for own application, please.

    There is no API for creating or showing menus on desk bands written by others, with the exception that a task bar button representing an application
    written by yourself, in that case you can use the Windows 7 Jump lists API (right click menu) or WM_SYSCOMMAND (shift+right click menu) to control the context menu of your own application. How other
    deskbands handle menus are completely up to their authors. 
    A deskband is an in-process COM server which means you must build a 64 bit version if you want to use it in 64 bit Windows Explorer.
    Visual C++ MVP

  • I have a poster sent to me created in illustrator and I have photoshop cs2.  I used the same dimensions from the original to create the poster in cs2.  After creating the poster in cs2 using images and texts from the original poster, I printed it off and

    So there is a lot of white space at the top and bottom of the page when I print off poster.  When I see the poster on the canvas on cs2 it looks how I want it to!  I am confused!  Help pls.  Also I am new to photoshop.
    When I sent the finished poster to the person I needed to send it to, it wasn't printing out how we wanted on A4.

    What system? What printer? What print settings? Most of that has nothing to do with teh Adobe apps, but your printer's capabilities and nobody can advise without that info.

  • How can I create an action that uses "Find and replace"?

    Hi there,
    I'm trying to create an action that will use "Find and replace" to change certain words and phrases in my .psd-files. These are words and phrases I change a lot (I'm translating emails and website banners) and I would like to speed up that process using actions.
    When I tried to create the action I got the error message "The object "in contents of all text layers" is not currently available".
    Then I tried "insert menu items" and chose "Find and replace" and then did my change, but then it stopped when the FAR-window popped up. That's what I want to skip, so it just changes my words and phrases that I want.
    Is this possible?

    Anyway, in the Script in that other thread the function replaceText takes two Strings, so something like
    function main () {
    var myDocument = app.activeDocument;
    replaceText ("replace this", "with this")
    would be a possibility.

  • Creat a DLL from a set of VIs

    I've a board that cames with Labview VIs for each of its functions.
    As I'd like to use it from CVI, I need a DLL.
    NI support team gave me the procedure to make such a DLL, it works fine.
    But, the create DLL can't be used by 2 application in same time, as it was possible with the old fashion driver on WindowsXP, delivered by the board supplier.
    When I've an application launched using functions in the DLL, it is loaded and seems to be "privative" to this application: if an other one tries to load the DLL, there is an error frolm Labview wrapper.
    Is there an option to make such DLL "reopenable" or "reentrant"?

    The DLL is written by Lavview tool to encapsulate VI and get them reachable from CVI: the board supplier no loger delivers a C-compatible DLL, only Labview driver and C# / .net / Java... modules, that implies heavy changes in our application to manage. NI support suggested to make this way a DLL from the set of VI delivered by supplier.
    In our case, on XP, the main application was using the board but it was possible in parallel to send commands from an other application.
    You're right it may be a question of locking resources by DLL / VIs functions: I'd like to know it there is a specific otpin when creating the DLL to make it reentrant and possibly get double access.

Maybe you are looking for

  • Data is not replicated on target database - oracle stream

    has set up streams replication on 2 databases running Oracle on windows. Steps for setting up one-way replication between two ORACLE databases using streams at schema level followed by the metalink doc I entered a few few records in the sour

  • How to use this function in crm5.2 -   /CEM/ENT_IMPORT_DATAFROMEXCEL

    i am having a problem regarding how to use this function to import values from an excel sheet. in call funtion what to specify at place of ct_ent_action = ? CALL FUNCTION '/CEM/ENT_IMPORT_DATAFROMEXCEL'   CHANGING     CT_ENT_ACTION       = EXCEPTIONS

  • Which trigger to use in this case

    Hello All, I have a form in which I have an list item STATUS STATUS may have values a or b or c or d One event should happen when user selects 'c' whose earlier status is 'b'. Here I have two doubts 1) Which trigger I have to use 2) How to get the ol

  • Cannot alter partitioned table with spatial column in Oracle

    Hello, I possibly discovered a bug in Oracle This script works fine with Oracle **: create table GEO_TABLE ( ID NUMBER(19) not null, PART_NAME VARCHAR2(50) not null, GEO_POS MDSYS.SDO_GEOMETRY, constraint PK_GEO_TABLE primary key

  • [J2ME] How to launch a .jar or .class with IM profile

    Hi all, I have tried and succeded to launch a .jar file with J2SE but with J2ME IM profile, I couldn't manage do the same because the URLClassLoader is missing. Does someone knows how to do that ? Thanks,