Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compiling/linking with common/criss crossing references

Status
Not open for further replies.

syedmuha

Programmer
Nov 18, 2004
1
0
0
US
I used to know how to do this..

I have a bunch of files and I need to know how to link them together using vc. theres four classes: a,b,c,d and a global.h . a references b. b references c and d. a,b,c,d all reference global.h, which defines a number of key global variables ( legacy code) .

i need to compile and run them. compiles okay. linker coughs on multiple symbols. i tried avoiding this problem by defining c and d in a single header file, referencing global from that file, using that file in b, and referencing b in a, hoping that global.h would cascade through to a. but im still getting LNK2005 errors on the variables defined in global.h. i've tried
- declaring all variables in global as static
- declaring them in global and then assigning them later on

how do i link/reference my files so that i avoid this stupid stupid error?

ps: im using vc6
 
In global.h, declare them as "extern" instead of "static". Then in one and only one of a/b/c/d, declare them again without "extern".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top