It means you haven't written a function, or you haven't created a variable, or you haven't linked against the library or object code that contains the missing function or variable.
It means the linker has looked through all the compiled code you told it to, and it still can't find what it's looking for.
Weird, I have a series of database which are struct's and all of those are contained in one include file. Those structs are used by multiple cpp's. Originally I was getting a duplicate symbol error so I rewrote it to use extern and now it is generating an undefined symbol error. What is the best way to go about fixing this?
A struct is identical to a class in C++, except for default privacy and default privacy inheritance. It will make no difference.The problem is not what kind of object it is.
The proper way to deal with this would be to have one object created in one place and pass it as a parameter to whichever functions need it.
Well I did what you said above, however I am getting a duplicate symbol error on on of my instances.. These errors are getting real annoying and I dont know what to do
First off, thank you so much for your help. Secondly I am trying to have one instance accessible from multiple cpp's. I have a header file which has the definition of the structs, I have a cpp which has the the extern definition of the instance extern food somefood, I have another cpp which has the instance just defined food somefood and some functions that use it and I have another cpp which also has food somefood and some functions. What is wrong here?
I have another cpp which has the instance just defined food somefood and some functions that use it and I have another cpp which also has food somefood and some functions. What is wrong here?
Two cpp which define food somefood. Should be just one. All the rest should be marked with extern.
Note that global variables are not a good thing and it's far better to write it such that functions that need to work on a variable have that variable passed to them, rather than fetching it from global namespace. Like this: