LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Link errors when using 3rd party static library with custom function panel

I'm getting a link error with a custom function panel I have created. The function panel references functions in a 3rd party .LIB file. My function panel is .c and .h files (not compiled to LIB or DLL). 3rd party .LIB file is added to the project. I get unresolved external errors when linking.
 
I've discovered that if I add my function panel .c file to my project, all is well. However, I don't want that to be a requirement for others using my function panel. (i.e. want them to simply load the instrument and go).
 
Any help would be much appreaciated.
 
Thanks,
Mike.
0 Kudos
Message 1 of 5
(3,444 Views)
Any project which uses your function panel will clearly need to be able to call its code somehow: if you don't supply a dll or lib then the only thing left with your code in it is the C file, which is why it effectively becomes part of the new project. Have you tried creating a static library file, or a dll with an import library, to overcome this problem?
 
JR
0 Kudos
Message 2 of 5
(3,431 Views)

Usually when I create an instrument driver function panel, a project only needs to load the instrument, even if the function panel is implemented as a .c and .h -- the project will compile just fine without adding the .c or .h to the project.

This instrument driver I am creating requires a 3rd party library that is an import library to a DLL. The DLL contains the low-level functions that communicate with the instrument. My function panel wraps these low-level functions.

So my function panel looks like this: myInst.c, myInst.h, myInst.fp where myInst.h includes the 3rd party driver.h that provides the function prototypes for the 3rd party driver.lib.

When my instrument is loaded into a developer project, the functions in the 3rd party library can't be found by the linker even if the library is added to the project.

Tried creating my own static library for my function panel -- received an error saying that the 3rd party library can't be included in the static library I want to build. So, no luck there.

I did discover two work-arounds but I don't like either of them:

1. Add the .c file for my function panel to the developer project and add the 3rd party library to the developer project.

2. Add the 3rd party library to the developer project then under the Build menu I choose Target Settings, click Add Files to Executable, and place a check mark beside the 3rd party library file. However this seems rather complex and non-intuitive (it's like I am adding the file twice)

In either case, there are additional, unexpected steps to get my instrument working with the project. Developers expect to load the instrument and go.

Is it possible to build an instrument driver, using a 3rd party library, that can simply be loaded as an instrument with no need for additional steps?

Thanks, Mike.

0 Kudos
Message 3 of 5
(3,424 Views)
Try creating a dll of your function panel, which incorporates the 3rd party functions. Then only your import library needs to be added to any project which uses the function panel. (Not forgetting to eventually include the actual dll files, both your function panel and the 3rd party ones, to the distribution kit.) This approach works very well - I have used it many times.
 
JR
0 Kudos
Message 4 of 5
(3,421 Views)
Thanks! That'll work ...
0 Kudos
Message 5 of 5
(3,417 Views)