C++ ';openssl/crypto.h';在vscode上找不到文件

C++ ';openssl/crypto.h';在vscode上找不到文件,c++,visual-studio-code,C++,Visual Studio Code,尽管我将include路径添加到openssl,但还是出现了以下编译错误。我在MAC上使用vscode。你能告诉我怎么修吗 错误 main.cpp:3:10: fatal error: 'openssl/crypto.h' file not found #include <openssl/crypto.h> ^ 1 error generated. .vscode/c_cpp_properties.json { "version": "0.1.0",

尽管我将include路径添加到openssl,但还是出现了以下编译错误。我在MAC上使用vscode。你能告诉我怎么修吗

错误

main.cpp:3:10: fatal error: 'openssl/crypto.h' file not found
#include <openssl/crypto.h>
         ^
1 error generated.
.vscode/c_cpp_properties.json

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "args": ["-std=c++14", "-O2", "-l", "boost_system", "-l", "boost_thread", "-o", "test", "-g",
        "main.cpp"
    ],
    "showOutput": "always"
}
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "/usr/local/opt/openssl/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "/usr/local/opt/openssl/include"
                ]
            }
        }
    ]
}
$ which openssl
/usr/bin/openssl

$ ls  /usr/local/opt/openssl/include/openssl | grep crypto.h
crypto.h
.vscode/c_cpp_properties.json

{
    "version": "0.1.0",
    "command": "g++",
    "isShellCommand": true,
    "args": ["-std=c++14", "-O2", "-l", "boost_system", "-l", "boost_thread", "-o", "test", "-g",
        "main.cpp"
    ],
    "showOutput": "always"
}
{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "/usr/local/opt/openssl/include"
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": "",
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "/usr/local/opt/openssl/include"
                ]
            }
        }
    ]
}
$ which openssl
/usr/bin/openssl

$ ls  /usr/local/opt/openssl/include/openssl | grep crypto.h
crypto.h

更新1

我发现了类似的问题,但仍然没有为我找到解决方案


更新2

我尝试使用g++进行编译,但效果不太好。我的mac是OS X El Capitan版本10.11.6

$ g++ main.cpp -L/usr/local/opt/openssl/lib -lssl -lcrypto -o test
main.cpp:3:10: fatal error: 'openssl/crypto.h' file not found
#include <openssl/crypto.h>
         ^
1 error generated.
另一个解决方案: 在Mac上(但这也适用于其他OSs),我首先更新了openssl:

brew upgrade openssl
然后设置以下环境变量:

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
这是我通过简单的尝试得到的:

brew info openssl
我仍然需要更新tasks.json,但现在更改成功了(c的clang):