用户工具

站点工具


jaysnote:linux_c_app_development

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

jaysnote:linux_c_app_development [2018/12/27 12:12]
jaylee
jaysnote:linux_c_app_development [2021/06/22 23:14]
行 1: 行 1:
-<markdown> 
  
- 
- 
-# 使用VS2017 开发Linux C应用 
- 
-* [Visual C++ for Linux Development](https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/) 
- 
-* 依赖环境 
- 
-  ```bash 
-  sudo apt-get install zip openssh-server g++ gdb gdbserver 
-  ``` 
-* 配置sshd 支持root账户登录 
- 
-  ```bash 
-  vi /etc/ssh/sshd_config  
-  permitRootLogin yes 
-  ``` 
- 
-* 重定向uname,默认不支持aarch64 
- 
-  ``` 
-  echo "echo ARM" > /bin/uname #暂时不支持arrch64,需要重定向uname 
-  ```    
- 
-### include 
- 
-在工程添加了路径添加了.h 文件,尽管在include 时候VS2017已经能够自动补全,但是编译的时候还是提示找不到.h文件。 
- 
-在编译机器发现对应的.h 并没有直接拷贝过来。 
- 
-原来同以前的直接include 搜索不一样,.h 同样需要加入工程里面,不然VS不知道拷贝那些文件。 
- 
-**13:46 2018/6/29** 
- 
-对于系统/usr/include 路径下*.h 文件,VS2017 不知道是什么时候拷贝到到Windows的,每次添加新机器后会报错。 
- 
-`C:\Users\Mdp-Jay\AppData\Local\Microsoft\Linux\Header Cache\1.0` 路径下文件夹为空。 
- 
-测试发现原来此过程发生在选项->跨平台->连接管理器->远程标头 IntelliSense 管理器,会自动打包Linux 编译机器上面的`/usr/include`然后到Windows 解压。 
- 
-![](http://www.leconiot.com/md_res//jaysnote/linux_c_app_development/images/inlude_header_download.png) 
- 
- 
- 
-### lib 
- 
-动态链接库 
- 
-属性页->链接->所有选项->库链接项 
- 
-![库依赖项](http://www.leconiot.com/md_res//jaysnote/linux_c_app_development/images/lib.png) 
- 
-``` 
-m 
-microhttpd 
-curl 
-pthread 
-rt 
-log4c 
-``` 
- 
-## TroubleShooting 
- 
-### Unexpected GDB output from command 
-``` 
-Unable to start debugging. Unexpected GDB output from command "-interpreter-exec console "target remote localhost:63442"". Remote connection closed 
-``` 
-![](http://www.leconiot.com/md_res//jaysnote/linux_c_app_development/images/debug_error.png) 
- 
-确定了Linux GDBServer版本 
- 
-``` 
-root@mxj-zbcs-310:/home/pi# gdbserver --version 
-GNU gdbserver (Debian 7.7.1+dfsg-5) 7.7.1 
-Copyright (C) 2014 Free Software Foundation, Inc. 
-gdbserver is free software, covered by the GNU General Public License. 
-This gdbserver was configured as "aarch64-linux-gnu" 
-``` 
- 
-大概明白了流程,暂时地,VS2017 还不支持`arm64`架构,通过ssh获取调试的架构的(`uname -m`)时候得到`aarch64`显示`Unkown`。VSlinux的[Issues](https://github.com/Microsoft/VSLinux/issues)详细讨论这个问题。同时微软承诺在15.8 prevew1版本会解决此问题,增加`ARM64`支持,同时增加选项是能到架构检测。 
- 
-https://github.com/Microsoft/VSLinux/issues/110 
- 
-https://github.com/Microsoft/VSLinux/issues/285 
- 
-``` 
-Ah I see, we made a fix for that, and are working on adding ARM64 support, in addition to a way of disabling the architecture check. 
-``` 
- 
-### Cannot insert breakpoint -1. 
- 
-``` 
-Warning: 
-Cannot insert breakpoint -1. 
-Cannot access memory at address 0x530 
-``` 
- 
-### Could not find the 'zip' archiver 
- 
-``` 
-生了错误。Could not find the 'zip' archiver, please install it using your system package manager.。请参阅 C:\Users\Mdp-Jay\AppData\Local\Temp\vslinux_header_update_log.txt 了解详细信 
-``` 
- 
-需要在调试设备上面安装zip(`sudo apt-get install zip`) 
- 
-###  Operation not permitted 
- 
-``` 
-&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n" 
-``` 
- 
-看起来在通过SSH 和GDServer不能直接操作设备。 
- 
-尝试更改root账户,还是不行,暂时看来,可以忽略改错误。 
- 
-### Microsoft.Build.Linux.Shared.ExceptionTTY 
- 
-![](http://www.leconiot.com/md_res//jaysnote/linux_c_app_development/images/debug_error2.png) 
-                                                                                                                
-https://github.com/Microsoft/VSLinux/issues/278 
- 
-最后确定和在`~/.bashrc` 启动中有未识别字符,和`echo -e`  的格式化字符串有关系,直接删除了`.bashrc`(删除前记得备份)。 
- 
-> **提示**:`vslinux_ttyexception_log.txt` 中有详细记录。 
- 
-### cannot open display 
- 
-调试 gtk 桌面引用提示不能代开显示。 
- 
-``` 
-Unable to init server: Could not connect: Connection refused 
- 
-(factory_test.out:7951): Gtk-WARNING **: cannot open display:  
-``` 
- 
-所有的x 桌面应用都一致需要指定显示的`x server`。 
- 
-``` 
-export DISPLAY=:0 
-``` 
- 
-同时,`x server` 限制连接账号。所以如果要通过`root`调试,会麻烦一些。 
- 
-``` 
-export DISPLAY=:0 
-xhost +                          #第二次运行可能会阻塞 
-cp /home/pi/.Xauthority /root/   #每次重启后该文件需要重新拷贝。 
-``` 
- 
- 
-</markdown> 
jaysnote/linux_c_app_development.txt · 最后更改: 2021/06/22 23:14 (外部编辑)