跳至主要内容

如何在mac、windows下开发linux环境下的程序


1.vim

直接在linux环境编写,硬核流派,上手难度高,看不了调用关系?也没用自动补全提示?

2.copy&paste

在本地用各种工具编辑好,复制到linux,缺点是太麻烦,而且版本不好控制

3.samba

通过samba映射linux文件夹到本地,然后编辑,缺点是速度慢,工程里带上boost就爆炸了

4.vscode

vscode速度快,可以直接在samba的目录编辑,缺点是也看不了调用关系,自动补全基本没有,属于半自动化

5.clion

全家桶成员,属于全自动化,有补全,缺点是不能直接在samba目录打开,网速原因,太慢
所以只需要解决代码同步问题即可,在本地编辑,同步到开发机,在开发机编译调试

我的方案

1.准备clion

  • 在本地clone全部代码,包括依赖库。比如boost、protobuf等,放到一个目录,比如project
  • 然后用clion打开,选择New CMake Project From Souce,打开代码目录,会自动生成CMakeList.txt
  • 这时候clion会开始解析,等待它完成
  • 注意到有些头文件或者符号解析不了,那么应该是自动生成的CMakeList.txt的include路径有问题,修改重新加载
  • 反复操作,最后在本地可以完全使用clion的功能,比如跳转、查引用等

2.准备ftp

  1. 下载proftpd服务工具
  2. 解压后进入proftpd目录,运行 sh init.sh 脚本,输入登陆FTP的密码(用户名为当前登陆的用户名,不能使用root用户)
  3. 确认默认的8021端口是否被占用,如果占用,修改 etc/proftpd.conf配置里的端口号
  4. 启动 proftpd:进入proftpd目录,运行 sh start.sh 脚本
  5. 验证 FTP 是否 OK:通过浏览器输入 FTP 地址,输入账号密码测试是否 OK(FTP地址:ftp://ip地址:端口号)

3.clion配置

  1. clion工具栏选择Tools->Deployment->Configuration,点击+号新增一个Server,名字任意,类型为FTP
  2. 填开发机的ip地址、上述步骤开启的端口、用户名、密码
  3. Mappings下修改本地路径以及服务器上对应的路径
  4. 打开自动上传
    Tool——Deployment——Automatic Upload

4.测试

    在clion打开个文件,修改下,会看到输出

测试没问题,那么可以在菜单里选择upload to my,就是把所有的上传服务器

评论

此博客中的热门博文

ubuntu 添加root登录

Login to your server as root. As the root user, edit the sshd_config file found in  /etc/ssh/sshd_config : vim /etc/ssh/sshd_config ( For details on working with Vim check out our article here !) Add the following line to the file, you can add it anywhere but it’s good practice to find the block about authentication and add it there. PermitRootLogin yes Save and exit the file. Restart the SSH server: systemctl restart sshd or service sshd restart