Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the prelaunchtask c/c++: gcc build active file terminated with exit code -1 #11927

Closed
Yamo406 opened this issue Feb 4, 2024 · 16 comments
Closed
Assignees
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service more info needed The issue report is not actionable in its current state

Comments

@Yamo406
Copy link

Yamo406 commented Feb 4, 2024

Type: Bug

  1. Write code in a new file
  2. press on run file on the top right.
  3. Error: "the prelaunchtask c/c++: gcc build active file terminated with exit code -1"
  4. run the file.

Expected result: compile the file and run it.

Not sure if it has to do with the flags, but apparently on linux it doesn't work, I tried another extension which used these flags and it worked like a charm ["-g3", "-Wall", "-Wextra", "${file}", "-o", ""${fileDirname}/${fileBasenameNoExtension}""]

Here is an e.g. from the extension that worked "Executing task: g++ -Wall -Wextra -g3 /run/media/yamo/EDU/Extracurriculars/OSC/S&T/DS/wordOnThePaper.cpp -o /run/media/yamo/EDU/Extracurriculars/OSC/S&T/DS/output/wordOnThePaper
"
Extension name: C/C++ Compile Run

Extension version: 1.18.5
VS Code version: Code 1.86.0 (05047486b6df5eb8d44b2ecd70ea3bdf775fd937, 2024-01-31T10:27:46.147Z)
OS version: Linux x64 6.6.10-1-MANJARO
Modes:

System Info
Item Value
CPUs AMD Ryzen 5 4600H with Radeon Graphics (12 x 3984)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 4, 3, 3
Memory (System) 15.00GB (6.24GB free)
Process Argv --unity-launch --crash-reporter-id 7162d89c-d2bf-40c9-896e-a9a1c34f045e
Screen Reader no
VM 0%
DESKTOP_SESSION plasma
XDG_CURRENT_DESKTOP KDE
XDG_SESSION_DESKTOP KDE
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyonecf:30548226
0bi6i642:30951795
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
dsvsc019b:30953937
3ef8e399:30949928
e3gdj431:30956216

@browntarik
Copy link
Contributor

Could you please provide more information about how you are getting this error? It is likely that you have not correctly configured your task.json with the appropriate arguments.

Example:
image

@browntarik browntarik self-assigned this Feb 6, 2024
@browntarik browntarik added more info needed The issue report is not actionable in its current state Language Service Feature: Configuration An issue related to configuring the extension or IntelliSense labels Feb 6, 2024
@Yamo406
Copy link
Author

Yamo406 commented Feb 7, 2024

I haven't modified the tasks.json I let the extension do it automatically for me. here is a screenshot of the tasks.json
Screenshot_20240207_130246

I am not sure, maybe it has something to do with me using Linux or the path of the file is not detected.

@browntarik
Copy link
Contributor

Can you provide the output from the error window including the command that is generated by the run and debug command?

Example:
image

@Yamo406
Copy link
Author

Yamo406 commented Feb 11, 2024

@browntarik sorry for the late reply.
image

@browntarik
Copy link
Contributor

It looks like there is an issue because of the '&' character in your path. Could you try renaming your directory to remove it and try the executable again?

If you would like to keep the ampersand you may have to escape it in the file path, but it is generally not recommended practice to use special characters in file paths.

@Yamo406
Copy link
Author

Yamo406 commented Feb 12, 2024

@browntarik so it worked when I indeed changed the ampersand character, I have another question when I use the the GCC from the dropdown it doesn't work, that's on a different directory but the g++ works as intended, does that have to do with Linux?

Here are the errors:
Screenshot_20240212_211748
Screenshot_20240212_211801

@Yamo406
Copy link
Author

Yamo406 commented Feb 12, 2024

Here are as well the dropdown menu in case you need it:

Screenshot_20240212_212104

@browntarik
Copy link
Contributor

Based on the error you showed me (i.e undefined reference to std::cout) I would guess that you are trying to use the gcc compiler to build a c++ project, please try using the g++ compiler instead.

@Yamo406
Copy link
Author

Yamo406 commented Feb 12, 2024

The g++ compiler works just fine.
If I understand correctly the gcc is for c projects and g++ for c++ projects?

@browntarik
Copy link
Contributor

Yes, that is generally the case. You could use explicit linking if you have a specific reason to use gcc. To use explicit linking just add the -lstdc++ to your list of arguments though it is recommended you just use g++.

@Yamo406
Copy link
Author

Yamo406 commented Feb 12, 2024

Awesome thanks for taking the time to solve the problem and answer my questions.

@browntarik
Copy link
Contributor

I am glad I was able to help, I will now close this issue but it will be available for future reference.

@dheerajparashar
Copy link

Hello there, I am facing the same error but on my Windows laptop.
image

@dheerajparashar
Copy link

Could you please help?

@Yamo406
Copy link
Author

Yamo406 commented Mar 30, 2024

@dheerajparashar Hey there, it seems that in your case it's giving permission denied, I would have 2 solutions that I would try first.

  1. change the location of the project.
  2. change the permission of the folder.

The easiest is to change the project's location as it can be tedious to change the permission of the folder especially since it's in the C: folder and I haven't been having that much luck with permissions on Windows.

@dheerajparashar
Copy link

Thanks mate I will try this and let you know what happens.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature: Configuration An issue related to configuring the extension or IntelliSense Language Service more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

3 participants