digitalmars.D.learn - surprised by link error
- Daniel Davidson (65/65) Oct 16 2013 The following code runs fine. There is a whole bunch of types
The following code runs fine. There is a whole bunch of types imported, so whittling it down to the problem is not too easy. import plus.models.assumption; import pprint.pp; import std.stdio; import std.datetime; void main() { immutable am = AssumptionModel(); writeln(pp(am)); } That code writes a formatted view of the assumption model. One small code change: writeln(pp(am)); => writeln(pp(&am)); Does not cause a compile error, but rather a link error (using rdmd even with --force): How is this possible? Link Error: --- errorlevel 1 | Undefined symbols for architecture x86_64: | "_D44TypeInfo_HAyayS4plus6models6common9RateCurve6__initZ", referenced from: | _D6object58__T16AssociativeArrayTAyaTyS4plus6models6common9RateCurveZ16AssociativeArray6rehashMFNdZHAyayS4plus6mod ls6common9RateCurve in linkerror.o | "_D56TypeInfo_HAyayS4plus6models10assumption15DateAssumptions6__initZ", referenced from: | _D6object70__T16AssociativeArrayTAyaTyS4plus6models10assumption15DateAssumptionsZ16AssociativeArray6rehashMFNdZHAyayS4plus6models10assumpt on15DateAssumptions in linkerror.o | "_D57TypeInfo_HAyayS4plus6models10assumption16AssetAssumptions6__initZ", referenced from: | _D6object71__T16AssociativeArrayTAyaTyS4plus6models10assumption16AssetAssumptionsZ16AssociativeArray6rehashMFNdZHAyayS4plus6models10assumpti n16AssetAssumptions in linkerror.o | "_D61TypeInfo_HAyayS4plus6models10assumption20LiabilityAssumptions6__initZ", referenced from: | _D6object75__T16AssociativeArrayTAyaTyS4plus6models10assumption20LiabilityAssumptionsZ16AssociativeArray6rehashMFNdZHAyayS4plus6models10assumption20 iabilityAssumptions in linkerror.o | ld: symbol(s) not found for architecture x86_64 | collect2: ld returned 1 exit status ---------------------------------- Original successful output: { (AssumptionModel).inflation = { (RateCurve).curveData = [ ] } (AssumptionModel).assetAssumptions = { } (AssumptionModel).liabilityAssumptions = { } (AssumptionModel).accountGrowthMap = { } (AssumptionModel).incomeModelOverrides = { } (AssumptionModel).expenseModelOverrides = { } (AssumptionModel).dateAssumptions = { } }
Oct 16 2013