I’m working on a project where I have the following scenario.
libFirst.lib
Has a function foo
that I want to access from libSecond.lib
. I defined foo
as an extern
in Second.c
and compiling the libraries went OK. Errors occur when I try to link the whole project to build the executable. The linker says that foo
is an undefined symbol. I tried adding libFirst.lib
and libSecond.lib
together to form libComposite.lib
and link it.
$> ar ruv libComposite.lib First.obj Second.obj
$> ranlib libComposite.lib
When I view libComposite.lib
with tools like nm
I see all the symbols are there in the same library but it still not working.
The question is, Is it doable? Can I just add the libraries together and by doing that the function will be defined? If not, What is the best way to achieve a similar behavior?
1