0

It has taken me a while but managed to install QuantLib on the Mac M1 chip, however I am running into bother with vscode & g++ not being able to locate the quantlib header files.

I feel like I have tried everything and I am not sure what to do next. Any help would be appreciated!

I have a feeling its something to do with the silicon chip.

What I have tried is adding to the include path c_cpp_properties.json "/opt/homebrew/Cellar/quantlib/1.28/include" & "/opt/homebrew/Cellar/boost/1.80.0/include".

I have also added to the ".zshrc" file some exports such as:

export CPLUS_INCLUDE_PATH=/opt/homebrew/include
export C_INCLUDE_PATH=/opt/homebrew/include
export CPATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib

Just to add the error message is:

test.cpp:3:10: fatal error: 'ql/quantlib.hpp' file not found

My c_cpp_properties.json file contains:

{
"configurations": [
    {
        "name": "Mac",
        "includePath": [
            "${workspaceFolder}",
            "/opt/homebrew/Cellar/quantlib/1.28/include",
            "/opt/homebrew/Cellar/boost/1.80.0/include"
        ],
        "defines": [],
        "macFrameworkPath": [
            "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
        ],
        "compilerPath": "/usr/bin/clang",
        "cStandard": "c17",
        "cppStandard": "c++17",
        "intelliSenseMode": "macos-clang-arm64"
    }
],
"version": 4

}

drescherjm
  • 10,365
  • 5
  • 44
  • 64
ceejam
  • 21
  • 3
  • What is the structure of your project? What build system/compiler/IDE do you use? – X99 Nov 17 '22 at 13:46
  • I am just trying to get quantlib working first, but to answer your question: build system is macOS Monetrey with M1 Chip, compiler is just manual atm I have been using g++ command, and my IDE is just VSCode. Let me know if i have missed something. Also I used brew install quantlib. – ceejam Nov 17 '22 at 13:51
  • `c_cpp_properties.json` sets the include directories for the Intellisense feature but has nothing to do with compiling. You need to edit your tasks.json if you are not using some build extension like MakefileTools or CMakeTools. – drescherjm Nov 17 '22 at 13:59
  • But would it not include the headers included in the compilation? – ceejam Nov 17 '22 at 14:00
  • ***But would it not include the headers included in the compilation?*** No it does not do that. You probably need to set the paths a second time in tasks.json – drescherjm Nov 17 '22 at 14:00
  • This official tutorial explains the 3 json files used in the default mode without a special build extension: [https://code.visualstudio.com/docs/cpp/config-clang-mac](https://code.visualstudio.com/docs/cpp/config-clang-mac) – drescherjm Nov 17 '22 at 14:02
  • This answer explains the behavior: [https://stackoverflow.com/a/68772283/487892](https://stackoverflow.com/a/68772283/487892) – drescherjm Nov 17 '22 at 14:06

1 Answers1

0

I figured it out!

As you guys said i was not actually including the path of the header files required in the manual compilation. So that is what I did:

The compilation command for Mac M1 if you have used homebrew to install QuantLib in this instance:

g++ -I/opt/homebrew/Cellar/quantlib/1.28/include/ \
-I/opt/homebrew/Cellar/boost/1.80.0/include test.cpp \
-o test -L/opt/homebrew/lib/ -IQuantLib -std=c++14

I was originally using -std=c++11 however I generated lots of errors so switched to -std=c++14 and the compilation worked in my test case.

Let me know if there is anything else I should be aware of!

Thanks.

ceejam
  • 21
  • 3