c++ - Makefile in the Root Directory of a Project "no Input Files" -



c++ - Makefile in the Root Directory of a Project "no Input Files" -

i'm having issues getting makefile work simple c++ project. error getting is

"fatal-error: no input files"

here project structure:

root | |___makefile | |___bin | |___src | | | |___main.cpp | |___include | |___gl | | | |___glew.h | |___glfw3.h | |___glm | |___glm.hpp

and here makefile:

cc = g++ inc_dir1 = include/gl inc_dir2 = include/glm src_dir = src obj_dir = bin cflags = -c -wall -i srcs = $(src_dir)/main.cpp objs = $(obj_dir)/main.o deps = $(inc_dir1)/glew.h $(inc_dir1)/glfw3.h $(inc_dir2)/glm.hpp executable = game all: $(objs) $(executable) $(obj_dir)/%.o : $(src_dir)/%.cpp $(cc) $(cflags) $< -o $@ $(executable): $(objs) $(cc) $(objs) -o $@ $(obj_dir)/main.o: $(deps)

i'm not sure if trying find .ccp files header files or if set makefile incorrectly. i'm pretty new makefiles insight much appreciated.

thanks.

edit:

so able resolve of issues having getting next error when seek create programme via command line:

:multiple definition of `main' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../..\libmingw32.a(main.o):main.c:(.tex t.startup+0x0): first defined here c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../..\libmingw32.a(main.o):main.c:(.tex t.startup+0xa7): undefined reference `winmain@16' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/mingw/b in/../lib/gcc/mingw32/4.8.1/../../..\libmingw32.a(main.o): bad reloc address 0x2 0 in section `.eh_frame' collect2.exe: error: ld returned 1 exit status make: *** [game.exe] error 1

below updated makefile

#makefile cc = g++ inc_dir = include lib_dir = lib src_dir = src obj_dir = bin cflags = -wall -i $(inc_dir) ldflags = -l $(lib_dir) -static -lglfw3 -lmingw32 options = -std=c++0x -o3 srcs = $(src_dir)/main.cpp objs = $(obj_dir)/main.o executable = game.exe all: $(executable) $(executable) : $(srcs) $(cc) $(cflags) $(ldflags) $< -o $@ clean: rm $(executable)

i know issue is finding 2 main methods in file somewhere in mingw32 library unsure how should go resolving error.

please show command invoked , exact error got, cutting , pasted. have taken me 1/20th time see wrong if you'd have done that.

here's problem:

cflags = -c -wall -i $(obj_dir)/%.o : $(src_dir)/%.cpp $(cc) $(cflags) $< -o $@

expanded out, run next command:

g++ -c -wall -i src/main.cpp -o bin/main.o

the problem here you've got -i in cflags, no directory after it. means next word, in case src/main.cpp, taken directory added include line.

probably want like:

cflags = -c -wall -i$(inc_dir1) -i$(inc_dir2)

c++ makefile g++ root

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -