c++ - How to compile dlib under make with multiple files? -


recently i've been trying add dlib library project (i interested in mpc part since want control quadrocopter), despite many different approaches couldn't find proper working solution. have makefile this:

all : quadro_mini cxxflags = -std=c++11 -lpthread -o3 #-wall -pedantic libraries = -impu6050 -lmpu6050 -ihcsr04 -lhcsr04  objs = steer.o measurer.o logwriter.o server.o functions.o engine.o enginesmanager.o main.o  hdrs = server.h measurer.h logwriter.h functions.h steeringsignalslistener.h engine.h enginesmanager.h constants.h steer.h   $(objs) : $(hdrs)   quadro_mini : $(objs)     g++ -pthread $^ $(libraries) -lmpu6050 -lhcsr04 -dlib_no_gui_support -o $@ 

i want use dlib in steer.o module

first approach
linking header containing necessary includes

objs = measurer.o logwriter.o server.o functions.o engine.o enginesmanager.o main.o dlib/control.o #nazwy sie musza zgadzac z nazwami *.cpp *.h hdrs = server.h measurer.h logwriter.h functions.h steeringsignalslistener.h engine.h enginesmanager.h constants.h steer.h   $(objs) : $(hdrs)   steer.o : $(hdrs)    g++ $(cxxflags) $^ $(libraries) -i. dlib/control.h -o $@ quadro_mini : $(objs) steer.o     g++ -pthread $^ $(libraries) -lmpu6050 -lhcsr04 -dlib_no_gui_support -o $@ 

the output receive:

in file included dlib/control/../matrix/matrix_exp.h:6:0,              dlib/control/../matrix/matrix.h:6,              dlib/control/../matrix.h:6,              dlib/control/approximate_linear_models.h:7,              dlib/control/lspi.h:7,              dlib/control.h:6,              steer.h:10: dlib/control/../matrix/../algs.h:146:9: error: expected identifier before numeric constant dlib/control/../matrix/../algs.h:146:9: error: expected '}' before numeric constant dlib/control/../matrix/../algs.h:146:9: error: expected unqualified-id before numeric constant dlib/control/../matrix/../algs.h:495:14: error: expected nested-name-specifier before 'disable_if_c' dlib/control/../matrix/../algs.h:495:26: error: expected initializer before '<' token dlib/control/../matrix/../algs.h:510:14: error: expected nested-name-specifier before 'enable_if_c' dlib/control/../matrix/../algs.h:510:25: error: expected initializer before '<' token dlib/control/../matrix/../algs.h:627:48: error: 'uint64' not declared in scope dlib/control/../matrix/../algs.h:627:48: note: suggested alternative: 

etc.

second aproach:
making library out of

all: dlib.a  cxxflags = -wall -g -std=c++11 -pthread -dlib_no_gui_support  dlib.o : control.h     g++ $(cxxflags) -c $^ -o $@   dlib.a: dlib.o     ar -rv $@ $^ 

but since header in dlib header should include ? none... since official page forbids adding compiler's include path. approach still doesn't work... info - compile artifacts take on 60 mb.

third approach
adding folder contains dlib folder include search path , use include statements of form #include (dlib official statement).

cplus_include_path=/home/linaro/quadrocopter/dlib export cplus_include_path 

also

cplus_include_path=/home/linaro/quadrocopter/ export cplus_include_path 

first gives:

/home/linaro/quadrocopter/dlib/dlib_include_path_tutorial.txt:1:2: error: #error "don't put dlib folder in include path" 

etc.
second has similar effect first approach

i've created test build 2 compilation artifacts:

all : test cxxflags = -g -o3 -std=c++11 lflags = -lpthread -lnsl   objs = maintest.o logwriter.o hdrs = logwriter.h constants.h  $(objs) : $(hdrs)  test : $(objs)      g++ -pthread -idlib/control.h $^ -o $@ 

and working ! yet cannot previous makefile

anyone please me ? (and no -ldlib not working)

environment: custom lubuntu, gcc version 4.7.2, gnu make 3.81

let proceed in small steps. try this, , tell result:

hdrs = server.h measurer.h logwriter.h functions.h steeringsignalslistener.h engine.h enginesmanager.h constants.h steer.h  measurer.o : measurer.cpp $(hdrs)      g++ $(cxxflags) $< -i. -o $@ 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -