在运行时使用makefile复制文件 [英] Copy a file using a makefile at runtime

查看:4905
本文介绍了在运行时使用makefile复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在Windows上使用批处理脚本来编译我的程序,但我最近发现了更有效率的makefile。

在我的 .bat 文件中,将一些dll文件复制到当前目录在运行时,它工作完美。

  copy C:\lib\glfw\glfw.dll 

我在我的makefile中尝试了同一行,甚至尝试了替换 cp ,但我的终端打印这个错误,即使 文件位于我指定的位置

  process_begin:CreateProcess(NULL,copy C:\ lib \glfw\glfw.dll,...)failed 
make(e = 2):系统找不到指定的文件。
make:*** [core.exe]错误2

我正在使用。注意你,缺少复制行它的工作原理就像一个魅力..我做错了或是可能的?

  EXEC = core.exe 
OBJS = src / obp.o

CC = g ++

CFLAGS = -W -Wall
LIBS = -lSOIL -lglew32 - lglfw -lopengl32
LDFLAGS =

$(OBE)$(OBJS)
$(CC)$(LDFLAGS)-o $ @ $(OBJS)$(LIBS)
copy C:\ lib \glfw\glfw.dll

clean:
rm -f $(EXEC)$(OBJS)*〜


解决方案

看起来你是从 MSYS ((或 MinGW )环境)。您可以使用

  cp C:\lib \glfw\glfw.dll。 

如果你想避免* nix像 cp ,那么您可以使用 xcopy 如下:

  xcopy / /YC:\lib\glfw\glfw.dll 

请注意双重<$ c $需要转义 /



才能使用c> // 在正常的 MS-DOS 环境中运行这种情况,在这种情况下,您的 clean 目标将无法工作,因为 rm 将不会被找到,您应该使用 del



当前设置,将不会找到任何内置的 DOS 命令。请参见选择外壳以了解如何 make 决定使用哪个shell。


I used to compile my programs with batch scripts on windows but I recently discovered makefiles which are much more efficient.

I had this line in my .bat file that copied some dlls to the current directory at runtime and it worked perfectly.

copy C:\lib\glfw\glfw.dll 

I tried the same line in my makefile and even tried the alternative cp but my terminal prints this error even tho the file is IN the location I specified

process_begin: CreateProcess(NULL, copy C:\lib\glfw\glfw.dll, ...) failed
make (e=2): The system cannot find the file specified.
make: *** [core.exe] Error 2

Here is the full makefile that I am using. Mind you, absent the copy line it works like a charm.. what am I doing wrong or is this possible?

EXEC = core.exe
OBJS = src/obp.o

CC = g++

CFLAGS  = -W -Wall
LIBS    = -lSOIL -lglew32 -lglfw -lopengl32
LDFLAGS =

$(EXEC): $(OBJS)
    $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
    copy C:\lib\glfw\glfw.dll

clean:
    rm -f $(EXEC) $(OBJS) *~

解决方案

It looks like you are running this from an MSYS (or MinGW) environment, which does not know about copy. Instead, you can use

cp C:\lib\glfw\glfw.dll .

If you want to avoid the *nix like cp, then you could use xcopy as follows:

xcopy //Y C:\lib\glfw\glfw.dll

Note the double // which is required to escape the /.

Or you could run this in a regular MS-DOS environment, in which case your clean target will not work because rm will not be found and you should use del.

With your current setup, any built-in DOS command will not be found. See Choosing the shell to read about how make determines which shell to use.

这篇关于在运行时使用makefile复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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