My code compiles well in codeblocks, but my makefile can't compile because of undefined reference to items with my namespace Chess
how should i specify the namespace in makefile or fix it?
here's the errors example:
King.cpp:35: undefined reference to `Chess::Board::getPiece(Chess::Position const&) const'
here's my makefile
CXXFLAGS = -ISFML-2.4.2/include -std=c++11
LXXFLAGS = -LSFML-2.4.2/lib -lsfml-graphics-d -lsfml-audio-d -lsfml-network-d -lsfml-window-d -lsfml-system-d -std=c++11
main.exe: main.o bishop.o king.o knight.o pawn.o position.o queen.o rook.o gui.o piece.o board.o Bishop.hpp Board.hpp
g++ -std=c++11 main.o bishop.o king.o knight.o pawn.o position.o queen.o rook.o gui.o piece.o -o main $(LXXFLAGS)
main.o: main.cpp GUI.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 main.cpp -c $(CXXFLAGS)
bishop.o: Bishop.cpp Bishop.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Bishop.cpp -c $(CXXFLAGS)
king.o: King.cpp King.hpp Rook.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 King.cpp -c $(CXXFLAGS)
pawn.o: Pawn.cpp Pawn.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Pawn.cpp -c $(CXXFLAGS)
position.o: Position.cpp Position.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Position.cpp -c $(CXXFLAGS)
queen.o: Queen.cpp Queen.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Queen.cpp -c $(CXXFLAGS)
rook.o: Rook.cpp Rook.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Rook.cpp -c $(CXXFLAGS)
knight.o: Knight.cpp Knight.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Knight.cpp -c $(CXXFLAGS)
gui.o: GUI.cpp GUI.hpp Queen.hpp Rook.hpp Bishop.hpp Knight.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 GUI.cpp -c $(CXXFLAGS)
piece.o: Piece.cpp Piece.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Piece.cpp -c $(CXXFLAGS)
board.o: Board.cpp Board.hpp Pawn.hpp Rook.hpp Knight.hpp Queen.hpp King.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Board.cpp -c $(CXXFLAGS)
You forgot to include board.o when compiling main.exe
Related
When I try to use the cplex from IBM in my code and try to compile it, it shows the following error. I've provided the path to the cplex include file and the concert include file, but it still says 'ilcplex/ilocplex.h' file not found.
test: test.o assembly.pb.o Mesh.o Assembly.o Part.o Mate.o MateConnector.o ConstraintsMath.o ConnectGraph.o Model.o myOptimizer.o
g++ test.o assembly.pb.o Mesh.o Assembly.o Part.o Mate.o MateConnector.o ConnectGraph.o ConstraintsMath.o Model.o myOptimizer.o -o test -lprotobuf
test.o: test.cc assembly.pb.h Assembly.h Mate.h Model.h Mesh.h Part.h MateConnector.h ConnectGraph.h ConstraintsMath.h myOptimizer.h
g++ -Wall -g -std=c++11 -c test.cc
Mesh.o: Mesh.cc Mesh.h
g++ -Wall -g -std=c++11 -c Mesh.cc
Assembly.o: Assembly.cc Assembly.h Mate.h Model.h Mesh.h MateConnector.h ConnectGraph.h myOptimizer.h
g++ -Wall -g -std=c++11 -c Assembly.cc
Part.o: Part.cc Part.h Model.h Mesh.h MateConnector.h
g++ -Wall -g -std=c++11 -c Part.cc
Mate.o: Mate.cc Mate.h Model.h Mesh.h MateConnector.h
g++ -Wall -g -std=c++11 -c Mate.cc
assembly.pb.o: assembly.pb.cc assembly.pb.h
g++ -Wall -g -std=c++11 -c assembly.pb.cc
MateConnector.o: MateConnector.cc MateConnector.h ConstraintsMath.h Model.h
g++ -Wall -g -std=c++11 -c MateConnector.cc
ConstraintsMath.o: ConstraintsMath.cc ConstraintsMath.h
g++ -Wall -g -std=c++11 -c ConstraintsMath.cc
ConnectGraph.o: ConnectGraph.cc ConnectGraph.h Part.h MateConnector.h
g++ -Wall -g -std=c++11 -c ConnectGraph.cc
Model.o: Model.cc Model.h Mesh.h Mate.h
g++ -Wall -g -std=c++11 -c Model.cc
myOptimizer.o: myOptimizer.cc myOptimizer.h
g++ -DIL_STD -I/Applications/CPLEX_Studio129/cplex/include -I/Applications/CPLEX_Studio129/concert/include \
-Wall -g -std=c++11 -c myOptimizer.cc \
-L/Applications/CPLEX_Studio129/concert/lib/x86-64_osx/static_pic\
-L/Applications/CPLEX_Studio129/cplex/lib/x86-64_osx/static_pic \
-lcplex
clean:
rm -rf test *.o *~ *.dSYM
The error it showed is:
c++ -c -o myOptimizer.o myOptimizer.cc
myOptimizer.cc:4:10: fatal error: 'ilcplex/ilocplex.h' file not found
#include <ilcplex/ilocplex.h>
^~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [myOptimizer.o] Error 1
I'm trying to compile this piece of software called Register3D_wx but have problems when trying to run make. I have installed Open GSL, Open GL and wxWidgets library as required. When I cd into the folder and run make, I get lots of error messages. I'm giving some of the output:
james#james-HP-Z420-Workstation:~/Downloads/Register3D_wx_1.1.1$ sudo make
test -d bin/Release || mkdir -p bin/Release
test -d obj/Release/ann_1.1.2/src || mkdir -p obj/Release/ann_1.1.2/src
test -d obj/Release/ || mkdir -p obj/Release/
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_pr_search.cpp -o obj/Release/ann_1.1.2/src/kd_pr_search.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ZPR.cc -o obj/Release/ZPR.o
ZPR.cc: In member function ‘void ZPR::ZprPick(GLdouble, GLdouble, GLdouble, GLdouble)’:
ZPR.cc:424:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (buffer[j+1]<minZ)
^
ZPR.cc:380:11: warning: variable ‘min’ set but not used [-Wunused-but-set-variable]
GLint min = -1;
^
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/ANN.cpp -o obj/Release/ann_1.1.2/src/ANN.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/bd_fix_rad_search.cpp -o obj/Release/ann_1.1.2/src/bd_fix_rad_search.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/bd_pr_search.cpp -o obj/Release/ann_1.1.2/src/bd_pr_search.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/bd_search.cpp -o obj/Release/ann_1.1.2/src/bd_search.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/bd_tree.cpp -o obj/Release/ann_1.1.2/src/bd_tree.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/brute.cpp -o obj/Release/ann_1.1.2/src/brute.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_dump.cpp -o obj/Release/ann_1.1.2/src/kd_dump.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_fix_rad_search.cpp -o obj/Release/ann_1.1.2/src/kd_fix_rad_search.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c PointOP.cc -o obj/Release/PointOP.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_search.cpp -o obj/Release/ann_1.1.2/src/kd_search.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_split.cpp -o obj/Release/ann_1.1.2/src/kd_split.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_tree.cpp -o obj/Release/ann_1.1.2/src/kd_tree.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/kd_util.cpp -o obj/Release/ann_1.1.2/src/kd_util.o
g++ -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ann_1.1.2/src/perf.cpp -o obj/Release/ann_1.1.2/src/perf.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c main.cc -o obj/Release/main.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c MainWindow.cc -o obj/Release/MainWindow.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Cylinder.cc -o obj/Release/Cylinder.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c GLCanvas.cc -o obj/Release/GLCanvas.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Help.cc -o obj/Release/Help.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ICP.cc -o obj/Release/ICP.o
ICP.cc: In member function ‘void ICP::SetPoints(std::vector<Point>&, std::vector<Point>&, float)’:
ICP.cc:439:73: warning: format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘std::vector<Point>::size_type {aka long unsigned int}’ [-Wformat=]
printf("Number of points after downsampling: %i\n", m_points2.size());
^
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c ICPDialog.cc -o obj/Release/ICPDialog.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c About.cc -o obj/Release/About.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Math2.cc -o obj/Release/Math2.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Matrix.cc -o obj/Release/Matrix.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Misc.cc -o obj/Release/Misc.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c MyANN.cc -o obj/Release/MyANN.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c OGLWrapper.cc -o obj/Release/OGLWrapper.o
gcc -O2 -Wall `wx-config --cflags` `gsl-config --cflags` -Iann_1.1.2/include -c Point.cc -o obj/Release/Point.o
g++ -s `wx-config --libs` `wx-config --libs gl` `gsl-config --libs` -Lann_1.1.2/include obj/Release/ann_1.1.2/src/kd_pr_search.o obj/Release/ZPR.o obj/Release/ann_1.1.2/src/ANN.o obj/Release/ann_1.1.2/src/bd_fix_rad_search.o obj/Release/ann_1.1.2/src/bd_pr_search.o obj/Release/ann_1.1.2/src/bd_search.o obj/Release/ann_1.1.2/src/bd_tree.o obj/Release/ann_1.1.2/src/brute.o obj/Release/ann_1.1.2/src/kd_dump.o obj/Release/ann_1.1.2/src/kd_fix_rad_search.o obj/Release/PointOP.o obj/Release/ann_1.1.2/src/kd_search.o obj/Release/ann_1.1.2/src/kd_split.o obj/Release/ann_1.1.2/src/kd_tree.o obj/Release/ann_1.1.2/src/kd_util.o obj/Release/ann_1.1.2/src/perf.o obj/Release/main.o obj/Release/MainWindow.o obj/Release/Cylinder.o obj/Release/GLCanvas.o obj/Release/Help.o obj/Release/ICP.o obj/Release/ICPDialog.o obj/Release/About.o obj/Release/Math2.o obj/Release/Matrix.o obj/Release/Misc.o obj/Release/MyANN.o obj/Release/OGLWrapper.o obj/Release/Point.o -lz -lGLEW -lGL -lglut -o bin/Release/Register3D_wx
obj/Release/ICP.o: In function `ICP::SetPoints(std::vector<Point, std::allocator<Point> >&, std::vector<Point, std::allocator<Point> >&, float)':
ICP.cc:(.text+0x38c): undefined reference to `wxStringBase::npos'
ICP.cc:(.text+0x3a4): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned long, unsigned long)'
ICP.cc:(.text+0x49a): undefined reference to `wxString::Format(wchar_t const*, ...)'
ICP.cc:(.text+0x593): undefined reference to `wxStringBase::npos'
ICP.cc:(.text+0x5ab): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned long, unsigned long)'
ICP.cc:(.text+0x614): undefined reference to `wxString::Format(wchar_t const*, ...)'
ICP.cc:(.text+0x6d9): undefined reference to `wxStringBase::npos'
ICP.cc:(.text+0x6f1): undefined reference to `wxStringBase::InitWith(wchar_t const*, unsigned long, unsigned long)'
ICP.cc:(.text+0x7da): undefined reference to `wxString::Format(wchar_t const*, ...)'
I know I need to edit the Makefile but that's where I am stuck. I do have some experience with makesfiles but don't know what to do. Moreover, all the dependencies are are complied and the object files produced so I don't know why ICP.cc is having this undefined reference error. The makefile is:
#------------------------------------------------------------------------------#
# This makefile was generated by 'cbp2make' tool rev.107 #
#------------------------------------------------------------------------------#
WRKDIR = `pwd`
CC = gcc
CXX = g++
AR = ar
LD = g++
WINDRES = windres
INC = -Iann_1.1.2/include
CFLAGS =
RESINC =
LIBDIR = -Lann_1.1.2/include
LIB =
LDFLAGS =
INC_RELEASE = $(INC)
CFLAGS_RELEASE = $(CFLAGS) -O2 -Wall `wx-config --cflags` `gsl-config --cflags`
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB) -lz -lGLEW -lGL -lglut
LDFLAGS_RELEASE = $(LDFLAGS) -s `wx-config --libs` `wx-config --libs gl` `gsl-config --libs`
OBJDIR_RELEASE = obj/Release
DEP_RELEASE =
OUT_RELEASE = bin/Release/Register3D_wx
OBJ_RELEASE = $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_pr_search.o $(OBJDIR_RELEASE)/ZPR.o $(OBJDIR_RELEASE)/ann_1.1.2/src/ANN.o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_fix_rad_search.o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_pr_search.o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_search.o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_tree.o $(OBJDIR_RELEASE)/ann_1.1.2/src/brute.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_dump.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_fix_rad_search.o $(OBJDIR_RELEASE)/PointOP.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_search.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_split.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_tree.o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_util.o $(OBJDIR_RELEASE)/ann_1.1.2/src/perf.o $(OBJDIR_RELEASE)/main.o $(OBJDIR_RELEASE)/MainWindow.o $(OBJDIR_RELEASE)/Cylinder.o $(OBJDIR_RELEASE)/GLCanvas.o $(OBJDIR_RELEASE)/Help.o $(OBJDIR_RELEASE)/ICP.o $(OBJDIR_RELEASE)/ICPDialog.o $(OBJDIR_RELEASE)/About.o $(OBJDIR_RELEASE)/Math2.o $(OBJDIR_RELEASE)/Matrix.o $(OBJDIR_RELEASE)/Misc.o $(OBJDIR_RELEASE)/MyANN.o $(OBJDIR_RELEASE)/OGLWrapper.o $(OBJDIR_RELEASE)/Point.o
all: Release
clean: clean_Release
before_Release:
test -d bin/Release || mkdir -p bin/Release
test -d $(OBJDIR_RELEASE)/ann_1.1.2/src || mkdir -p $(OBJDIR_RELEASE)/ann_1.1.2/src
test -d $(OBJDIR_RELEASE)/ || mkdir -p $(OBJDIR_RELEASE)/
after_Release:
Release: before_Release out_Release after_Release
out_Release: $(OBJ_RELEASE) $(DEP_RELEASE)
$(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE)
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_pr_search.o: ann_1.1.2/src/kd_pr_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_pr_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_pr_search.o
$(OBJDIR_RELEASE)/ZPR.o: ZPR.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ZPR.cc -o $(OBJDIR_RELEASE)/ZPR.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/ANN.o: ann_1.1.2/src/ANN.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/ANN.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/ANN.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/bd_fix_rad_search.o: ann_1.1.2/src/bd_fix_rad_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/bd_fix_rad_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_fix_rad_search.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/bd_pr_search.o: ann_1.1.2/src/bd_pr_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/bd_pr_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_pr_search.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/bd_search.o: ann_1.1.2/src/bd_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/bd_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_search.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/bd_tree.o: ann_1.1.2/src/bd_tree.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/bd_tree.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/bd_tree.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/brute.o: ann_1.1.2/src/brute.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/brute.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/brute.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_dump.o: ann_1.1.2/src/kd_dump.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_dump.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_dump.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_fix_rad_search.o: ann_1.1.2/src/kd_fix_rad_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_fix_rad_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_fix_rad_search.o
$(OBJDIR_RELEASE)/PointOP.o: PointOP.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c PointOP.cc -o $(OBJDIR_RELEASE)/PointOP.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_search.o: ann_1.1.2/src/kd_search.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_search.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_search.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_split.o: ann_1.1.2/src/kd_split.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_split.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_split.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_tree.o: ann_1.1.2/src/kd_tree.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_tree.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_tree.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/kd_util.o: ann_1.1.2/src/kd_util.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/kd_util.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/kd_util.o
$(OBJDIR_RELEASE)/ann_1.1.2/src/perf.o: ann_1.1.2/src/perf.cpp
$(CXX) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ann_1.1.2/src/perf.cpp -o $(OBJDIR_RELEASE)/ann_1.1.2/src/perf.o
$(OBJDIR_RELEASE)/main.o: main.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c main.cc -o $(OBJDIR_RELEASE)/main.o
$(OBJDIR_RELEASE)/MainWindow.o: MainWindow.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c MainWindow.cc -o $(OBJDIR_RELEASE)/MainWindow.o
$(OBJDIR_RELEASE)/Cylinder.o: Cylinder.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Cylinder.cc -o $(OBJDIR_RELEASE)/Cylinder.o
$(OBJDIR_RELEASE)/GLCanvas.o: GLCanvas.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c GLCanvas.cc -o $(OBJDIR_RELEASE)/GLCanvas.o
$(OBJDIR_RELEASE)/Help.o: Help.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Help.cc -o $(OBJDIR_RELEASE)/Help.o
$(OBJDIR_RELEASE)/ICP.o: ICP.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ICP.cc -o $(OBJDIR_RELEASE)/ICP.o
$(OBJDIR_RELEASE)/ICPDialog.o: ICPDialog.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c ICPDialog.cc -o $(OBJDIR_RELEASE)/ICPDialog.o
$(OBJDIR_RELEASE)/About.o: About.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c About.cc -o $(OBJDIR_RELEASE)/About.o
$(OBJDIR_RELEASE)/Math2.o: Math2.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Math2.cc -o $(OBJDIR_RELEASE)/Math2.o
$(OBJDIR_RELEASE)/Matrix.o: Matrix.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Matrix.cc -o $(OBJDIR_RELEASE)/Matrix.o
$(OBJDIR_RELEASE)/Misc.o: Misc.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Misc.cc -o $(OBJDIR_RELEASE)/Misc.o
$(OBJDIR_RELEASE)/MyANN.o: MyANN.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c MyANN.cc -o $(OBJDIR_RELEASE)/MyANN.o
$(OBJDIR_RELEASE)/OGLWrapper.o: OGLWrapper.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c OGLWrapper.cc -o $(OBJDIR_RELEASE)/OGLWrapper.o
$(OBJDIR_RELEASE)/Point.o: Point.cc
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c Point.cc -o $(OBJDIR_RELEASE)/Point.o
clean_Release:
rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
rm -rf $(OBJDIR_RELEASE)/ann_1.1.2/src
rm -rf $(OBJDIR_RELEASE)/
.PHONY: before_Release after_Release clean_Release
I see two potential problems here:
You should use wx-config --libs std,gl to link with all normal wxWidgets libraries and wxWidgets OpenGL library instead of just the latter.
You should ensure that in your link command LDFLAGS_RELEASE comes after the object files, this is important if you're using static wxWidgets libraries.
I'm getting errors when trying to run the HTTP server example that comes with the source of the boost library, under the path: boost_1_59_0/libs/asio/example/cpp11/http/server/.
I already ran this following commands in the boost_1_59_0 directory:
$ ./bootstrap.sh
$ sudo ./bjam install
$ sudo ./b2 install
After installing all targets, i tried to compile the main.cpp and the server.cpp with this command: g++ -std=c++0x -o main main.cpp -I "/home/user/Desktop/boost_1_59_0" -L "/home/user/Desktop/boost_1_59_0/libs/" -lboost_system.
Any suggestion on how to compile this server example?
I linked all files from the boost_1_59_0/libs/asio/example/cpp11/http/server/ folder after the main.cpp, as #Richard Hodges suggested. It still didn't work, i got errors concerning lpthread, so i added it to the compiling options. The program compiled but it failed the execution, returning an error saying that it didn't find the library libboost_system.so.1.59.0. I tried linking the folders with -L /path/to/library but it didn't work.
Solution:
My compilation command:
g++ -std=gnu++0x -o main main.cpp server.cpp connection.cpp connection_manager.cpp reply.cpp mime_types.cpp request_handler.cpp request_parser.cpp -I "/home/user/Desktop/boost_1_59_0" -lboost_system -lpthread
I solved it with this commands:
$ LD_LIBRARY_PATH="/usr/local/lib/"
$ sudo ldconfig
And then I just ran the executable and it worked!
Here's a simple makefile I just concocted that works:
all:server
CPPFLAGS+=-std=c++11 -Wall -pedantic
CPPFLAGS+=-g -O2
CPPFLAGS+=-pthread
LDFLAGS+=-lboost_system
%.o:%.cpp
$(CXX) $(CPPFLAGS) $^ -c -o $#
server:$(patsubst %.cpp,%.o,$(wildcard *.cpp))
$(CXX) $(CPPFLAGS) $^ -o $# $(LDFLAGS)
It runs make:
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread connection.cpp -c -o connection.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread connection_manager.cpp -c -o connection_manager.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread main.cpp -c -o main.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread mime_types.cpp -c -o mime_types.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread reply.cpp -c -o reply.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread request_handler.cpp -c -o request_handler.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread request_parser.cpp -c -o request_parser.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread server.cpp -c -o server.o
g++ -std=c++11 -Wall -pedantic -g -O2 -pthread connection.o connection_manager.o main.o mime_types.o reply.o request_handler.o request_parser.o server.o -o server -lboost_system
And the test program runs:
$ ./server 0.0.0.0 9889 . &
$ GET http://localhost:9889/main.cpp > main.cpp.0
Check the files
$ md5sum main.cpp*
be5dc1c26b5942101a7895de6baedcee main.cpp
be5dc1c26b5942101a7895de6baedcee main.cpp.0
Don't forget to kill the server when you're done
Following makefile works except cleaning the object files after compiling and linking. I tried make clean which does exactly what I want: deletes the executable and the object files in all folders. I also included the outputs of make and make clean. Any idea?
Makefile:
CC=g++
CFLAGS=-c -std=c++11 -O2 -O3
SOURCES=main.cpp\
BoundaryConditions/BoundaryConditions.cpp\
Cell/Cell.cpp\
Face/Face.cpp\
Formulation/Explicit/Explicit.cpp\
Formulation/Implicit/Implicit.cpp\
Grid/Grid.cpp\
Grid/ReadGrid.cpp\
Grid/SetGrid.cpp\
Init/Init.cpp\
InterFlux/Interflux.cpp\
InterFlux/Roe/Roe.cpp\
Matrix5/Operators.cpp\
Output/Output.cpp\
Solver/GaussSeidel.cpp\
Vector/Vector.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=codeBaku
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $#
.cpp.o:
$(CC) $(CFLAGS) $< -o $#
.PHONY: clean
clean:
rm -rf $(OBJECTS) $(EXECUTABLE)
Output of make:
g++ -c -std=c++11 -O2 -O3 main.cpp -o main.o
g++ -c -std=c++11 -O2 -O3 BoundaryConditions/BoundaryConditions.cpp -o BoundaryConditions/BoundaryConditions.o
g++ -c -std=c++11 -O2 -O3 Cell/Cell.cpp -o Cell/Cell.o
g++ -c -std=c++11 -O2 -O3 Face/Face.cpp -o Face/Face.o
g++ -c -std=c++11 -O2 -O3 Formulation/Explicit/Explicit.cpp -o Formulation/Explicit/Explicit.o
g++ -c -std=c++11 -O2 -O3 Formulation/Implicit/Implicit.cpp -o Formulation/Implicit/Implicit.o
g++ -c -std=c++11 -O2 -O3 Grid/Grid.cpp -o Grid/Grid.o
g++ -c -std=c++11 -O2 -O3 Grid/ReadGrid.cpp -o Grid/ReadGrid.o
g++ -c -std=c++11 -O2 -O3 Grid/SetGrid.cpp -o Grid/SetGrid.o
g++ -c -std=c++11 -O2 -O3 Init/Init.cpp -o Init/Init.o
g++ -c -std=c++11 -O2 -O3 InterFlux/Interflux.cpp -o InterFlux/Interflux.o
g++ -c -std=c++11 -O2 -O3 InterFlux/Roe/Roe.cpp -o InterFlux/Roe/Roe.o
g++ -c -std=c++11 -O2 -O3 Matrix5/Operators.cpp -o Matrix5/Operators.o
g++ -c -std=c++11 -O2 -O3 Output/Output.cpp -o Output/Output.o
g++ -c -std=c++11 -O2 -O3 Solver/GaussSeidel.cpp -o Solver/GaussSeidel.o
g++ -c -std=c++11 -O2 -O3 Vector/Vector.cpp -o Vector/Vector.o
g++ main.o BoundaryConditions/BoundaryConditions.o Cell/Cell.o Face/Face.o Formulation/Explicit/Explicit.o Formulation/Implicit/Implicit.o Grid/Grid.o Grid/ReadGrid.o Grid/SetGrid.o Init/Init.o InterFlux/Interflux.o InterFlux/Roe/Roe.o Matrix5/Operators.o Output/Output.o Solver/GaussSeidel.o Vector/Vector.o -o codeBaku
Output of make clean:
rm -rf main.o BoundaryConditions/BoundaryConditions.o Cell/Cell.o Face/Face.o Formulation/Explicit/Explicit.o Formulation/Implicit/Implicit.o Grid/Grid.o Grid/ReadGrid.o Grid/SetGrid.o Init/Init.o InterFlux/Interflux.o InterFlux/Roe/Roe.o Matrix5/Operators.o Output/Output.o Solver/GaussSeidel.o Vector/Vector.o codeBaku
It is unusual to automatically remove the object files, since that would mean everything would have to be recompiled each time, even if you only change one source file. However, if you really want to do it, you could do something like this:
all: $(SOURCES) $(EXECUTABLE)
rm $(OBJECTS)
I am making a makefile and one of the targets is exptrtest.o how do I use g++ to create an objectfile with that name, the name of my cpp file is exprtest.cpp not exptrtest.cpp?
exptrtest.o: exprtest.cpp
g++ -Wall -g -c exprtest.cpp
to make it more clear, this is my makefile:
all: exprtest
exprtest: exptrtest.o driver.o parser.tab.o scanner.o
g++ -Wall -g -o exprtest exptrtest.o driver.o parser.tab.o scanner.o
exptrtest.o: exprtest.cpp
g++ -Wall -g -c exptrtest.o exprtest.cpp
driver.o: driver.cpp scanner.hpp driver.hpp
g++ -Wall -g -c driver.cpp
parser.tab.o: parser.tab.hpp parser.tab.cpp
bison parser.ypp
g++ -Wall -g -c parser.tab.cpp
scanner.o: scanner.cpp scanner.hpp
flex -t scanner.ll > scanner.cpp
g++ -Wall -g -c scanner.cpp
clean:
rm parser.tab.hpp parser.tab.cpp scanner.cpp
I'm getting the error:
"g++: error: exptrtest.o: No such file or directory
make: * [exprtest] Error 1"
Use the -o option in conjunction with -c.
exptrtest.o: exprtest.cpp
g++ -Wall -g -c exprtest.cpp -o exptrtest.o