私はMakefileには新しく、cppプロジェクトを作成しようとしています。 "hello world"プログラム(main.cppファイルのみ)があります。 私はメイクをコンパイルしようとしたときに、このエラーを取得して停止することはできません。make error: "g ++:エラー:main.o:そのようなファイルやディレクトリがありません"
g++ -std=c++0x -g -Wall -o sub_game main.o
g++: error: main.o: No such file or directory
g++: fatal error: no input files
compilation terminated.
Makefile:38: recipe for target 'sub_game' failed
make: *** [sub_game] Error 4
私は、私が間違っているのかを理解していないあなたの助けをいただければ幸いです。
これはMakefileのである:
# the compiler: gcc for C program, define as g++ for C++
CC = g++
# compiler flags:
# -g adds debugging information to the executable file
# -Wall turns on most, but not all, compiler warnings
CXXLAGS = -std=c++0x -g -Wall
# the build target executable:
TARGET = sub_game
# define any libraries to link into executable:
LIBS = -lpthread -lgtest
# define the C source files
SRCS = ../src
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .cc of all words in the macro SRCS
# with the .o suffix
#
#OBJ = $(SRCS)/main.cc
OBJ = main.o
# define any directories containing header files other than /usr/include
#
INCLUDES = -I../include
all : $(TARGET)
$(TARGET) : $(OBJ)
$(CC) $(CXXLAGS) -o $(TARGET) $(OBJ)
main.o : $(SRCS)/main.cpp
.PHONY : clean
clean :
rm $(TARGET) $(OBJ)
は、高度にありがとうございます。
それはそうです大丈夫です。コンパイルのコマンドを書くようにしてください。 – EFenix
私はこのルールを追加して作業しています: g ++ -c $(SRCS)/main.cpp これは私が追加する必要がありますか? – dorash
私はそれが今動作すると思います...ところで、CXXFLAGS(CXXLAGSではなく)を使用してください – EFenix