g ++:没有这样的文件或目录? [英] g++: No such file or directory?

查看:212
本文介绍了g ++:没有这样的文件或目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(在Linux上,尝试设置SDL)我有时间使用makefile,我发现它们很难学习。这是我得到的错误。

  g ++:error:game.exe:没有这样的文件或目录
make:*** [game.exe ]错误1

这是我的makefile。 (任何关于改善效果的建议都会很棒,只要我可以找到工作,我都会一sla不振。)



<$ p $ #Game Make file
TARGET = game.exe
OBJS = App.o\
App_OnInit.o\
App_OnEvent.o\
App_OnLoop.o\
App_OnRender.o \
App_OnCleanup.o\

SDL_CFLAGS:= $(shell sdl-config --cflags)
SDL_LDFLAGS:= $(shell sdl-config --libs)
CFLAGS = -Wall -o
LIBS =
LDFLAGS =

$(目标): $(OBJS)
g ++ $(CFLAGS)$(SDL_CFLAGS)$ @ $(LDFLAGS)$(OBJS)$(SDL_LDFLAGS)$(LIBS)
%.o:src /%。cpp
g ++ -c $(SDL_CFLAGS)$< $(SDL_LDFLAGS)

.PHONY:clean
clean:
rm -f $(TARGET)$(OBJS)
pre

解决方案

您可以交换 $(CFLAGS) $(SDL_CFLAGS)来制作 $(TARGET)或更好地移除 -o code>从> CFLAGS ,并将其放在 $ @ 之前:

  ... 
CFLAGS = -Wall
...
$(TARGET):$(OBJS)
g ++ $(CFLAGS)$(SDL_CFLAGS)-o $ @ $(LDFLAGS)$(OBJS)$(SDL_LDFLAGS)$(LIBS)

-o 选项应该立即位于要生成的可执行文件的名称之前。在您的原始 Makefile 中,它是 $(CFLAGS)的一部分,后面跟着SDL库的C标志。因此,编译器会尝试链接 game.exe $ @ ),而不是通过该名称生成可执行文件。


(On Linux, trying to set up SDL) I'm having a time with makefiles, I'm finding them hard to learn. Here is the error I'm getting.

g++: error: game.exe: No such file or directory
make: *** [game.exe] Error 1

Here is my makefile. (Any suggestions on making it better would be great. I've just kind of slapped together whatever I could find to work.)

#Game Make file
TARGET = game.exe
OBJS = App.o\
   App_OnInit.o\
   App_OnEvent.o\
   App_OnLoop.o\
   App_OnRender.o \
   App_OnCleanup.o\

SDL_CFLAGS := $(shell sdl-config --cflags)
SDL_LDFLAGS := $(shell sdl-config --libs)
CFLAGS = -Wall -o
LIBS =
LDFLAGS = 

$(TARGET): $(OBJS)
       g++ $(CFLAGS) $(SDL_CFLAGS) $@  $(LDFLAGS) $(OBJS) $(SDL_LDFLAGS) $(LIBS)
%.o: src/%.cpp
       g++  -c $(SDL_CFLAGS) $< $(SDL_LDFLAGS)

.PHONY: clean
clean:
    rm -f $(TARGET) $(OBJS)

解决方案

You could either exchange $(CFLAGS) and $(SDL_CFLAGS) in the rule to make $(TARGET) or better remove -o from CFLAGS and put it directly before $@:

...
CFLAGS = -Wall
...
$(TARGET): $(OBJS)
       g++ $(CFLAGS) $(SDL_CFLAGS) -o $@  $(LDFLAGS) $(OBJS) $(SDL_LDFLAGS) $(LIBS)

-o option should immediately precede the name of the executable file to be produced. In your original Makefile it is part of $(CFLAGS) and is followed by the C flags of the SDL library. Therefore the compiler tries to link in game.exe (the $@) instead of producing an executable file by that name.

这篇关于g ++:没有这样的文件或目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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