Closed laputae closed 1 year ago
错误的makefile如下: CXX = g++ CFLAGS = -std=c++14 -O2 -Wall -g
TARGET = server OBJS = ../code/log/.cpp ../code/pool/.cpp ../code/timer/.cpp \ ../code/http/.cpp ../code/server/.cpp \ ../code/buffer/.cpp ../code/main.cpp
all: $(OBJS) $(CXX) $(CFLAGS) $(OBJS) -o ../bin/$(TARGET) -pthread -lmysqlclient
clean: rm -rf ../bin/$(OBJS) $(TARGET)
错误如下 g++ -std=c++14 -O2 -Wall -g ../code/log/.cpp ../code/pool/.cpp ../code/timer/.cpp ../code/http/.cpp ../code/server/.cpp ../code/buffer/.cpp ../code/main.cpp -o ../bin/server -pthread -lmysqlclient ../code/http/httprequest.cpp: In static member function ‘static bool HttpRequest::UserVerify(const string&, const string&, bool)’: ../code/http/httprequest.cpp:185:18: warning: variable ‘j’ set but not used [-Wunused-but-set-variable] 185 | unsigned int j = 0; | ^ ../code/http/httprequest.cpp:187:18: warning: variable ‘fields’ set but not used [-Wunused-but-set-variable] 187 | MYSQL_FIELD *fields = nullptr; | ^~ /usr/bin/ld: cannot open output file ../bin/server: 没有那个文件或目录 collect2: error: ld returned 1 exit status make: *** [Makefile:10:all] 错误 1
可以在项目的根目录执行make,不要在build目录里面执行make
错误的makefile如下: CXX = g++ CFLAGS = -std=c++14 -O2 -Wall -g
TARGET = server OBJS = ../code/log/.cpp ../code/pool/.cpp ../code/timer/.cpp \ ../code/http/.cpp ../code/server/.cpp \ ../code/buffer/.cpp ../code/main.cpp
all: $(OBJS) $(CXX) $(CFLAGS) $(OBJS) -o ../bin/$(TARGET) -pthread -lmysqlclient
clean: rm -rf ../bin/$(OBJS) $(TARGET)
错误如下 g++ -std=c++14 -O2 -Wall -g ../code/log/.cpp ../code/pool/.cpp ../code/timer/.cpp ../code/http/.cpp ../code/server/.cpp ../code/buffer/.cpp ../code/main.cpp -o ../bin/server -pthread -lmysqlclient ../code/http/httprequest.cpp: In static member function ‘static bool HttpRequest::UserVerify(const string&, const string&, bool)’: ../code/http/httprequest.cpp:185:18: warning: variable ‘j’ set but not used [-Wunused-but-set-variable] 185 | unsigned int j = 0; | ^ ../code/http/httprequest.cpp:187:18: warning: variable ‘fields’ set but not used [-Wunused-but-set-variable] 187 | MYSQL_FIELD *fields = nullptr; | ^
~/usr/bin/ld: cannot open output file ../bin/server: 没有那个文件或目录 collect2: error: ld returned 1 exit status make: *** [Makefile:10:all] 错误 1