LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

compiling SDK functions with CVI

Hello,
I am including SHBrowseForFolder from SDK in a CVI project.
I noticed that compiling the project became very slow, and if I
comment out the SDK fragment of the code, it becomes very fast. To
have an idea of the difference, I am talking about 1 minute with SDK
against 10 second without.
Any reason for that?
0 Kudos
Message 1 of 8
(4,019 Views)
Hi,

First of all make sure that you clear the watch window before compiling; this can slow down compiling time significantly. The next thing to check is where is this time being spent. Do you know if this extra time is spent compiling or linking? It is possible that going through the lib file to find the function is taking a lot of time. It's also possible that the h file contains references to other h files taking a long time to compile all the dependencies.

You may want to pre-process the file to check the size of the file that actually being compiled and compare it with Vs without SDK calls.

Please give this a try and let me know how this goes.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 8
(4,019 Views)
JuanCarlos wrote in message news:<506500000005000000C1920100-1079395200000@exchange.ni.com>...
> Hi,
>
> First of all make sure that you clear the watch window before
> compiling; this can slow down compiling time significantly. The next
> thing to check is where is this time being spent. Do you know if this
> extra time is spent compiling or linking? It is possible that going
> through the lib file to find the function is taking a lot of time.
> It's also possible that the h file contains references to other h
> files taking a long time to compile all the dependencies.
>
> You may want to pre-process the file to check the size of the file
> that actually being compiled and compare it with Vs without SDK calls.
>
> Please give this a try and let me know how this goes.
>
> Regards,
>
> Juan Carlos
> N.I.

First of all: I forgot to mention that I use version 5.5 of CVI.
To me, it seems that it is spent in compiling.
You can try to reproduce it with the following code, commenting out
the first line to see the difference with/without SDK:
//--------------CODE_BEGIN---------------------
#define USE_SDK_LIB
#ifdef USE_SDK_LIB
#include
#include
#endif
#include
#ifdef USE_SDK_LIB
int GetFolder(char* DirName) {
BROWSEINFO bi = { 0 };
LPITEMIDLIST ItemID;
LPMALLOC imalloc = NULL;
int ret;
bi.ulFlags = BIF_NEWDIALOGSTYLE;
bi.lpszTitle = "Select SESSION Directory";
ItemID = SHBrowseForFolder(&bi);
if( SHGetPathFromIDList(ItemID, DirName) ) {
ret = 1; //OK
}
else {
ret = 0; //no selection
}
// free memory used
if ( SUCCEEDED( SHGetMalloc ( &imalloc )) ) {
imalloc->lpVtbl->Free (imalloc, ItemID );
imalloc->lpVtbl->Release (imalloc );
}
return ret;
}
#endif
int main (int argc, char *argv[])
{
char dir[MAX_PATHNAME_LEN];
if (InitCVIRTE (0, argv, 0) == 0) {
return -1; /* out of memory */
}
#ifdef USE_SDK_LIB
GetFolder(dir);
#else
DirSelectPopup ("", "Select Directory", 1, 1, dir);
#endif
MessagePopup ("Selected dir", dir);
return 0;
}
//--------------CODE_END---------------------

Thanx 4 your help
0 Kudos
Message 3 of 8
(4,019 Views)
Hi,

Sorry for the late response, I was out last week. I notice a couple of things while compiling your code: first I notice that the CVI package included with CVI 7.0 does not include the h files for the shell API; I am not sure about the reasons for this but it is possible that we did not went through the h files and fix them for C compilation.

Second, when you pre-process the C file generates 65,000 lines of code. This is a lot of code, you may want to download the demo version of CVI 7.0 to see if you get a faster compile time. You can also compile your CVI project in Visual C++ or just that specific function.

I hope this helps.

Juan Carlos
0 Kudos
Message 4 of 8
(4,019 Views)
JuanCarlos wrote in message news:<50650000000500000027990100-1079395200000@exchange.ni.com>...
> Hi,
>
> Sorry for the late response, I was out last week. I notice a couple of
> things while compiling your code: first I notice that the CVI package
> included with CVI 7.0 does not include the h files for the shell API;
> I am not sure about the reasons for this but it is possible that we
> did not went through the h files and fix them for C compilation.
>

Thank you for your reply; do you mean that I can patch the h file of
the distribution to remove the extra inclusions?

> Second, when you pre-process the C file generates 65,000 lines of
> code. This is a lot of code, you may want to download the demo version
> of CVI 7.0 to
see if you get a faster compile time. You can also
> compile your CVI project in Visual C++ or just that specific function.
>
> I hope this helps.
>
> Juan Carlos

I will try to compile a .lib with Visual C++, because the CVI project
is quite big. I do not want to upgrade CVI for the moment.

Elio
0 Kudos
Message 5 of 8
(4,019 Views)
Elio,

To be able to compile the Windows SDK in CVI (C compiler only) we went through the set of h files and changed them to be C compliant. We did not included the shell API; so you could create your own h files with only the functions and typedefs that you really need; this would definatelly reduce your compiling time. However if this is a one-time priject it would make more sense just to create a lib or dll in VC++ anc call it in CVI.

I hope this helps.

Keep me posted.

Regards,

Juan Carlos
0 Kudos
Message 6 of 8
(4,019 Views)
JuanCarlos wrote in message news:<506500000005000000539C0100-1079395200000@exchange.ni.com>...
> Elio,
>
> To be able to compile the Windows SDK in CVI (C compiler only) we went
> through the set of h files and changed them to be C compliant. We did
> not included the shell API; so you could create your own h files with
> only the functions and typedefs that you really need; this would
> definatelly reduce your compiling time. However if this is a one-time
> priject it would make more sense just to create a lib or dll in VC++
> anc call it in CVI.
>
> I hope this helps.
>
> Keep me posted.
>
> Regards,
>
> Juan Carlos
Juan,
I finally got it faster by removing the shlobj.h inclusion and
defining the necess
ary funcions, however I was unable to do the same
with objidl.h, it is too difficult for me.
Compiling time is still slow but reasonable now.
Thank you for your help
0 Kudos
Message 7 of 8
(4,019 Views)
I'm glad to hear that this is working. Sometimes is just faster to create your own functions declarations for just what you need.

Let us know if you need any further help.

Regards,

Juan Carlos
0 Kudos
Message 8 of 8
(4,018 Views)