I have two libs that share a extern variable. In libA I have the variable declared in the header as such:
extern int Gbl;
then I define it again in the source as:
int Gbl;
next then I set Gbl=1;
in libB, I include libA's header file. And printf Gbl, expecting to get 1 here.
though unfortunately i can't even compile this since I get the error:
undefined symbol '_Gbl' referenced in ....
开发者_如何学Go
I was told that this is a linking error, but I'm not sure what to do from here
You need to compile the libB with libA included. This is done by adding -llibA to the compile line. If you don't have library options set correctly, you need to add -lpath_to_library
精彩评论