如何通过修改命令行中给出的路径名来停止MinGW和MSYS [英] How to stop MinGW and MSYS from mangling path names given at the command line

查看:140
本文介绍了如何通过修改命令行中给出的路径名来停止MinGW和MSYS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上,我正在使用CodeSourcery的交叉编译器套件交叉编译ARM/Linux程序.我使用MinGW MSYS作为我的命令解释器,通常它会破坏我的路径和路径名.例如,要构建程序,我调用

On Windows, I'm cross-compiling a program for ARM/Linux using CodeSourcery's cross-compiler suite. I use MinGW MSYS as my command interpreter, and very often it will mangle my paths and pathnames. For example, to build my program, I invoke

arm-none-linux-gnueabi-gcc.exe -Wall -g \
    -Wl,--dynamic-linker=/usr/lib/myrpath/ld-linux.so.3 \
    -Wl,-rpath=/usr/lib/myrpath \
    -I../targetsysroot/usr/include \
    myprogram.c -o myprogram

当然,我希望/usr/lib/myrpath逐字插入myprogram可执行文件中-我要为其编译的ARM Linux目标不使用MinGW或MSYS.但是,最终的结果如下:

Of course, I want /usr/lib/myrpath inserted verbatim into the myprogram executable - the ARM Linux target I'm compiling for doesn't use MinGW or MSYS. But here's what ends up going into it:

...
0x0000000f (RPATH)            Library rpath: [C:/MinGW/msys/1.0/lib/myrpath]
...

不完全是我想要的.如果直接在cmd.exe命令行上调用GCC,则会在可执行文件中获得正确的rpath.如果我在MSYS命令行上调用GCC,则会得到错误的rpath.如果我使用从cmd.exe命令行使用make运行的Makefile调用GCC,我仍然会得到错误的rpath(!)

Not exactly what I wanted. If I invoke GCC on the cmd.exe command line directly, I get the right rpath in the executable. If I invoke GCC on the MSYS command line, I get the mangled rpath. If I invoke GCC with a Makefile that is run with make from the cmd.exe command line, I still get a mangled rpath (!)

有什么想法可以关闭这种烦人的行为吗?

Any ideas how I might turn off this annoying behavior?

推荐答案

我刚刚发现了一个巧妙的技巧,可以避免MSYS/MinGW为您转换路径.

I just discovered a neat trick to avoid MSYS/MinGW translating the paths for you.

如果使用双斜杠开始路径,则MSYS不会将路径转换为DOS格式.因此,在OP的示例中,-rpath开关应指定为:

If you use double-slash to start the path, then MSYS won't translate the path to DOS format. So in OP's example, the -rpath switch should be specified like this:

-Wl,-rpath=//usr/lib/myrpath

所有Unix/Linux工具似乎都能毫无问题地处理此类假斜线,因此即使您二进制文件的rpath将以//usr/...开头,我也认为加载程序会做正确的事.

All Unix/Linux tools seem to handle such spurious slashes without any problem, so even though your binary's rpath will start with //usr/... I think the loader will do the right thing.

这篇关于如何通过修改命令行中给出的路径名来停止MinGW和MSYS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆