Re: symbols in static libraries by Coward
Coward
Sat Jul 19 08:27:42 CDT 2008
HI,
Thank you for your reply
Alex: I tried that setup myself in a separate solution/project
myself. it worked too. StaticLib1.h is included everywhere I use
kNotUsed. Otherwise, compile will NOT succeed, right? Also
StaticLib1.cpp is included in static lib 1 project(otherwise, I will
not be able to reference it from app.exe)
Norbert: I am not mixing C/C++ here. All projects are being developed
in VS2005.
As a bonus of sleep overnight, I found the solution. After I include
StaticLib1.h in StaticLib1.cpp(at the begining, I did not), the link
error IS GONE. Also,
0BF 00000000 SECT30 notype External | ?kNotUsed@@3HB (int
const kNotUsed) is showing up in the output of
dumpbin /symbols StaticLib1.lib
Do you know what configurations regarding whether to export a symbol
or not from a static library I am missing here?
Thank you again for your helps,
On Jul 19, 8:25=A0am, Norbert Unterberg <nunterb...@newsgroups.nospam>
wrote:
> Coward 9 schrieb:
>
>
>
>
>
> > I have an application that look like
>
> > =A0app.exe =A0 depends static lib 1 and static lib 2
> > =A0static lib 2 depends on static lib 1
>
> > in static lib 1, I have one header file and one cpp file
> > header:
> > =A0 =A0 =A0 =A0 =A0extern =A0 =A0const int =A0 =A0 =A0 kNotUsed;
> > cpp:
> > =A0 =A0 =A0 =A0 =A0const int kNotUsed =3D -1;
>
> > The weird thing is that I can use kNotUsed in my app.exe. =A0However, I
> > can NOT use kNotUsed from static lib 2. =A0Also, I used
>
> > =A0 =A0 =A0 =A0 =A0dumpbin /symbols StaticLib1.lib
>
> > and I could NOT find kNotUsed.
>
> > Thus, my questions are
> > 1. =A0why can I use kNotUsed from app but not from static lib2?
> > 2. if kNotUsed is not in the symbols, how can app.exe use it?
>
> Maybe this a C/C++ name mangling problem?
> Are all your three projects using the same language, or are you mixing C =
and C++
> code? If you need to access kNotUsed from both C and C++ code you must de=
clare
> it as extern "C" for C++ code.
>
> Norbert- Hide quoted text -
>
> - Show quoted text -