Chapter 10

An Object-oriented Approach

Chapter 10

Postby Cuchulainn » Mon Mar 12, 2007 10:02 am

Exercises and Answers
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Tue Jan 22, 2008 6:55 pm

Some files that were missing from Chap 10 directory (FDM)
Attachments
fdmdirector.zip
(5.34 KiB) Downloaded 1217 times
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Sphere369 » Wed Jul 08, 2009 8:09 pm

Hi,



Running testBSPDE1.cpp I have the link error message below (it seems that the variables in the namespace BlackScholesOneFactorIBVP has already defined somewhere in the file testBSPDE1.cpp):



1>G?n?ration de code en cours...

1>Compilation du manifeste en ressources en cours...

1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0

1>Copyright (C) Microsoft Corporation. All rights reserved.

1>?dition des liens en cours...

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDMDirector.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>BSOneFactorPDE.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>FDM.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) d?j? d?fini(e) dans testBSPDE1.obj

1>C:\sphere369\DistanceLearning\Code\Part1_Cpp_Essential_Skills\Debug\Chap10_BSPDE1.exe : fatal error LNK1169: un ou plusieurs symboles d?finis ? diff?rentes reprises ont ?t? rencontr?s

1>Le journal de g?n?ration a ?t? enregistr? ? l'emplacement "file://c:\sphere369\DistanceLearning\Code\Part1_Cpp_Essential_Skills\Chap10_BSPDE1\Debug\BuildLog.htm"

1>Chap10_BSPDE1 - 22 erreur(s), 2 avertissement(s)
Attachments
testBSPDE1.cpp
(2.72 KiB) Downloaded 860 times
Sphere369
 
Posts: 17
Joined: Tue May 19, 2009 10:51 pm

Postby Cuchulainn » Thu Jul 09, 2009 11:43 am

Thanks for the response. It seems the namespace and FDM class were missing. See code below.



remarks.

1. Array.hpp, .cpp class in chap 10 should be renamed

2. you need cpps for Utilities directory (e.g. stringconversion)



hth
Attachments
FDM.cpp
(2.83 KiB) Downloaded 786 times
BSOneFactorPDE.hpp
(943 Bytes) Downloaded 777 times
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Thu Jul 09, 2009 12:18 pm

here is the output.
Attachments
BSFDM.jpg
BSFDM.jpg (132.41 KiB) Viewed 33205 times
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Sphere369 » Thu Jul 09, 2009 8:01 pm

Cuchulainn wrote:


1. Array.hpp, .cpp class in chap 10 should be renamed







Detail please. Are the files OldDuffyArray.cpp, OldDuffyArray.hpp I have to rename to Array.cpp and Array.hpp in despite of the facts that these lasts files are already included in the directory Utilities/VectorsAndMatrices?



Cuchulainn wrote:Thanks for the response. It seems the namespace and FDM class were missing. See code below.



remarks.

2. you need cpps for Utilities directory (e.g. stringconversion)



hth






Below is the list added (but still having the error message) in my project's 'additional include directories' box (after have unpdated the files contained in the zip file fdmdirectory.zip below) :



C:\CPP2006\Utilities\PropertySet;C:\CPP2006\Utilities\PayoffFunctions;C:\CPP2006\Utilities\ODE;C:\CPP2006\Utilities\Instruments;C:\CPP2006\Utilities\Geometry;C:\CPP2006\Utilities\Functions;C:\CPP2006\Utilities\ExceptionClasses;C:\CPP2006\Utilities\ExcelDriver;C:\CPP2006\Utilities\BitsAndPieces;C:\CPP2006\Utilities\Algebra;C:\CPP2006\Utilities\DataStructures;C:\CPP2006\Utilities\DateAndTime;C:\CPP2006\Utilities\VectorsAndMatrices





However, I have re-downloaded yours two lasts files (FDM.cpp and BSOneFactorPDE.hpp) but I still having the same errors messages.
Sphere369
 
Posts: 17
Joined: Tue May 19, 2009 10:51 pm

Postby Cuchulainn » Thu Jul 09, 2009 9:18 pm

Only rename Array in Chapter 10 directory.



Start new empty Console project.



Add

testbspde1.cpp

exceldriver.cpp

Stringconversions.cpp



references to dirs



ExceDriver

Geometry



Build project
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Sphere369 » Fri Jul 10, 2009 6:47 pm

Hi,

It was due to a small syntax error.



FDMDirector.cpp has to be renamed FDMDirector.hpp.



And in testBSPDE1.cpp, #include "ExcelDriver.cpp" has to be changed in #include "ExcelDriver.hpp" (since it doesn't contain any template class...).



I even now have the excel map :D.



Sphere369
Sphere369
 
Posts: 17
Joined: Tue May 19, 2009 10:51 pm

Postby Cuchulainn » Sat Jul 11, 2009 11:08 am

that's a better solution, indeed.

The reason I used .cpp was to avoid having to put them in the project, to make life easier for readers.



Thanks for the feedback.

D
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Sphere369 » Fri Jul 17, 2009 4:35 pm

You're welcome. I've just taken this last problem like my first exercises.



Regards,



Sphere369
Sphere369
 
Posts: 17
Joined: Tue May 19, 2009 10:51 pm

linking error with chapter 10, VC++ 2008

Postby steve » Sun Apr 04, 2010 5:03 pm

I am using VC++ 2008 express to compile code in chapter 10 and having below lnk errors. I've searched a lot but could not solve it. Could anybody kindly assist? Many thanks.



1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2019: unresolved external symbol "public: void __thiscall ExcelDriver::CreateChart(class Vector<double,long,class FullArray<double,class std::allocator<double> > > const &,class Vector<double,long,class FullArray<double,class std::allocator<double> > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?CreateChart@ExcelDriver@@QAEXABV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@0ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@11@Z) referenced in function "void __cdecl printOneExcel(class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?printOneExcel@@YAXAAV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

1>testBSPDE1.obj : error LNK2019: unresolved external symbol "public: void __thiscall ExcelDriver::MakeVisible(bool)" (?MakeVisible@ExcelDriver@@QAEX_N@Z) referenced in function "void __cdecl printOneExcel(class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?printOneExcel@@YAXAAV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

1>testBSPDE1.obj : error LNK2019: unresolved external symbol "public: static class ExcelDriver & __cdecl ExcelDriver::Instance(void)" (?Instance@ExcelDriver@@SAAAV1@XZ) referenced in function "void __cdecl printOneExcel(class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class Vector<double,long,class FullArray<double,class std::allocator<double> > > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?printOneExcel@@YAXAAV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@0AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

1>testBSPDE1.obj : error LNK2019: unresolved external symbol "public: void __thiscall ExcelDriver::CreateChart(class Vector<double,long,class FullArray<double,class std::allocator<double> > > const &,class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &,class std::list<class Vector<double,long,class FullArray<double,class std::allocator<double> > >,class std::allocator<class Vector<double,long,class FullArray<double,class std::allocator<double> > > > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?CreateChart@ExcelDriver@@QAEXABV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@ABV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@ABV?$list@V?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@V?$allocator@V?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@@std@@@4@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@33@Z) referenced in function "void __cdecl printInExcel(class Vector<double,long,class FullArray<double,class std::allocator<double> > > const &,class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &,class std::list<class Vector<double,long,class FullArray<double,class std::allocator<double> > >,class std::allocator<class Vector<double,long,class FullArray<double,class std::allocator<double> > > > > const &)" (?printInExcel@@YAXABV?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@ABV?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@ABV?$list@V?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@V?$allocator@V?$Vector@NJV?$FullArray@NV?$allocator@N@std@@@@@@@std@@@3@@Z)
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby Cuchulainn » Sun Apr 04, 2010 7:19 pm

There are a few issues



1. use Vector from here

http://www.datasimfinancial.com/forum/v ... .php?t=203



2. I assume you are running tstPDEBS1. The namespace has been added



3. MS changed Excel interface after 2006. So, for the moment, you can run the program without Excel. After that I will provide the new code.



4. I assume you have "additional include files" defined in project properties (dirs. VectorsAndMatrices, DataStructures, Geometry, ExcelDriver, PropertySet, Chapter12)



5. Th CD has ready-to-run projects where all is defined. Make directory C:\cpp2006



Let me know how you get on. hth
Attachments
testBSPDE1.cpp
(2.81 KiB) Downloaded 698 times
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby steve » Mon Apr 05, 2010 8:19 am

Thanks for your prompt reply. Still got error:

1. file testBSPDE1.cpp include file "FDMDirector.cpp" which does NOT exist. I search for all folders in CD room and there is no such file.

2. Assume it is a typo, I tried to include "FDMDirector.hpp" instead. Then got the same error LNK2005 as posted previously.

But I do note that the error LNK2019 disappear.

3. Vector.cpp and Vector.hpp are separated from above error. I tried to compile with both old and updated version, see the same error as reported below:

Looking forward to hearing from you.





1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::sigma)(double,double)" (?sigma@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::f)(double,double)" (?f@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::mu)(double,double)" (?mu@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::IC)(double)" (?IC@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCR)(double)" (?BCR@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::BCL)(double)" (?BCL@BlackScholesOneFactorIBVP@@3P6ANN@ZA) already defined in FDM.obj

1>testBSPDE1.obj : error LNK2005: "double (__cdecl* BlackScholesOneFactorIBVP::b)(double,double)" (?b@BlackScholesOneFactorIBVP@@3P6ANNN@ZA) already defined in FDM.obj



Cuchulainn wrote:There are a few issues



1. use Vector from here

http://www.datasimfinancial.com/forum/v ... .php?t=203



2. I assume you are running tstPDEBS1. The namespace has been added



3. MS changed Excel interface after 2006. So, for the moment, you can run the program without Excel. After that I will provide the new code.



4. I assume you have "additional include files" defined in project properties (dirs. VectorsAndMatrices, DataStructures, Geometry, ExcelDriver, PropertySet, Chapter12)



5. Th CD has ready-to-run projects where all is defined. Make directory C:\cpp2006



Let me know how you get on. hth
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Postby Cuchulainn » Mon Apr 05, 2010 11:13 am

Well, strange,fdmdirector.cpp is on the official CD... Did you look in chapter 10 directory?



The error message means that the namespace is defined twice. Maybe it was my addition to the test program, so just remove it once. It means the same code is being inserted twice (chapter 2)



BTW, as a check how many files in total do you have on the CD?
User avatar
Cuchulainn
 
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby steve » Tue Apr 06, 2010 9:35 am

Well, it works fine now, thank for your support.



Could you update Excel feature for VC 2008 as well? I am looking forward to checking out that feature.



Once again, thanks for your great support.



Cuchulainn wrote:Well, strange,fdmdirector.cpp is on the official CD... Did you look in chapter 10 directory?



The error message means that the namespace is defined twice. Maybe it was my addition to the test program, so just remove it once. It means the same code is being inserted twice (chapter 2)



BTW, as a check how many files in total do you have on the CD?
steve
 
Posts: 8
Joined: Tue Mar 30, 2010 5:39 am

Next

Return to Introduction to C++ for Financial Engineers (Duffy)

Who is online

Users browsing this forum: No registered users and 3 guests

cron