05-01-2012 10:10 AM
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.
05-01-2012 10:15 AM
Use C instead of C++.
I never had this kind of problem with C dll.
05-01-2012 10:33 AM
05-01-2012 12:21 PM
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
05-01-2012 12:29 PM
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.
05-01-2012 12:33 PM
Can you provide your VI with dll?