This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dynamic linking for C++


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]