M
mshngo
Hi,
I am having the following trouble in compiling DLL on windows. Suppose
I want to compile module A into a DLL library, and I want to declare an
external interger n in A. My intention is to have n actually defined in
another module B, and I want to compile B into an executable, which
will dynamically load module A at run-time. Such reference can then be
resolved when B loads A. Is there a way to achieve this? Right now when
I tried compiling module A into DLL, I got linker error LNK2001:
unresolved external symbol. (I'm using Visual Studio 2005)
It seems if I were to try compiling A into a static library or an
object file, this design could go through: A will first be compiled
successfully into a .lib or .obj file, which is then linked into the
object file for module B to form an executable. During that link stage
this external integer reference can be resolved.
One possible way around this is that instead of having A access the
global integer n, we pass the reference of n from B into A, when B
invokes certain function exported by A that reads and/or writes that
interger. On the other hand, if I have many global objects defined in
B, and want functions defined in A to access them, such parameter
passing will seem like an unnecessary burden. Any suggestions? I very
much appreciate your help!
Mingsheng
I am having the following trouble in compiling DLL on windows. Suppose
I want to compile module A into a DLL library, and I want to declare an
external interger n in A. My intention is to have n actually defined in
another module B, and I want to compile B into an executable, which
will dynamically load module A at run-time. Such reference can then be
resolved when B loads A. Is there a way to achieve this? Right now when
I tried compiling module A into DLL, I got linker error LNK2001:
unresolved external symbol. (I'm using Visual Studio 2005)
It seems if I were to try compiling A into a static library or an
object file, this design could go through: A will first be compiled
successfully into a .lib or .obj file, which is then linked into the
object file for module B to form an executable. During that link stage
this external integer reference can be resolved.
One possible way around this is that instead of having A access the
global integer n, we pass the reference of n from B into A, when B
invokes certain function exported by A that reads and/or writes that
interger. On the other hand, if I have many global objects defined in
B, and want functions defined in A to access them, such parameter
passing will seem like an unnecessary burden. Any suggestions? I very
much appreciate your help!
Mingsheng