c++ - What does exporting a symbol mean? -
i have been looking term " exporting symbol" couldn't useful.what exporting symbol means in c/c++ or respect libraries(shared/static).from export symbols , why? relation of exporting symbol name mangling compiler.
ps : hour have posted question on "what name mangling" thinking in relation *exporting symbo*l.but sadly question down voted 4 times , later closed.i agree duplicate.but want know exporting symbol (top protiy ) , relation name mangling.(if @ there is)
rgds, softy
exporting symbol means "advertising" existence in object file/library , is, imported (=linked to) other modules.
link can done statically or dynamically, either way linker has know symbol is, , is, , exported symbol , imported symbol must match happen. name mangling related (c++ name mangling includes symbol's type definition in symbol name, , mangling of exported , imported symbol must match linker link import-export correctly).
example:
suppose have library "standardc" (random name) , program someprog. program someprog needs print console, call printf. don't implement printf in program someprog, use (=import it), while implementation elsewhere.
the library standardc has list of symbols exports includes functions implemented in library , can called outside (=exported functions). printf 1 of such functions, appear in exported list.
the compiler goes through someprog.c , sees reference printf, there's no implementation it. compiler adds printf list of imported symbols resulting someprog.obj, linker link actual implementation in.
the linker takes someprog.obj file , standardc .lib file, , sees functions used in someprog.obj. linker finds printf not implemented, imported, linker looks through .lib files has , finds matching printf in exported list of standardc. takes implementation of printf standardc , links program everywhere reference imported symbol printf.
Comments
Post a Comment