how to share a variable among modules

These are old archives. They are kept for historic purposes only.
Post Reply
creative1
Posts: 2
Joined: Thu Oct 06, 2005 2:53 am

how to share a variable among modules

Post by creative1 » Thu Oct 06, 2005 3:02 am

Hi there,

I had some code that was working fine on 3.2.2 but for reason i can't get it to work in 3.2.3. Btw Im compiling under vc 7 (windows).

My question is simple, if i want to share a variable among 2 modules: m_pingpong and m_nick
how can i do so?

I tried everything I could think of but i always get a external reference not found.

For instance let's say I want to share the variable int MyCoolVariable = 0;
what i tried was to put that variable into ircd.c
then add it as a extern int MyCoolVariable into struct.h
then use it in m_pingpong and m_nick

compile using nmake -f makefile.win32

everything starts compiling ok until i get this errors:

Generating Code...
Compiling...
M_LUSERS.C
Generating Code...
Creating library L_COMMANDS.lib and object L_COMMANDS.exp
M_PINGPONG.obj : error LNK2019: unresolved external symbol _mycoolvariable reference
d in function _m_mycoolfunction
M_NICK.obj : error LNK2019: unresolved external symbol _mycoolvariable referenced in
function _m_nick
src/modules/commands.dll : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.


So what's the deal? how can i achieve this result? I spent 10 hours with this and no matter how i organize the code i keep getting that error.

btw, this is important, im trying to stop a current attack on my network of 2000 viruses :(

Joaquin

creative1
Posts: 2
Joined: Thu Oct 06, 2005 2:53 am

found it!

Post by creative1 » Thu Oct 06, 2005 3:17 am

great, the whole day working on this and when i decide to ask for help, it hits me and i solve it... amazing
the solution is to add the variable into the wircd.def file, i just remembered that vc uses that file to link dlls.

I hope this posting helps some other desperate soul.

Joaquin

Post Reply