致命错误:"ql/quantlib.hpp"未找到C++



我花了一段时间,但还是设法在Mac M1芯片上安装了QuantLib,但我遇到了vscode&g++无法定位quantlib头文件。

我觉得我什么都试过了,不知道下一步该怎么办。任何帮助都将不胜感激!

我觉得这和硅片有关。

我所尝试的是将c_cpp_properties.json添加到包含路径中/opt/homebrew/Cellar/quantlib/1.28/include"&quot/opt/homebrew/Cellar/boost/1.80.0/include";。

我还添加了";。zshrc";归档一些导出,例如:

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

只需添加错误消息:

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

我的c_cpp_properties.json文件包含:

{
"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

}

我想通了!

正如你们所说,我实际上并没有包括手动编译中所需的头文件的路径。我就是这么做的:

Mac M1的编译命令,如果你在这个例子中使用自制软件安装QuantLib:

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

我最初使用的是-std=c++11,但我产生了很多错误,所以切换到-std=c++14,在我的测试用例中编译成功了。

如果还有什么我应该知道的,请告诉我!

谢谢。

最新更新