2020/10/8

Makefile for building served liked program

要使用cross build 好的 served library 的話,要指定 boost library 和 served lib/include path。

先找出 CMake build example 的 build command..

把CMakeLists.txt 的 VERBOSE 打開。make 一次,然後 touch hello_world/main.cpp 再 make 一次。找出 make command:
/usr/local/linaro-aarch64-2018.08-gcc8.2/bin/aarch64-linux-gnu-g++   
-I/home/charles-chang/githubgitlab/served/src 
-I/tmp/boost/include  
-std=c++11 -Wall -pedantic -Wextra -Wno-missing-field-initializers   
-o CMakeFiles/eg_hello_world.dir/main.cpp.o 
-c /home/charles-chang/githubgitlab/served/src/examples/hello_world/main.cpp



/usr/local/linaro-aarch64-2018.08-gcc8.2/bin/aarch64-linux-gnu-g++   
-std=c++11 -Wall -pedantic -Wextra -Wno-missing-field-initializers  -rdynamic 
CMakeFiles/eg_hello_world.dir/main.cpp.o  
-o /home/charles-chang/githubgitlab/served/bin/eg_hello_world  
-L/tmp/boost/lib 
-Wl,-rpath,/tmp/boost/lib:/home/charles-chang/githubgitlab/served/lib: /home/charles-chang/githubgitlab/served/lib/libserved.so.1.4 /tmp/boost/lib/libboost_system.so 
-lpthread 
分別是 compile 和 link

所以 Makefile...
CC=aarch64-linux-gnu-g++
CFLAGS=-I/home/charles-chang/githubgitlab/served/src -I/tmp/boost/include -std=c++11 -Wall -pedantic -Wextra -Wno-missing-field-initializers
LDFLAGS=-std=c++11 -Wall -pedantic -Wextra -Wno-missing-field-initializers -rdynamic
LLIBS=-L/tmp/boost/lib -Wl,-rpath,/tmp/boost/lib:/home/charles-chang/githubgitlab/served/lib: /home/charles-chang/githubgitlab/served/lib/libserved.so.1.4 /tmp/boost/lib/libboost_system.so -lpthread


%.o: %.cpp
    $(CC) $(CFLAGS) -c -o $@ $< 


hello_world: main.o
    $(CC) $(LDFLAGS) -o $@ $^ $(LLIBS)

沒有留言:

張貼留言