Hello friends,

I am facing a linking problem in VC++8.0 compiler.

Suppose I have a library, say A.dll.
In this library I have a file, say x.cpp. Within this file there is a extern const variable, like

.....
__declspec( dllexport ) extern const long ERROR = 100; 
.....

Now I am trying to access that constant from another library, say B.dll.

...
extern const long ERROR;
...
void ABC::func()
{
       std::cout<<ERROR;
}
...

Now whenever I am trying to build B.dll I am getting a linking error like
ABC.obj : error LNK2019: unresolved external symbol "long const ERROR" ....

I have already linked A.lib in the makefile to generate B.dll

Pls help me to fix the problem.

Thanx,
Amit

Check and make sure that you have defined ERROR in you code.

Use static before __declspec...first lib.!...

One more point I want to mention that it is running fine (obviously except __declspec( dllexport ) ) in Solaris environment with Sun Studio 10 compiler.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.