include versus library files as cause of error?

Compiling I get the following output:
1
2
3
4
x64_MT9V034_vid\Debug/../src/main.cpp:142: undefined reference to `ArduCam_writeSensorReg'
\x64_MT9V034_vid\Debug/../src/main.cpp:143: undefined reference to `ArduCam_writeSensorReg'
\x64_MT9V034_vid\Debug/../src/main.cpp:145: undefined reference to `ArduCam_writeSensorReg'
x64_MT9V034_vid\Debug/../src/main.cpp:197: undefined reference to `ArduCam_close'


The definitions are in the .h file, on manual inspection. I've checked my spelling, etc. What is going on here? Is it possible I need to be scrutinizing the library files instead? And when one gets undefined ref is it more likely an include cause or a library cause?
Last edited on
Undefined reference means the linker cannot find the binary code representing that function.

To get as far as trying to link, the compiler must have finished. So the compiler was able to find the declaration of the function.

The definitions are in the .h file, on manual inspection.

Clearly not. I expect the declarations are in the .h file

The problem is one of the following:

1) You meant to write these functions yourself and you haven't
2) The functions are written but you're not compiling and linking the file they're in
3) The functions are in a library and you're not linking against that library.

Typically, a .h file contains a declaration of a function. The definition is either in a .cpp file, or it's in a library that you must link against. Perhaps one of these libraries: https://github.com/ArduCAM/ArduCAM_USB_Camera_Shield/tree/master/Windows/USBTest/x64/Release

Last edited on
Perhaps one of these libraries: https://github.com/ArduCAM/ArduCAM_USB_Camera_Shield/tree/master/Windows/USBTest/x64/Release


That is right on the money Repeater I've been delving into that library pretty hard. They released another much smaller and lightweight version, and if I go include crazy its going to get bloated all over. Thank you for clarifying.

I get confused when we use the words "linking against that library". Aren't we just linking to the library.? What's 'against' mean in this context? I am not suggesting you are incorrect, just my linguistics need some polishing -- what does against the library mean? I am probably doing it already and my words haven't caught up with my actions.

Thanks in advance

I get confused when we use the words "linking against that library". Aren't we just linking to the library.?
Both prepositions mean the same thing in this context. I.e. both modules are linked together into a final executable.

https://en.wiktionary.org/wiki/against#Preposition (see meanings 1.2 and 1.4)
https://en.wiktionary.org/wiki/to#Preposition (see meaning 9)
What is my strategy at this point?
You need to link to the library files provided by the developer.
You would also benefit greatly from understanding how plain text files become executable binaries and libraries. This would enable you to diagnose the problems in building yourself.

This is a pretty thorough explanation; https://www.daniweb.com/programming/software-development/tutorials/466177/understanding-c-from-source-to-binaries .

If you understand it, you will be somewhere in the top 20% of C++ programmers, in my experience.
Right place right time. I'll make understanding this article a mission. Hopefully I'll become the better for it, I really don't like being dependent.

Thx for all comments.
Topic archived. No new replies allowed.