LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[Beginner question] Add new *.C file to project correctly

Hi

 

I have completed the "Getting Started Manual" (http://www.ni.com/pdf/manuals/373552g.pdf), and would like to extend my program by adding new *.C-files to the project. Here is the situation:

 

Say I add a single Quit-button to my canvas, and I want its function "CVICALLBACK QuitCallback" to be in an external file "quit_ext.c". Is there a smart way to do this, or doI have to manually create the header and C-file?

0 Kudos
Message 1 of 8
(4,069 Views)

One possibility is to create a new file in the project file browser. Then, in the UI editor, you can choose the menu item Code / Set Targe File to select to which file your callbacks are added. Then use Code / Generate...

0 Kudos
Message 2 of 8
(4,061 Views)

I can't get that to work. I start with a fresh project, add a Quit-button and a new ext.C-file. Then I set the Code Target File to ext.C and press Ctrl-G on the Quit-button (to generate code). When I compile, I get the error:

 

NON-FATAL RUN-TIME ERROR:   "test.c", line 47, col 5, thread id 0x00000A90:   The callback function, QuitCallback, specified in the UIR file, is not a known function.  If you are using an external compiler, you must include the UIR callbacks object or source file in the executable or DLL.


Another thing is, that ext.C does not get its own header? That is probably the reason why it doesn't work.. do I have to add that myself?

0 Kudos
Message 3 of 8
(4,054 Views)

So your project consists of the files test.c, ext.c, test.h, test.uir?

 

In your C file calling the function QuitCallback, do you have a line such as

 

#include "test.h"

?

 

 

0 Kudos
Message 4 of 8
(4,051 Views)

Yes, that is what my project consist of. And yes, I have "test.h" included in ext.C

0 Kudos
Message 5 of 8
(4,045 Views)

 NON-FATAL RUN-TIME ERROR:   "test.c", line 47, col 5, thread id 0x00000A90:   The callback function, QuitCallback, specified in the UIR file, is not a known function.  If you are using an external compiler, you must include the UIR callbacks object or source file in the executable or DLL.

The error suggests that you load your panel in the file test.c; on loading the panel, CVI checks if all callback functions are known, obviously QuitCallback is not known yet so you will need to include test.h in test.c, too.

 

You may also want to have a look here and here

0 Kudos
Message 6 of 8
(4,040 Views)

But test.h is in test.c too, that is why I don't get it. Thanks for the links, I will take a look at them too at a later point.

0 Kudos
Message 7 of 8
(4,033 Views)

For some magic reason it works now.. don't know why, I didn't change anything. But the conclusion is: The only extra thing that needs to be added is the C-file, the (single, unique) header-file LabWindows updates manually.

0 Kudos
Message 8 of 8
(4,020 Views)