-4

I have to run a c++ script in debug on Visual Studio Code, but I'm not able to do it. It says me that It is not able to find the file raise.c

Unable to open 'raise.c': Unable to read file (Error: File not found (/build/glibc-B9XfQf/glibc-2.28/sysdeps/unix/sysv/linux/raise.c)).

What is the problem?

Tanozar
  • 49
  • 1
  • 1
  • 4
  • 1
    What did you do? C++ is no scripting language so you don't run a file, but a compiled program. – Lukas-T Nov 08 '19 at 11:14
  • And then? How are main.cpp and raise.c connected? – Lukas-T Nov 08 '19 at 11:20
  • I have created a c++ file (main.cpp) and I have opened it in Visual Studio Code. After I compiled it with g++ , so in terminal I written g++ main.cpp -o main.out and I have executed it as ./main.out. But I have a problem in the code and I want to know where the problem is, so I want to debug the code with VS Code. I add a new configuration in launch.json with the name of my code and then launch the debug, but VS says me that he is not able to open raise.c – Tanozar Nov 08 '19 at 11:25
  • But _what is_ raise.c? Is it a part of your project? – Lukas-T Nov 08 '19 at 11:26
  • The file raise.c should be here : /build/glibc-B9XfQf/glibc-2.28/sysdeps/unix/sysv/linux/raise.c but I don't know what it actually is. Is a system file? or else? – Tanozar Nov 08 '19 at 11:29
  • Did you build glibc from source? – Thomas Sablik Nov 08 '19 at 11:53
  • I hope that I've understood your question, and I tried to follow this : https://stackoverflow.com/questions/48278881/gdb-complaining-about-missing-raise-c/48287761 but when I write "apt source libc6" in terminal it shows me "You must put some 'source' URIs in your sources.list". – Tanozar Nov 08 '19 at 12:06

1 Answers1

0

Good evening Tanozar,

the problems are probably due to: - task.json

    "tasks": [
        {
            "type": "shell",
            "label": "g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "`pkg-config", "--cflags", "--libs", "opencv4`",
                "-lcfitsio", "-lcurl",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-lboost_iostreams", "-lboost_system", "-lboost_filesystem", "-lpython2.7", "-lm", "-L/usr/lib/python2.7/config/", "-I/usr/include/python2.7/ ",
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]

this is an example of my task.json for a program that include opencv and python. Probably a first error is that the argument is not quoted. This task.json "correspond to" "g++ -Os -std=c++11 main2.cpp pkg-config --cflags --libs opencv4 -lcfitsio -lcurl -o ~/blabla/main2 -lboost_iostreams -lboost_system -lboost_filesystem -lpython2.7 -lm -L/usr/lib/python2.7/config/ -I/usr/include/python2.7/"

  • launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++ build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

you have to check this line "program": "${fileDirname}/${fileBasenameNoExtension}",

  • in the program code
int main(int argc, char* argv[]) 
{
    string folder = argv[1];
}

if you write in this way you get the error "Unable to open 'raise.c': Unable to read file (Error: File not found (/build/glibc-B9XfQf/glibc-2.28/sysdeps/unix/sysv/linux/raise.c))."

string folder = "/home/.../pathofyourprogram";

in this way the problem not occured.

I hope that is useful, but i don't know the detail of this problem sorry.

oOLorOo
  • 16
  • 1
  • 4