是否有任何方法可以运行命令并将其输出作为G++汇编标志?
我的目标是能够在WSL2中编译和运行简单的C ++程序。我想将WSL的G ++用作编译器。要编写程序,我正在使用崇高的文本用于Windows。 All my program are stored in Windows filesystem.
这是我针对C ++的崇高构建文件。
"shell_cmd": "wsl g++ -std=c++17 -fsanitize=address \"${file}\" -g -o \"${file_path}/${file_base_name}.o\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c++",
现在问题是当我尝试构建代码时,Sublime变量$ {file_path}
将我的源代码的Windows文件路径传递到wsl2中安装的g ++,而wsl2和g ++无法识别路径并产生错误(如预期)。
为了克服这个问题,我想使用称为wslpath
的程序,该程序将将Windows文件路径c:// some_folder
转换为WSL2类型/mnt/c/c/some_folder
。
现在,当我尝试在Sublime Build文件中使用WSLPATH
时,它会产生错误,而无需按预期工作。
我的最终崇高构建文件的shell_cmd
看起来像是
"shell_cmd": "wsl g++ -std=c++17 -fsanitize=address $wslpath | \"${file}\" -g -o \"${file_path}/${file_base_name}.o\"",
我在此过程中做错了什么,或者我可以做其他事情来实现目标?
My goal is to be able to compile and run simple C++ programs in WSL2. I want to use WSL's G++ as the compiler. To write the program I am using sublime text for Windows. All my program are stored in Windows filesystem.
This is my sublime build file for C++.
"shell_cmd": "wsl g++ -std=c++17 -fsanitize=address \"${file}\" -g -o \"${file_path}/${file_base_name}.o\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)quot;,
"working_dir": "${file_path}",
"selector": "source.c++",
Now the problem is when I try to build the code, the sublime variable ${file_path}
passes the Windows file path of my source code to g++ which is installed in WSL2 and g++ is unable to recognize the path and produces errors (as expected).
To overcome this problem I want to use the program called wslpath
which will convert the Windows file path C://some_folder
to WSL2 type /mnt/c/some_folder
.
Now when I try to use wslpath
in sublime build file, it produces error and doesnot works as expected.
My final sublime build file's shell_cmd
looks like this
"shell_cmd": "wsl g++ -std=c++17 -fsanitize=address $wslpath | \"${file}\" -g -o \"${file_path}/${file_base_name}.o\"",
What am I doing wrong in the process or is there something else I can do to achieve the goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论