01-29-2009 04:31 PM
I'm using LW/CVI 7.0, FDS. I have a working program to acquire data from both a data acquisition board and two serial devices. I now need to add another sensor that acts as a TCP/IP server. I have successfully interacted with the new sensor that communicates via TCP/IP using a test program. In my data acquisition program, I will be acquiring the new sensor data from the main thread as it is callback intensive for the TCP/IP communications, and use a second thread for the existing DAQ board and two serial ports. If the program is unable to acquire the data fast enough, I will want to assign the second thread to the second CPU on the computer. The NI white paper "Multithreading in LabWindows/CVI" discusses setting the preferred processor for a thread using Win32 API function "SetThreadIdealProcesssor". LW/CVI automatically searches the Windows/SDK for unresolved references after searching the LW libraries. When I try to build the exe, I get an "Unresolved Reference" linker error for "SetThreadIdealProcesssor" function. In reviewing the NI provided "sdkfuncs.txt" and "sdkfuncs_base.txt" files, no reference to "SetThreadIdealProcesssor" is found. I did find the function prototype in the "winbase.h" file. I was unable to find "SetThreadIdealProcesssor" in any file where LW/CVI is installed except for a .pdf on multithreading and the "winbase.h" file.
Is or is not the "SetThreadIdealProcesssor" included with LW/CVI 7.0 FDS? If so, where and how do I reference it for linking. I did add "windows.h" and "winbase.h" as include files in an attempt to resolve the issue with no success.
I saw a forum discussion from a few years ago but it had no resolution.
Solved! Go to Solution.
01-30-2009 11:42 AM
Are you sure that it's a link error that you're seeing, and not a compile error? The problem that I see is that the function prototype in winbase.h has a preprocessor guard around it (presumably, because the function was only added in Windows 2000). Using these preprocessor guards to protect against inadvertent use of a function doesn't make a lot of sense, since what matters is the version of the OS where you're running your program, not the version with which you compile it.
In any case, you should be able to work around this by adding the following to the top of your source code (before you include windows.h😞
#define _WIN32_WINNT 0x0500
After you do this, you should no longer get a link error. Let me know if that's not the case.
By the way, the function implementatin is in C:\Program Files\National Instruments\CVI70\sdk\lib\msvc\kernel32.lib. You don't have to add this library to the project.
Luis