This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
dynamic linking for C++
- To: gcc-help at gcc dot gnu dot org
- Subject: dynamic linking for C++
- From: Dachuan Yu <dachuan dot yu at yale dot edu>
- Date: Fri, 02 Nov 2001 16:14:02 -0500
- Organization: Yale University
How to turn on dynamic linking of C++ programs if I'm compiling with g++?
To be specific, I have a "B.cc" which I intend to build into a library. I used
g++ -shared -fPIC -o B.so B.cc
It seems working.
However, I also have a "C.cc" which contains a "main" and depends on this "B.cc". I tried
g++ C.cc B.so
It doesn't work, complaining about undeclared identifiers (which are defined in B.cc).
Due to specific reasons, I didn't include "B.h" in "C.cc". Is this saying that I'll have to include "B.h" if I want it to work?
Thanks in advance!
Dachuan