LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create and use in Labwindows my own static library (with functions and panel)

hello,

I would like to create and use in Labwindows my own static library (with functions and panel).
First I create some simple panel with callbacks and functions that are recalled from callbacks. It would be nice if I could do .lib and use it from any other new project in Labwindows. I'm trying to do this but it's doesn;t work. So the conclusin is - I don;t know how it should be done. Can you help me please ?

I think that static library would be easier than dll to use for me. Library would be better than including .c and .h file (in new projects) beacuse it could be used in external compilers (?)
0 Kudos
Message 1 of 12
(4,321 Views)
Hi,

You can customize the Library menu by adding the desired Function panels (fp file).Go to Library/Customize/Browse. Then Browse the path of the desired .fp file and restart LabWindows/CVI.The function panel selected by you will be added to the Library.

Hope this helps.

Regards,
Siddu
0 Kudos
Message 2 of 12
(4,318 Views)
means that .fp files are some kind of indispensable interface to functions in .lib ? I created that file, but there where a problem too, Don't remember - surely Labwindows throw some internal error and crushed.


Should the correct way to create and use .lib look like this : ?
1. Create new workspace, some controls on .uir, some functions in main .c file
2. Change Target to - Static Library
3. Compile Library
4. Create new workspace, .prj (where we want to use the library), .uir.
5. Add to project .lib and .h (of library)
6. add #include "nameoflibrary.h" to .prj
7. Now I want to recall function from library (but there's missing it's prototype I added the prototype to .h file but don't work (by the way in this file is info, that I shouldn't do that) )
8. If I want to loadpanel I just use Loadpanel(paneloflibrary.uir) ?
9. If I want interface to library for programmers I can create it ( .fp). If I don't want interface for programmers I need to create it too, but with no classes (only instrument)

Where I'm wrong ?
0 Kudos
Message 3 of 12
(4,315 Views)
Hi,

I do not think we can create a library with .uir (GUI). As far as my knowledge is concerned we can create static library of the normal functions or make a function panel act as library by customizing through Programmers tool box.

Regards,
Siddu
0 Kudos
Message 4 of 12
(4,315 Views)
tnx for reply

ok, so, first maybe i'll create .lib - i'll write some functions there (without main() ? )

then i'll try to use the library in new project (add to project NameOfLibrary.lib and #include NameOfLibrary.h ) ?

if this will work i'll create .fp - and load it as instrument driver or customized library

is it in good order ? something missed ?

greets, obibok
0 Kudos
Message 5 of 12
(4,296 Views)
I can't do it : /

My bibliotek.c file - source of .lib, looks like this:



#include "bibliotek2.h"

int test()
{
return 3;
}



bibliotek.h file :

int test();


In new project where I want to use the library - UseBibliotek.c (added .lib to project, .h and .lib files copied to project directory):

on top:
#include "bibliotek2.h"

and in one of callback :

SetCtrlVal(1,PANEL_NUMERIC,test());

and compiler says 'Missing prototype' : /

and what to do now ? ehhh

regards, frustated o.
0 Kudos
Message 6 of 12
(4,289 Views)
I have worked on creating GUI on various device drivers.

1. I create the various functions and function panels for the driver.
2. I build the dll for the driver which releases the .lib file also.
3. Then i create GUI calling the functions of the driver either by loading the function panel as an instrument or
by including the .lib file of the driver in my project.

This way it does not give any linking errors. You can load the function panel as an instrument or customize the .fp file to the library or add the .lib file generated when you build the Dynamic Link Library to your project and use the functions in your new application.

Regards,
Siddu
0 Kudos
Message 7 of 12
(4,285 Views)
Hi,

I tried working on your exapmle.I think including ivi.h to the header file solves the problem. Let me know about the results.

Regards,
Siddu
0 Kudos
Message 8 of 12
(4,284 Views)
Include ivi.h in bibliotek2.h
Then create a lib file and include that in your new project. That solves your problem.


Regrds,
Siddu
0 Kudos
Message 9 of 12
(4,283 Views)
Actually if you declare the function as

void _VI_FUNC test (int *value);
then you need to include ivi.h

Else if you are going to use normal C declaration then you do not need to include ivi.h

In both ways you need to include the .h file of the first project in your new .c file and .lib file added to your new project.

Check out the attachment.

test is my first project where i have declared the function GetValue which returns 3 as output. I have built test.lib using test.c and test.h in my project.
test_new is my new project with test_new.uir, test_new.c and test_new.h
I have included test.h in test_new.c and added test.lib for test_new project. It worked fine.

Regards,
Siddu
0 Kudos
Message 10 of 12
(4,282 Views)