I'm modifying a program to collect data from a National Instruments spectrum analyzer. For correspondence with this piece of equipment, the reference to header file #include <ni488.h> is written into the program. The program was working fine before, but after I saved the updated program to my flash drive and another location where it needed to be, I started receiving these errors upon compilation:
1 2 3 4
[Linker error]undefined reference to 'ibdev@24'
[Linker error]undefined reference to 'ibwrt@12'
[Linker error]undefined reference to 'ibrd@12'
[Linker error]undefined reference to 'ibcntl'
and a host of other undefined references to functions defined in the header file mentioned above.
The ni488 header file is included in the folder with the program in each location where it was saved. Why is it now having trouble locating this header and what can I do to fix it? I've tried resaving the file and using Execute >> Rebuild All, but nothing seems to work.
To build on Vlad's answer, note that these are all linker errors. Linking happens after compilation; your code compiles fine. The problem is not in your code.
is included in the program and contains all of these functions. In fact, if I look at the "Classes" tab on the left side of the screen, all of these functions are included under the list of classes. Furthermore, when I click on one of these functions the ni488 header tab appears next to the main source file tab.
For some reason, though, the program does not recognize these functions when it compiles.
After reading Moschops's reply I looked at the error message again. The last two lines read:
1 2
Id returned 1 exit status
[Build error][RF-DFS.exe] Error 1
And prior to the second line, it gives the address for a Makefile.win file associated with the program. This must be why, for the other locations where it is saved, every time I attempt to compile, I get this error screen:
For some reason, though, the program does not recognize these functions when it compiles.
That is incorrect. You are not having compilation errors. You are having linker errors.
As I mentioned in the first paragraph,
#include<ni488.h>
is included in the program and contains all of these functions.
No, it does not. If it did, you would not be having those linker errors. It must contain declarations of those functions. This allows the compiler to ensure that you are using the functions correctly. It effectively leaves a note to the linker saying "here, please call the actual code that does the actual work for this function". The linker then goes looking through all the binary objects it has been told to look through, which will be your code and any libraries it has been told to look through. If it cannot find the actual (compiled) code that does the actual work, it comes back with the complaint "undefined reference".
That is what is happening here. Your code is compiling. You have not told the linker where to find the actual compiled code for these library functions.
Well like I said, I'm modifying someone else's old program that was written several years ago, and I don't have time to write a new one. I'm working with what I've got.
Do you have any ideas on why the program would have been able to find the code for the functions before, but not now?
No, it is not something for the source code (except in the abomination of recent version of Microsoft's Visual C++, but that's not relevant here). It is an instruction that gets passed to the linker, which is a separate executable program. Somewhere in your IDE is an option to tell it the library name, and the directory path the library is on.
No, MinGW does not support this, unlike Visual Studio.
You need to find "Linker settings" in your IDE and add all the needed libraries here, then rebuild.
I found the Linker settings and updated the library. I'm not getting the "undefined reference" notifications anymore. Thanks.
I'm still getting the "multiple target patterns" problem, though. Not sure what the origin of that is. From what I've read, it has something to do with third-party libraries and possible errors in directory names.
I'll read some more on it and try to see if I can untangle it.