我正在寻找 cl 命令 /FC 的 clang 等效项。我的构建工具需要完整路径来解析并打开有错误的代码文件。
您需要在命令行上指定文件的完全限定路径或相对路径,而不是仅传递文件名。在下面的示例中,调试器将不知道在哪里可以找到“blah.cc”,因为我仅通过指定文件名进行编译:
~ pwd
/mnt/scratch/myproject/src
~ clang++ blah.cc -c -o /mnt/scratch/myproject/build/blah.o
~ cd ../build
~ clang++ *.o -o myprogram
Run Code Online (Sandbox Code Playgroud)
...但是,如果我这样做:
~ pwd
/mnt/scratch/myproject
~ clang++ /mnt/scratch/myproject/src/blah.cc -c -o /mnt/scratch/myproject/build/blah.o
# or:
~ clang++ src/blah.cc -c -o build/blah.o
# ...
Run Code Online (Sandbox Code Playgroud)
...然后它将完全限定或相对路径嵌入到调试部分中。
如果您使用部分限定路径,则必须告诉 GDB 在哪里查找代码。您可以在此处查看它的文档,尽管两个 gdb 命令可能会有所帮助:
# This will cause gdb to look in "path2" instead of "path1"
(gdb) set substitute-path path1 path2
# This allows you to give a list of directories to search for your source.
# note that if you give relative paths on the command-line, it'll concatenate
# these paths and the relative path used at compile-time.
(gdb) set directories path [path ...]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2208 次 |
| 最近记录: |