GENERAL Tips for "C++ Programming for Financial Engineering" course

Andy Nguyen

Member
This is installation/setup notes for students taking the "C++ Programming for Financial Engineering" online course.

Setting up Visual Studio Compiler (version 2010)
  • Compiler settings: in the video lectures, Dr. Daniel Duffy has his compiler set up using "Expert Settings" (under Tools->Menu). This results in two new options under Debug menu: Build Menu and Start without Debugging. The default settings may not have these options.
Working with Visual Studio
  • To build: F7
  • To run the program: Ctrl-F5 (Windows)
  • To create and build multiple projects under a single solution:
    • Right-click on the Solution branch level in your Solution Explorer panel
    • Choose "Add-New Project" . This can be repeated as many times as necessary
    • To rebuild the whole solution with all projects under it in one click: Right-click on the solution branch again and choose "Rebuild solution" (key shortcut Ctrl+Alt+F7)
  • Showing/hiding line numbers in your source code:
    • From your menu tab Tools -> Options .
    • Expand: Text Editor -> C/C++ -> General
    • Check/Un-check check box "Line numbers"
Submit your assignments
  • In Visual Studio, compile and run the project. When confirmed that the code is working as expected and ready to be submitted to the TA, remove the Debug and Releases folders. Then zip the whole project folder into a zip file. If your project is named Homework_1.3, then you will submit Homework_1.3.zip file to the TA.
Resources/Tips that are relevant to the material and exercises
Install Boost on Mac OS
Install macports from: http://www.macports.org/install.php Here, install from the link appropriate for your machine (Leopard/Snow Leopard/Lion), then use the command sudo port install boost on terminal to install boost. Then on xcode, (i'm using xcode 4 on Mountain lion) go to Project->info->build settings->User Header Search Paths-> here I used the path of where my boost folder was (e.g. in my case, I copied the whole folder on desktop and I used the path: /Users/maneet/Desktop/opt/local/ include/ ) but did not include 'boost' after that since its already used in all the files (because if you use .../include/boost, the compiler is going to look for boost/boost and will give errors). Don't forget to switch 'Always Search User Paths' on at last.

If Boost on Visual Studio does not work:
Remove the extra path to the boost files (if you put any previously) from VC++ directories (include directories and library directories) and leave it as is. The only place where you enter the path to the boost files is under C/C++ general:additional include directories, and Linker: general: additional library directories (for lib). And it all compiles and works perfectly.

If IntelliSense on Visual Studio does not work:
1. Go to Tools -> Options -> Text Editor -> C/C++ -> General and make sure “Auto list members” and “Parameter information” are checked.
2. Check option “Disable IntelliSense” is not set to True in Tools -> Options -> Text Editor -> C/C++ -> Advanced.
3. Reinstall “Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop” from: http://www.microsoft.com/en-us/download/details.aspx?id=5783
Requires Windows 7, Vista, XP SP3 or other Windows OS. See system requirements from link for a complete list.

Level 9 Excel doesn't work with MS Office 2010?
This could happen if you haven't installed any OLDER versions of MS Office on your system.
  1. In the "ExcelImport.hpp" file, uncomment the last part
    Code:
    #import "C:\Program Files\Common Files\Microsoft Shared\office12\mso.dll" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
    #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
    #import "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") rename("DocumentProperties", "DocumentPropertiesXL") rename("ReplaceText", "ReplaceTextXL") rename("CopyFile", "CopyFileXL") no_dual_interfaces
    , and comment out all the previous parts.
  2. Change the "office12" (in the 1st and 3rd "#import" sentence) into "office14"
  3. Create the following directory:
    Code:
    C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\
    and save the attached documents into this directory. (don't forget to change the extension into ".olb" -- delete the ".txt")
  4. In addition to the above, if you have 64bit version of Windows 7 you will need to change C:\Program Files\... to C:\Program Files (x86)\... for all the import lines
  5. Rebuild the project, it should work fine with MS Office 2010 now.
[/LIST]

Batch file for deleting unnecessary files and folders from exercises
I have written some batch commands for deleting unnecessary folders and files created when building the homework projects in the course. Hope you find it useful. The created batch file should reside in the folder where each sections folder is kept. It will delete the Debug and ipch folders and also delete the sdf file in the exercise folders. You can add the release folder too after the "debug ipch" command in the code below.

@Echo OFF
REM Deleting debug and ipch folders
REM Deleting sdf file from each exercise folder in each section
cls
for /f %%i in ('dir /s/b debug ipch') do rmdir /s/q %%i
for /f %%i in ('dir /s/b *.sdf') do del /s/q %%i

Methods to refer to additional include directories required for exercises
You may be getting errors like cannot open the include file 'UtilitiesDJD/Vecto......." etc?

I kept the UtilitiesDjd folder in one place and in the properties section under C/C++ -> General -> Additional Include Directories I added the path where the UtilitiesDJD folder resides. Mine looks like this

D:\C++\Quantnet\Level9_Material\Level9Code;%(AdditionalIncludeDirectories)

where the UtilitiesDJD folder is placed in the Level9Code folder.

Another suggstion would be to place the full UtilitiesDJD folder in the folder C:\Program Files\Microsoft Visual Studio 10.0\VC\include . That way you can refer to the utilities there in any program without any worries of copying or changes to project settings. Everything should compile fine the way it is with either of the two suggestions.

Setting up global property sheets for Visual Studio 2010
You may want to set some global directories for the exercises especially when it comes to the boost exercises. The best way to do this is via the property pages in VS 2010. To do this please see the following steps.
  • Open up property manager by clicking on View.Property Manager.
  • Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp.<Platform>.users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.
  • Multi-Select "Microsoft.cpp.<Platform>.users", right click and bring up the property page window
  • In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons. Here add the boost folder.
  • Make sure to save the settings before shutting down Visual Studio.
  • Re-launch Visual Studio and the new settings will be in effect.
Refer to the following link otherwise
http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/a494abb8-3561-4ebe-9eb0-6f644a679862

Boost and Quantlib in Visual Studio 2012
Instruction on how to get Quantlib andBoost working in VC++ 2012
 

Attachments

Daniel Duffy

C++ author, trainer
Are you installing as administrator? Try to avoid SQL stuff in this course.
You can use Control Panel to remove SQL.
 

APalley

Well-Known Member
This chain seems to be a duplicate. Per the other chain -- are you having issues with intellisense? If so, I'd just ignore it. Better to focus on actual compile issues, especially in the beginning.
 

Shuwei Li

Member
C++ Student
Hi,
I just wonder whether it is okay to use another version visual studio 2015 for this class? Cause I have another class using it and it's impossible to download different versions. Also I'm confused if the same code will compile and work as expected on different versions.
Thanks for your time.

@APalley
 

APalley

Well-Known Member
Hi,
I just wonder whether it is okay to use another version visual studio 2015 for this class? Cause I have another class using it and it's impossible to download different versions. Also I'm confused if the same code will compile and work as expected on different versions.
Thanks for your time.

@APalley
Any version including and after 2010 is fine for this course.
 

zhouyourong

Member
C++ Student
Hi, I fixed my computer recently, so I have to reinstall the VS2012, but I can't find the product key, I can only use it for 30 days now. Is there any way I can get the product key again?
What can I do?
 

APalley

Well-Known Member
Hi, I fixed my computer recently, so I have to reinstall the VS2012, but I can't find the product key, I can only use it for 30 days now. Is there any way I can get the product key again?
What can I do?
You can get the totally free community edition of 2015
 

Lingqian Liang

Member
C++ Student
Hi, I fixed my computer recently, so I have to reinstall the VS2012, but I can't find the product key, I can only use it for 30 days now. Is there any way I can get the product key again?
What can I do?
you don`t need to reinstall VS. I met this problem before. I followed the instructions VS provided and sign up in the VS community. Then I get a code which helps me to continue to use VS.
 

Skander

Active Member
C++ Student
Level 9 Excel doesn't work with MS Office 2010?
This could happen if you haven't installed any OLDER versions of MS Office on your system.
  1. In the "ExcelImport.hpp" file, uncomment the last part
    , and comment out all the previous parts.
  2. Change the "office12" (in the 1st and 3rd "#import" sentence) into "office14"
  3. Create the following directory:
Hi there! Avi, I hope you are well:)
The directories above do not exist in my pc! can you help Please!
I have excel2010
but in my system I found a directory 20104 and 2016 but not 2010
C:\Program files\Common Files\microsoft shared\ OFFICE14 or OFFICE16 None of them has mso.dll ;\
@APalley
 

APalley

Well-Known Member
Hi there! Avi, I hope you are well:)
The directories above do not exist in my pc! can you help Please!
I have excel2010
but in my system I found a directory 20104 and 2016 but not 2010
C:\Program files\Common Files\microsoft shared\ OFFICE14 or OFFICE16 None of them has mso.dll ;\
@APalley
Every installation of MS Office will have these files somewhere; you need to locate them on your PC.
 

Skander

Active Member
C++ Student
I found the paths added them but they still in red
#import "C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\MSO.DLL" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
why it does not recognize it?
 

Skander

Active Member
C++ Student
Only one thing
Excel::RangePtr item = pRange->Item[sheetRow][sheetColumn];

The pRange pointer is underlined in red
The program compiles but when I point my cursor on pRange it says:
Error:expression must be a pointer to complete object type
any ideas?
lastly, is the output just a graph?
thank you
 

APalley

Well-Known Member
Only one thing
Excel::RangePtr item = pRange->Item[sheetRow][sheetColumn];

The pRange pointer is underlined in red
The program compiles but when I point my cursor on pRange it says:
Error:expression must be a pointer to complete object type
any ideas?
lastly, is the output just a graph?
thank you
If it compiles then you're fine
 

Daniel Duffy

C++ author, trainer
Hi there! Avi, I hope you are well:)
The directories above do not exist in my pc! can you help Please!
I have excel2010
but in my system I found a directory 20104 and 2016 but not 2010
C:\Program files\Common Files\microsoft shared\ OFFICE14 or OFFICE16 None of them has mso.dll ;\
@APalley
don't know why this as the correct directories are on the forum

Code:
#import "C:\Program Files (x86)\Common Files\Microsoft Shared\office14\mso.dll" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RGBXL")
#import "C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
#import "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" rename("DialogBox", "DialogBoxXL") rename("RGB", "RGBXL") rename("DocumentProperties", "DocumentPropertiesXL") rename("ReplaceText", "ReplaceTextXL") rename("CopyFile", "CopyFileXL") no_dual_interfaces
 
Top