2

I am trying to move to VSCode from sublime text and I was wondering how to configure VSCode to work properly with SCIP.

my c_cpp_properties.json file looks like this:

    {
        "configurations": [
            {
                "name": "Mac",
                "includePath": [
                    "${workspaceFolder}/**",
                    "/Library/scip7/scip/",
                    "/Library/scip7/scip/src"
                ],
                "defines": [],
                "macFrameworkPath": [],
                "compilerPath": "/usr/local/bin/gcc-9",
                "cStandard": "c11",
                "cppStandard": "gnu++14",
                "intelliSenseMode": "clang-x64"
            }
        ],
        "version": 4
    }

I am able to get code completion working but I have having these errors in the Problems tab of the VScode terminal

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/morpheus/main.cpp)

cannot open source file "scip/config.h" (dependency of "/Users/morpheus/main.cpp")

This doesn't severely affect the development but I would like to know if there is a simple fix.

Morpheus
  • 3,285
  • 4
  • 27
  • 57

2 Answers2

2

As far as I know (and I'm not a VScode pro), the include path is not recursive if you don't use **. This looks like scip is not in your workspaceFolder is that correct? You could try to use "/Library/scip7/scip/src/**" and see if that fixes your issue?

Edit: Ok last hope: I just post my own configuration that works for me. Note that my $workspaceFolder here is the scip source directory.

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}",
                "${workspaceFolder}/src",
                "${workspaceFolder}/src/scip",
                "${workspaceFolder}/src/lpi"
            ],
            "defines": [
                "SOPLEX_WITH_GMP",
                "SCIP_WITH_GMP",
                "SCIP_WITH_ZIMPL"
            ],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "${workspaceFolder}/src"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++11"
        }
    ],
    "version": 4
}
Leon
  • 1,588
  • 1
  • 7
  • 16
  • Thanks for your SCIP is not in my workspace folder and unfortunately it did not work. The error still persists. Do you think it help if I put SCIP in my workspace folder? – Morpheus Jun 29 '20 at 19:32
  • Ok two followup things: 1) try putting `"/Library/scip7/scip/src/scip` in your include path (this is where config.h resides). 2) did you actually compile scip? because `config.h` only exists if scip has been built (it gets created automatically from `config.h.in` – Leon Jun 30 '20 at 06:32
  • I tried the above and it did not work. I did compile SCIP using make at the beginning. I probably did not mention this, my code runs fine from command line. Only VSCode has the problems. – Morpheus Jul 01 '20 at 06:00
  • I updated my original post with my own configuration that works for me, I hope it helps – Leon Jul 01 '20 at 09:23
  • 1
    I looked back one more time (not sure if your problem was actually fixed). If you compile scip with make then `NO_CONFIG_HEADER` is set as a compile flag. You can make vscode aware of this by adding "NO_CONFIG_HEADER", in your c_cpp_properties.json defines – Leon Jul 03 '20 at 08:25
  • Hey Leon. I kind of gave up. Thanks for your immense help. I did install using `make` and tried the `NO_CONFIG_HEADER` and it worked. Thanks a lot! – Morpheus Jul 03 '20 at 19:21
  • Glad I could help! – Leon Jul 05 '20 at 19:16
1

The comment section in the accepted answer suggests to define NO_CONFIG_HEADER. That no longer works as of about SCIP 8.0.1.

The exception is caused because src/scip/def.h tries to import config.h and scip_export.h. These do not exist under the src/ directory, but are generated when make is called in opt/static/O.linux.x86_64.gnu.opt and opt/static/O.linux.x86_64.gnu.dbg (assuming x86_64). The solution is to add opt/static/O.linux.x86_64.gnu.dbg/include to the includePath.

Below follows my .vscode/c_cpp_properties.json file:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/src/**",
                "${workspaceFolder}/obj/static/O.linux.x86_64.gnu.dbg/include"
            ],
            "browse": {
                "path": [
                    "${workspaceFolder}/src/**"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "${default}",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}
Jasper
  • 155
  • 1
  • 8