LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiply defined symbol

I declare the functions in a .h file, I declare the functions in a .c file, and I call the functions from another .c file, and when I run the program, messages "Multiply defined symbol '_XXX' in modules 'YYY.c' and 'ZZZ.c' appears.
0 Kudos
Message 1 of 4
(7,399 Views)
This problem often occurs when you declare and initialize a global variable in a .h file that is included in multiple .c (or other .h) files.
If you just declare a global in a .h (but don't initialize it in the .h), you can include that .h in as many files as you would like. But you should initialize it (assign an initial value to it) in only one .c file, not in the .h file.
0 Kudos
Message 2 of 4
(7,399 Views)
Declare the function, i.e., put the function prototype in the .h file.
Define the function in the corresponding .c file.
#include the .h file in the other .c files that will be using the function.
0 Kudos
Message 3 of 4
(7,399 Views)
Hello,
From your email, it sounds like you have multiple declarations of the same function, once in the header file (.h) and another in the source file (.c). You need to declare it only once. A good programming practice would be to declare it in a header file and define it (implement the function body) in the source file. Then, you can include the header file in any source file so that you can call the function.

Mika Fukuchi
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(7,399 Views)