darknet
My application is to record sound via microphone, to preprocess like fft, and to classify voice activities. I composed own code that deals with recording,converting into *.wav,and doing learning and predicting in the name of sound.c. At this time, I do not need image processing.
Anyway, followings are what I get during make.
#-desktop:~/darknet_tmp$ make
PATH:=/usr/local/cuda-11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda/bin:/usr/local/cuda/lib64
g++ -std=c++11 -std=c++11 -Iinclude/ -I3rdparty/stb/include -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -Ofast -DGPU -DCUDNN -I/usr/local/cudnn/include -fPIC obj/sound.o obj/http_stream.o obj/gemm.o obj/utils.o obj/dark_cuda.o obj/convolutional_layer.o obj/list.o obj/image.o obj/activations.o obj/im2col.o obj/col2im.o obj/blas.o obj/crop_layer.o obj/dropout_layer.o obj/maxpool_layer.o obj/softmax_layer.o obj/data.o obj/matrix.o obj/network.o obj/connected_layer.o obj/cost_layer.o obj/parser.o obj/option_list.o obj/darknet.o obj/detection_layer.o obj/captcha.o obj/route_layer.o obj/writing.o obj/box.o obj/nightmare.o obj/normalization_layer.o obj/avgpool_layer.o obj/coco.o obj/dice.o obj/yolo.o obj/detector.o obj/layer.o obj/compare.o obj/classifier.o obj/local_layer.o obj/swag.o obj/shortcut_layer.o obj/activation_layer.o obj/rnn_layer.o obj/gru_layer.o obj/rnn.o obj/rnn_vid.o obj/crnn_layer.o obj/demo.o obj/tag.o obj/cifar.o obj/go.o obj/batchnorm_layer.o obj/art.o obj/region_layer.o obj/reorg_layer.o obj/reorg_old_layer.o obj/super.o obj/voxel.o obj/tree.o obj/yolo_layer.o obj/gaussian_yolo_layer.o obj/upsample_layer.o obj/lstm_layer.o obj/conv_lstm_layer.o obj/scale_channels_layer.o obj/sam_layer.o obj/convolutional_kernels.o obj/activation_kernels.o obj/im2col_kernels.o obj/col2im_kernels.o obj/blas_kernels.o obj/crop_layer_kernels.o obj/dropout_layer_kernels.o obj/maxpool_layer_kernels.o obj/network_kernels.o obj/avgpool_layer_kernels.o -o darknet -lm -pthread -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand -L/usr/local/cudnn/lib64 -lcudnn -lstdc++
obj/darknet.o: In function `main':
darknet.c:(.text.startup+0xae): undefined reference to `show_opencv_info'
obj/network_kernels.o: In function `backward_network_gpu':
tmpxft_00001197_00000000-6_network_kernels.cudafe1.cpp:(.text+0xc90): undefined reference to `resize_window_cv'
obj/network_kernels.o: In function `train_network_datum_gpu':
tmpxft_00001197_00000000-6_network_kernels.cudafe1.cpp:(.text+0x163a): undefined reference to `resize_window_cv'
tmpxft_00001197_00000000-6_network_kernels.cudafe1.cpp:(.text+0x1644): undefined reference to `wait_key_cv'
obj/data.o: In function `load_data_detection':
data.c:(.text+0x4dba): undefined reference to `wait_until_press_key_cv'
obj/data.o: In function `load_data_augment':
data.c:(.text+0x5ad2): undefined reference to `wait_until_press_key_cv'
obj/network.o: In function `train_network_waitkey':
network.c:(.text+0x13db): undefined reference to `wait_key_cv'
obj/writing.o: In function `test_writing':
writing.c:(.text+0x9ae): undefined reference to `wait_until_press_key_cv'
writing.c:(.text+0x9b5): undefined reference to `destroy_all_windows_cv'
obj/coco.o: In function `test_coco':
coco.c:(.text+0x1ac0): undefined reference to `wait_until_press_key_cv'
coco.c:(.text+0x1ac7): undefined reference to `destroy_all_windows_cv'
obj/yolo.o: In function `test_yolo':
yolo.c:(.text+0x1a40): undefined reference to `wait_until_press_key_cv'
yolo.c:(.text+0x1a47): undefined reference to `destroy_all_windows_cv'
obj/detector.o: In function `test_detector':
detector.c:(.text+0x8a0b): undefined reference to `wait_until_press_key_cv'
detector.c:(.text+0x8a12): undefined reference to `destroy_all_windows_cv'
collect2: error: ld returned 1 exit status
Makefile:173: recipe for target 'darknet' failed
make: *** [darknet] Error 1
I need your help and advice.
Makefile
GPU=1
CUDNN=1
CUDNN_HALF=0
OPENCV=0
AVX=0
OPENMP=0
LIBSO=1
ZED_CAMERA=0
ZED_CAMERA_v2_8=0
export PATH:=${PATH}:/usr/local/cuda/bin
export PATH:=${PATH}:/usr/local/cuda/lib64
$(info PATH:=${PATH})
# set GPU=1 and CUDNN=1 to speedup on GPU
# set CUDNN_HALF=1 to further speedup 3 x times (Mixed-precision on Tensor Cores) GPU: Volta, Xavier, Turing and higher
# set AVX=1 and OPENMP=1 to speedup on CPU (if error occurs then set AVX=0)
# set ZED_CAMERA=1 to enable ZED SDK 3.0 and above
# set ZED_CAMERA_v2_8=1 to enable ZED SDK 2.X
USE_CPP=0
DEBUG=0
#ARCH= -gencode arch=compute_30,code=sm_30 \
# -gencode arch=compute_35,code=sm_35 \
# -gencode arch=compute_50,code=[sm_50,compute_50] \
# -gencode arch=compute_52,code=[sm_52,compute_52] \
# -gencode arch=compute_61,code=[sm_61,compute_61]
ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61
OS := $(shell uname)
# Tesla A100 (GA100), DGX-A100, RTX 3080
# ARCH= -gencode arch=compute_80,code=[sm_80,compute_80]
# Tesla V100
# ARCH= -gencode arch=compute_70,code=[sm_70,compute_70]
# GeForce RTX 2080 Ti, RTX 2080, RTX 2070, Quadro RTX 8000, Quadro RTX 6000, Quadro RTX 5000, Tesla T4, XNOR Tensor Cores
# ARCH= -gencode arch=compute_75,code=[sm_75,compute_75]
# Jetson XAVIER
# ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]
# GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4
# ARCH= -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61
# GP100/Tesla P100 - DGX-1
# ARCH= -gencode arch=compute_60,code=sm_60
# For Jetson TX1, Tegra X1, DRIVE CX, DRIVE PX - uncomment:
# ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]
# For Jetson Tx2 or Drive-PX2 uncomment:
# ARCH= -gencode arch=compute_62,code=[sm_62,compute_62]
VPATH=./src/
EXEC=darknet
OBJDIR=./obj/
ifeq ($(LIBSO), 1)
LIBNAMESO=libdarknet.so
APPNAMESO=uselib
endif
ifeq ($(USE_CPP), 1)
CC=g++
else
CC=gcc
endif
CPP=g++ -std=c++11
NVCC=nvcc
OPTS=-Ofast
LDFLAGS= -lm -pthread
COMMON= -Iinclude/ -I3rdparty/stb/include
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC
ifeq ($(DEBUG), 1)
#OPTS= -O0 -g
#OPTS= -Og -g
COMMON+= -DDEBUG
CFLAGS+= -DDEBUG
else
ifeq ($(AVX), 1)
CFLAGS+= -ffp-contract=fast -mavx -mavx2 -msse3 -msse4.1 -msse4.2 -msse4a
endif
endif
CFLAGS+=$(OPTS)
ifneq (,$(findstring MSYS_NT,$(OS)))
LDFLAGS+=-lws2_32
endif
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv4 2> /dev/null || pkg-config --libs opencv`
COMMON+= `pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv`
endif
ifeq ($(OPENMP), 1)
ifeq ($(OS),Darwin) #MAC
CFLAGS+= -Xpreprocessor -fopenmp
else
CFLAGS+= -fopenmp
endif
LDFLAGS+= -lgomp
endif
ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
ifeq ($(OS),Darwin) #MAC
LDFLAGS+= -L/usr/local/cuda/lib -lcuda -lcudart -lcublas -lcurand
else
LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand
endif
endif
ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
ifeq ($(OS),Darwin) #MAC
CFLAGS+= -DCUDNN -I/usr/local/cuda/include
LDFLAGS+= -L/usr/local/cuda/lib -lcudnn
else
CFLAGS+= -DCUDNN -I/usr/local/cudnn/include
LDFLAGS+= -L/usr/local/cudnn/lib64 -lcudnn
endif
endif
ifeq ($(CUDNN_HALF), 1)
COMMON+= -DCUDNN_HALF
CFLAGS+= -DCUDNN_HALF
ARCH+= -gencode arch=compute_70,code=[sm_70,compute_70]
endif
ifeq ($(ZED_CAMERA), 1)
CFLAGS+= -DZED_STEREO -I/usr/local/zed/include
ifeq ($(ZED_CAMERA_v2_8), 1)
LDFLAGS+= -L/usr/local/zed/lib -lsl_core -lsl_input -lsl_zed
#-lstdc++ -D_GLIBCXX_USE_CXX11_ABI=0
else
LDFLAGS+= -L/usr/local/zed/lib -lsl_zed
#-lstdc++ -D_GLIBCXX_USE_CXX11_ABI=0
endif
endif
OBJ=sound.o http_stream.o gemm.o utils.o dark_cuda.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o captcha.o route_layer.o writing.o box.o nightmare.o normalization_layer.o avgpool_layer.o coco.o dice.o yolo.o detector.o layer.o compare.o classifier.o local_layer.o swag.o shortcut_layer.o activation_layer.o rnn_layer.o gru_layer.o rnn.o rnn_vid.o crnn_layer.o demo.o tag.o cifar.o go.o batchnorm_layer.o art.o region_layer.o reorg_layer.o reorg_old_layer.o super.o voxel.o tree.o yolo_layer.o gaussian_yolo_layer.o upsample_layer.o lstm_layer.o conv_lstm_layer.o scale_channels_layer.o sam_layer.o
ifeq ($(GPU), 1)
LDFLAGS+= -lstdc++
OBJ+=convolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o network_kernels.o avgpool_layer_kernels.o
endif
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile include/darknet.h
all: $(OBJDIR) backup results $(EXEC) $(LIBNAMESO) $(APPNAMESO)
ifeq ($(LIBSO), 1)
CFLAGS+= -fPIC
$(LIBNAMESO): $(OBJDIR) $(OBJS) include/yolo_v2_class.hpp src/yolo_v2_class.cpp
$(CPP) -shared -std=c++11 -fvisibility=hidden -DLIB_EXPORTS $(COMMON) $(CFLAGS) $(OBJS) src/yolo_v2_class.cpp -o $# $(LDFLAGS)
$(APPNAMESO): $(LIBNAMESO) include/yolo_v2_class.hpp src/yolo_console_dll.cpp
$(CPP) -std=c++11 $(COMMON) $(CFLAGS) -o $# src/yolo_console_dll.cpp $(LDFLAGS) -L ./ -l:$(LIBNAMESO)
endif
$(EXEC): $(OBJS)
$(CPP) -std=c++11 $(COMMON) $(CFLAGS) $^ -o $# $(LDFLAGS)
$(OBJDIR)%.o: %.c $(DEPS)
$(CC) $(COMMON) $(CFLAGS) -c $< -o $#
$(OBJDIR)%.o: %.cpp $(DEPS)
$(CPP) -std=c++11 $(COMMON) $(CFLAGS) -c $< -o $#
$(OBJDIR)%.o: %.cu $(DEPS)
$(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $#
$(OBJDIR):
mkdir -p $(OBJDIR)
backup:
mkdir -p backup
results:
mkdir -p results
setchmod:
chmod +x *.sh
.PHONY: clean
clean:
rm -rf $(OBJS) $(EXEC) $(LIBNAMESO) $(APPNAMESO)
I'm trying to get dlib library working in my C++ project from last 2 weeks and found some solution but still i'm facing errors which i can not understand. As i am newbie to the makefile and dlib guide me what to do with makefile.
The folder structure is like this:
projectDir
|-makefile
|-src
|-CDetector.cpp
|-CDetectot.h
|-CStreamReader.cpp
|-CStreamReader.h
|-include
|-darknet
|-(files).h (other .h files needed by src files)
|-dlib-19.6
|-all
|-source.cpp
|-lots of header files
|-...
|-external_libs
|-libdarknet.a
|-libdarknet.so
The makefile looks like this:
EXE = darknet
OBJ_DIR = obj
CXXFILES = $(shell find src -type f -name '*.cpp')
CXXOBJ = $(patsubst src/%.cpp,obj/%.o,$(CXXFILES))
INCLUDE = -I/include -I/include/darknet
LIBS = external_libs/libdarknet.a
CXXFLAGS = `pkg-config --cflags-only-I opencv` -Wall -Wno-unknown-pragmas -Wfatal-errors -Wwrite-strings -fPIC
LDFLAGS = -lm -pthread -lX11 -DDLIB_JPEG_SUPPORT -ljpeg
all: $(EXE)
$(EXE): $(CXXOBJ)
$(CXX) $(CXXOBJ) -o $(EXE) $(LIBS) $(LDFLAGS)
$(OBJ_DIR)/%.o: src/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDE) $< -c -o $#
$(BUILD)
run: all
./$(EXE)
clean:
-rm -f $(EXE) $(CXXOBJ)
rmdir obj/
It needs some modification as INCLUDE, CXXFLAGS AND LDFLAGS will be
INCLUDE = -Iinclude -Iinclude/darknet `pkg-config --cflags-only-I opencv`
CXXFLAGS = -Wall -Wno-unknown-pragmas -Wfatal-errors -Wwrite-strings -fPIC
LDFLAGS = -lm -pthread -lX11 -DDLIB_JPEG_SUPPORT -ljpeg -lopencv_videoio `pkg-config --libs opencv`
and i'm now using darknet makefile to do it so my makefile looks like
VPATH = ./src/
ALIB = external_libs/libdarknet.a
EXEC = darknet
OBJDIR = ./obj/
CC = g++ -std=c++11
NVCC = nvcc
AR = ar
ARFLAGS = rcs
OPTS = -Ofast
LDFLAGS = -lm -pthread -lX11 -DDLIB_JPEG_SUPPORT -ljpeg -lopencv_videoio `pkg-config --libs opencv`
INCLUDE = -Iinclude -Iinclude/darknet `pkg-config --cflags-only-I opencv`
CFLAGS = -Wall -Wno-unknown-pragmas -Wfatal-errors -Wwrite-strings -fPIC
OBJ = CDetector.o CStreamReader.o
EXECOBJA = CDetector.o CStreamReader.o
EXECOBJ = $(addprefix $(OBJDIR), $(EXECOBJA))
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile include/darknet/darknet.h
all: obj results $(ALIB) $(EXEC)
$(EXEC): $(EXECOBJ) $(ALIB)
$(CC) $(INCLUDE) $(CFLAGS) $^ -o $# $(LDFLAGS) $(ALIB)
$(ALIB): $(OBJS)
$(AR) $(ARFLAGS) $# $^
$(OBJDIR)%.o: %.cpp $(DEPS)
$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $#
obj:
mkdir -p obj
backup:
mkdir -p backup
results:
mkdir -p results
.PHONY: clean
clean:
rm -rf $(OBJS) $(ALIB) $(EXEC) $(EXECOBJ)
I'm in Ubuntu 16.04.3 LTS xenial and I'm trying to run the command make on the terminal, but I'm getting this error:
g++ -g -O2 -Wall -Wuninitialized -fno-strict-aliasing -Iinclude -
I/usr/local/include -DOS_LINUX -DHAVE_USB -DHAVE_LIBUSB10 -
DUSE_DRS_MUTEX -I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-
3.1-unofficial3 -I/usr/include/wx-3.1-unofficial -
D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -c src/DRS.cpp
In file included from /usr/include/c++/5/type_traits:35:0,
from /usr/include/wx-3.1-unofficial/wx/strvararg.h:22,
from /usr/include/wx-3.1-unofficial/wx/string.h:37,
from /usr/include/wx-3.1-unofficial/wx/memory.h:15,
from /usr/include/wx-3.1-unofficial/wx/object.h:19,
from /usr/include/wx-3.1-unofficial/wx/wx.h:15,
from src/DRS.cpp:15:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file
requires compiler and library support for the ISO C++ 2011 standard.
This support must be enabled with the -std=c++11 or -std=gnu++11 c
ompiler options.
#error This file requires compiler and library support \
^
In file included from /usr/include/wx-3.1-unofficial/wx/string.h:37:0,
from /usr/include/wx-3.1-unofficial/wx/memory.h:15,
from /usr/include/wx-3.1-unofficial/wx/object.h:19,
from /usr/include/wx-3.1-unofficial/wx/wx.h:15,
from src/DRS.cpp:15:
/usr/include/wx-3.1-unofficial/wx/strvararg.h:345:18: error: ‘is_enum’
in namespace ‘std’ does not name a template type
typedef std::is_enum<T> is_enum;
^
/usr/include/wx-3.1-unofficial/wx/strvararg.h:349:54: error: ‘is_enum’
was not declared in this scope
enum { value =
wxFormatStringSpecifierNonPodType<is_enum::value>::value };
^
/usr/include/wx-3.1-unofficial/wx/strvararg.h:349:68: error: template
argument 1 is invalid
enum { value =
wxFormatStringSpecifierNonPodType<is_enum::value>::value };
^
src/DRS.cpp: In member function ‘void DRSBoard::InteractSpeed()’:
src/DRS.cpp:3986:25: warning: ignoring return value of ‘int
scanf(const char*, ...)’, declared with attribute warn_unused_result
[-Wunused-result]
scanf("%lf", &vds);
^
Makefile:81: recipe for target 'DRS.o' failed
make: *** [DRS.o] Error 1
I think that I must do this correction:
This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
I have never tried to do something like this before, so I don't know how to correct.
Follows the makefile:
# check if wxWidgets is installed
HAVE_WX = $(shell which wx-config)
ifeq ($(HAVE_WX),)
$(error Error: wxWidgets required to compile "drsosc")
endif
# check for OS
OS = $(shell uname)
ifeq ($(OS),Darwin)
DOS = OS_DARWIN
else
DOS = OS_LINUX
endif
CFLAGS = -g -O2 -Wall -Wuninitialized -fno-strict-aliasing -
Iinclude -I/usr/local/include -D$(DOS) -DHAVE_USB -DHAVE_LIBUSB10 -
DUSE_DRS_MUTEX
LIBS = -lpthread -lutil -lusb-1.0
ifeq ($(OS),Darwin)
CFLAGS += -stdlib=libstdc++
endif
# wxWidgets libs and flags
WXLIBS = $(shell wx-config --libs)
WXFLAGS = $(shell wx-config --cxxflags)
CPP_OBJ = DRS.o averager.o ConfigDialog.o DOFrame.o DOScreen.o
DRSOsc.o MeasureDialog.o Measurement.o Osci.o InfoDialog.o
DisplayDialog.o AboutDialog.o EPThread.o TriggerDialog.o rb.o
OBJECTS = musbstd.o mxml.o strlcpy.o
ifeq ($(OS),Darwin)
all: drsosc drscl drs_exam drs_exam_multi DRSOsc.app
else
all: drsosc drscl drs_exam drs_exam_multi
endif
DRSOsc.app: drsosc
-mkdir DRSOsc.app
-mkdir DRSOsc.app/Contents
-mkdir DRSOsc.app/Contents/MacOS
-mkdir DRSOsc.app/Contents/Resources
-mkdir DRSOsc.app/Contents/Resources/English.lproj
echo 'APPL????' > DRSOsc.app/Contents/PkgInfo
cp Info.plist DRSOsc.app/Contents/Info.plist
cp DRSOsc.icns DRSOsc.app/Contents/Resources
cp drsosc DRSOsc.app/Contents/MacOS/DRSOsc
drsosc: $(OBJECTS) $(CPP_OBJ) main.o
$(CXX) $(CFLAGS) $(OBJECTS) $(CPP_OBJ) main.o -o drsosc $(LIBS)
$(WXLIBS)
drscl: $(OBJECTS) DRS.o averager.o drscl.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drscl.o -o drscl
$(LIBS) $(WXLIBS)
drs_exam: $(OBJECTS) DRS.o averager.o drs_exam.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drs_exam.o -o drs_exam
$(LIBS) $(WXLIBS)
drs_exam_multi: $(OBJECTS) DRS.o averager.o drs_exam_multi.o
$(CXX) $(CFLAGS) $(OBJECTS) DRS.o averager.o drs_exam_multi.o -o
drs_exam_multi $(LIBS) $(WXLIBS)
main.o: src/main.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) $(WXFLAGS) -c $<
drscl.o: src/drscl.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
drs_exam.o: src/drs_exam.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
drs_exam_multi.o: src/drs_exam_multi.cpp include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) -c $<
$(CPP_OBJ): %.o: src/%.cpp include/%.h include/mxml.h include/DRS.h
$(CXX) $(CFLAGS) $(WXFLAGS) -c $<
$(OBJECTS): %.o: src/%.c include/mxml.h include/DRS.h
$(CC) $(CFLAGS) -c $<
clean:
rm -f *.o drscl drsosc
In my research I didn't find anything helpful.
Sorry for the long post, couldn't make it more simple.
You simply need to set the C++ standard by adding it to the CFLAGS, ie:
CFLAGS += -std=c++11
I have the same problem you have and I was looking for an answer but can't find one so I solved it on my own. In my case, the problem is with the string.h header file I removed it and my code is working now.
I'm having issues getting my Makefile to work for a simple C++ project.
The error I am getting is
"fatal-error: no input files"
Here is my project structure:
ROOT
|
|___Makefile
|
|___bin
|
|___src
| |
| |___main.cpp
|
|___include
|
|___GL
| |
| |___glew.h
| |___glfw3.h
|
|___glm
|
|___glm.hpp
And Here is my 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 its trying to find .ccp files for the header files or If I set my Makefile up incorrectly. I'm pretty new to Makefiles so any insight would be much appreciated.
Thanks.
EDIT:
So I was able to resolve most of the issues I was having however now I am getting the following error when I try to make my program 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 to `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 is my 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 the issue is that it is finding two main methods in a file somewhere in my mingw32 library but I am unsure as to how I should go about resolving the error.
Please show the command that was invoked and the exact error you got, cut and pasted. It would have taken me about 1/20th the time to see what was wrong if you'd have done that.
Here's your problem:
CFLAGS = -c -Wall -I
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp
$(CC) $(CFLAGS) $< -o $#
Expanded out, this will run the following command:
g++ -c -Wall -I src/main.cpp -o bin/main.o
The problem here is you've got -I in your CFLAGS, with no directory after it. That means that the next word, in this case src/main.cpp, is taken to be the directory to be added to the include line.
Probably you want something like:
CFLAGS = -c -Wall -I$(INC_DIR1) -I$(INC_DIR2)
After trying to compile a program on a friendlyARM qtopia 2.0.0 but I am getting this error:
/sdcard/images/makef # make -f Makefile
gcc -o main obj/main.o obj/serial.o obj/fb.o obj/menu_main.o obj/timer.o obj/cmdin.o obj/buzzer.o obj/statemachine.o obj/inout.o obj/network.o obj/text_file_input.o obj/text_file_input_oven.o -I./ -lgd -lrt
/usr/bin/ld:/usr/lib/gcc/arm-linux-gnueabi/4.4.1/../../../librt.so: file format not recognized; treating as linker script
/usr/bin/ld:/usr/lib/gcc/arm-linux-gnueabi/4.4.1/../../../librt.so:2: syntax error
collect2: ld returned 1 exit status
make: *** [main] Error 1
/sdcard/images/makef #
makefile :
IDIR =./
CC=gcc
CFLAGS=-I$(IDIR)
ODIR=obj
LDIR =./
LIBS=-lgd -lrt
_DEPS = main.h Makefile
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
_OBJ = main.o serial.o fb.o menu_main.o timer.o cmdin.o buzzer.o statemachine.o inout.o network.o text_file_input.o text_file_input_oven.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
$(ODIR)/%.o: %.c $(DEPS)
$(CC) -c -o $# $< $(CFLAGS)
main: $(OBJ)
gcc -o $# $^ $(CFLAGS) $(LIBS)
.PHONY: clean
clean:
rm -f $(ODIR)/*.o *~ core $(INCDIR)/*~