LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL Issues

Hey everyone,

 

I have recently begun using Labview for a specialized task. As a result, I started decided to start with bare basics and move on from there to get to more advanced issues.

 

Let's say for this issue I needed an external C/C++ program which writes doubles to a file.

 

__declspec(dllexport) double getDouble (double);

double getDouble (double value)
{
    std::ofstream outfile ("output3.txt");
    outfile << "This is a message that you should receive" << std::endl;
    outfile << "Appended Value: " << value << std::endl;
    outfile.close();
    return value;
}

 Awesome. We can now import this function into labview using Import -> Shared DLL. So I check the function, and it works. Fantastic I think. Let's call this file test1.vi

 

Now I close the files, and when the orange Labview start screen shows up again, I open test1.vi just to make sure it still works. It does.

 

Now I close everything. When orange Labview start screen pops up, I close that as well.

 

Immediately I re-open labview and start a new session. I open up test1.vi without modifying anything, and it does not work - the function returns the value we passed into it, but it does not write to a file. I create test2.vi with the imported function from the first step. It works correctly opening the file and overwriting it(or creating a new file). Open up test1.vi, doesn't work. Close everything again. Open test1.vi, still doesn't work. Open up test2.vi, now it also doesn't work.

 

Honestly, I am lost. I ran out of ideas, and hope that one of you might help.


Thank you very much.

0 Kudos
Message 1 of 6
(2,380 Views)

Use C instead of C++.

I never had this kind of problem with C dll.

 

George Zou
0 Kudos
Message 2 of 6
(2,379 Views)

Do you get any error outputs?

Is the dll in the search path? (details).

0 Kudos
Message 3 of 6
(2,376 Views)

Hi, The other two guys know the biz, all i can add is the difference between quiting the 'orange Labview start screen' and not is that when the orange screen is quit, LabVIEW memory is cleared.

If the orange screen is not quit, and you re-open the previous project/VI you were working on the values/states of the VIs appear to be retained.

 

Not sure if this will help with your trouble shooting, but it may be that you are linking/calling something which is retained in LabVIEW memory until the whole of LabVIEW is re-started.

Another possibility could be that you are not closing the ref/call to the .dll, which could leave it hanging, not accepting further calls (but i don't know much about .dlls...).

 

b

 

 

0 Kudos
Message 4 of 6
(2,363 Views)

Does it work if you provide an absolute path to the file, instead of just a filename?  How do you know where the file is created?  I wonder if your DLL is working fine, but because you are not specifying the output directory for the file it's getting saved somewhere you do not expect.

0 Kudos
Message 5 of 6
(2,357 Views)

Can you provide your VI with dll?

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 6
(2,355 Views)