Visual Studio 2017 for Linux C ++:“无法找到或打开符号文件”

时间:2017-09-09 04:53:01

标签: c++ linux gcc visual-studio-2017

我使用VS Linux C ++开发支持来创建Linux C ++项目,然后在Virtualbox上连接Ubuntu远程调试。但控制台已经打印了一些错误消息。

如何让VS2017正确打印Linux C ++程序的输出?

环境

  • Windows 10 Pro x64
  • Microsoft Visual Studio Community 2017 15.3.3 - VS Linux C ++开发支持
  • Virtualbox 5.1.26
  • Ubuntu 16.04 LTS x64

步骤

  • Shift + Ctrl + N
  • 创建新的Linux项目
  • ConsoleApplication
  • 运行
  • 填写SSH用户名和密码(Ubuntu 16.04 Virtualbox)

的main.cpp

#include <cstdio>

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

控制台

=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)。

2 个答案:

答案 0 :(得分:2)

在我看来,你的程序运行正常。你打开过Visual Studio的Linux控制台吗?您发布的输出将写入“输出/调试”窗口,而不是控制台窗口。从“调试”菜单中打开Linux控制台。请注意,根据您正在执行的操作(如在文件中查找),它是具有不同位置和可见性设置的VS窗口之一,因此您可能必须在调试时重新打开它。

gdb可以在没有符号文件的情况下进行管理,因此您看到的消息不是错误。您将获得有关系统库内部内容的更少信息,如果您真的需要,请从Linux发行版安装调试包以获取libc等符号文件。

答案 1 :(得分:0)

这可能是权利问题。尝试从Visual Studio附加到正在运行的应用程序。我收到此错误:无法启动调试。使用GDB附加到过程4626失败,因为没有足够的权限和错误消息&#39; ptrace:操作不被允许。&#39;。

请参阅此处以解决ptrace错误: Qt Creator, ptrace: Operation not permitted. What is the permanent solution?