0

I used VS Linux C ++ development support to create a Linux C ++ project, and then connect Ubuntu remote debugging on Virtualbox. But the console has printed some error messages.

How to make VS2017 correctly print the output of Linux C ++ program?


Environment

  • Windows 10 Pro x64
  • Microsoft Visual Studio Community 2017 15.3.3 - VS Linux C ++ development support
  • Virtualbox 5.1.26
  • Ubuntu 16.04 LTS x64

Step

  • Shift + Ctrl + N
  • Create a new Linux project
  • ConsoleApplication
  • Run
  • Fill out SSH username and password (Ubuntu 16.04 Virtualbox)

main.cpp

#include <cstdio>

int main()
{
    printf("hello from ConsoleApplication1!\n");
    return 0;
}

Console

=thread-group-added,id="i1"
GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-mingw32 --target=x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
Stopped due to shared library event:
  Inferior loaded /lib/x86_64-linux-gnu/libc.so.6
    /lib64/ld-linux-x86-64.so.2
Loaded '/lib/x86_64-linux-gnu/libc.so.6'. Cannot find or open the symbol file.
Loaded '/lib64/ld-linux-x86-64.so.2'. Cannot find or open the symbol file.
[Inferior 1 (process 14481) exited normally]
程序“”已退出,返回值为 0 (0x0)。
hijkzzz
  • 13
  • 1
  • 5
  • There are some Chinese characters at the bottom, so you may want to make sure your encodings match. That said, please elaborate more on the minimal steps needed to reproduce the problem. Additionally, please give the IDE **version** in the question, *not* the marketing name. – tambre Sep 09 '17 at 04:57
  • Why are you using Visual Studio in Linux? – Sailanarmo Sep 09 '17 at 05:14
  • @Sailanarmo I'm pretty sure he's probably using [VS Linux C++ development support](https://blogs.msdn.microsoft.com/vcblog/2017/04/11/linux-development-with-c-in-visual-studio/). I doubt Wine could run VS. – tambre Sep 09 '17 at 06:26
  • Forgive me for not making it clear I am using VS Linux C ++ development support – hijkzzz Sep 10 '17 at 02:03

2 Answers2

2

It looks to me like your program ran ok. Have you opened Visual Studio's Linux console? The output you have posted is written to the Output / Debug window, not the console window. Open the Linux console from the Debug menu. Note that it is one of those VS windows that has different position and visibility settings depending on what you are doing (like Find in Files) so you might have to reopen it when you are debugging.

gdb can manage without symbols files so the messages you see are not an error. You'll get less information about what's going on inside the system libraries and, if you really want this, install the debug package from your Linux distro to get the symbols files for libc etc..

stanthomas
  • 1,141
  • 10
  • 9
  • Also be aware that you might encounter this problem https://github.com/Microsoft/VSLinux/issues/119 when debugging console applications. – stanthomas Sep 10 '17 at 13:47
  • @hijkzzz why this answer is marked as correct? How did you solve your problem? Did you check the output on Linux Console? I'm also getting the same problem with my setup and on the Linux Console it says - Listening on port 4444 Remote debugging from host 127.0.0.1 bind: Address already in use – warunanc Apr 19 '18 at 05:42
  • @warunanc - it doesn't sound like the same promlem at all, in fact it sounds like you are already using port 4444 for something else. I'd guess you're using WSL but if you want to post a full question I'll try to answer it for you. – stanthomas Apr 19 '18 at 20:25
0

It could be a rights problem. Try to attach to a running application from Visual Studio. I got this error: Unable to start debugging. Attaching to process 4626 with GDB failed because of insufficient privileges with error message 'ptrace: Operation not permitted.'.

See here for solving the ptrace error: Qt Creator, ptrace: Operation not permitted. What is the permanent solution?