Reputation: 275
I've run into a tough "undefined reference" error when trying to build a module in Linux with C++. I'm going to describe it at a high level, and post code later if necessary (it's proprietary, so posting it would require some name changing). Some details:
Module C - whose output is an executable - contains references to module B. When I try to build Module C, then it yells at me for the undefined reference from Module B to Module A's Foo and Bar methods.
EDIT:
Upvotes: 2
Views: 2751
Reputation: 275
I figured out why it wasn't building. It's the same problem as was had here:
Upvotes: 1
Reputation: 1207
When you create shared library, all the symbols do not need to be defined. This behaviour can be changed with compiler commandline switches(linker option --no-allow-shlib-undefined) if needed.
Upvotes: 0
Reputation: 83577
Does module B build or just compile? Are you actually linking module B to module A before you try to build Module C? I would be surprised if you are. In the compiling stage, the compiler only checks that all names are declared. The compiler doesn't look for an definitions (i.e. implementations). The linking stage takes care of this detail. In the linking stage, you need to specify all modules needed to build the project (in this case A, B, and C.)
Upvotes: 0