automatom
automatom

Reputation: 275

Tricky Undefined Reference Error

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:

EDIT:

  1. I should mention that Module C's makefile also has -L/path/to/Foo and -lFoo, but it still fails. Any high-level guesses as to anything I should try? I have a feeling I'm going to have to post some code...

Upvotes: 2

Views: 2751

Answers (3)

automatom
automatom

Reputation: 275

I figured out why it wasn't building. It's the same problem as was had here:

undefined reference to symbol even when nm indicates that this symbol is present in the shared library

Upvotes: 1

tp1
tp1

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

Code-Apprentice
Code-Apprentice

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

Related Questions