From 27a7faa0ba95461788f33ddbb2f1fc28facb8e00 Mon Sep 17 00:00:00 2001 From: "simon.fanetti" <simon.fanetti@etu.hesge.ch> Date: Fri, 13 Mar 2020 14:31:44 +0100 Subject: [PATCH] adjust to shared object lib --- Makefile | 25 +++++++++++++++------ export.sh | 4 ++++ {lib/components => includes}/beamer.h | 1 + {lib/tools => includes}/borderedit.h | 0 {lib/tools => includes}/borderfinder.h | 0 {lib/components => includes}/calibrate.h | 0 {lib/components => includes}/camera.h | 0 {lib => includes}/controller.h | 16 +++++++------ {lib/tools => includes}/log.h | 0 sandbox.h => includes/sandbox.h | 8 ++++--- sandbox_setup.h => includes/sandbox_setup.h | 0 sandbox.cpp | 2 +- {lib => src}/Makefile | 2 +- {lib => src}/common.mk | 2 ++ {lib => src}/components/Makefile | 2 +- {lib => src}/components/beamer.cpp | 2 +- {lib => src}/components/calibrate.cpp | 4 ++-- {lib => src}/components/camera.cpp | 2 +- {lib => src}/controller.cpp | 2 +- {lib => src}/tools/Makefile | 0 {lib => src}/tools/borderedit.cpp | 2 +- {lib => src}/tools/borderfinder.cpp | 2 +- {lib => src}/tools/log.c | 2 +- 23 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 export.sh rename {lib/components => includes}/beamer.h (99%) rename {lib/tools => includes}/borderedit.h (100%) rename {lib/tools => includes}/borderfinder.h (100%) rename {lib/components => includes}/calibrate.h (100%) rename {lib/components => includes}/camera.h (100%) rename {lib => includes}/controller.h (87%) rename {lib/tools => includes}/log.h (100%) rename sandbox.h => includes/sandbox.h (74%) rename sandbox_setup.h => includes/sandbox_setup.h (100%) rename {lib => src}/Makefile (85%) rename {lib => src}/common.mk (74%) rename {lib => src}/components/Makefile (88%) rename {lib => src}/components/beamer.cpp (99%) rename {lib => src}/components/calibrate.cpp (97%) rename {lib => src}/components/camera.cpp (99%) rename {lib => src}/controller.cpp (99%) rename {lib => src}/tools/Makefile (100%) rename {lib => src}/tools/borderedit.cpp (98%) rename {lib => src}/tools/borderfinder.cpp (98%) rename {lib => src}/tools/log.c (97%) diff --git a/Makefile b/Makefile index 9cbae54..1becae4 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,34 @@ -include ./lib/common.mk +include src/common.mk SRCS=$(wildcard ./*.cpp) OBJS=$(SRCS:%.cpp=%.o) OBJSALL=$(shell find . -name '*.o') +LIBNAME=libsandbox +LIB_MINOR_VERS=0.0 +LIB_MAJOR_VERS=1 +LIB_VERS=$(LIB_MAJOR_VERS).$(LIB_MINOR_VERS) +LIB_FULL_NAME=$(LIBNAME).so.$(LIB_VERS) +path=$(shell pwd) +ld_libs=$(shell echo $$LD_LIBRARY_PATH) all: - $(MAKE) -C lib + $(MAKE) -C src $(MAKE) build -C . $(MAKE) pack -C . +# $(MAKE) link -C . build: $(OBJS) %.o: %.cpp - g++ -c $(CFLAGS) $(OPENCVFLAG) $< -o $@ + $(CCP) -c $(CFLAGS) $< -o $@ -# manque tout les autres fichiers .o pack: - gcc -shared $(OBJSALL) $(CFLAGS) $(OPENCVFLAG) -lrealsense2 -o ./libsandbox.so + gcc -shared -Wl,-soname,$(LIB_FULL_NAME) $(OBJSALL) -o $(LIB_FULL_NAME) + +link: + -ln -s $(LIB_FULL_NAME) $(LIBNAME).so.$(LIB_MAJOR_VERS) + -ln -s $(LIB_FULL_NAME) $(LIBNAME).so clean: - -rm -f *.o *.so - $(MAKE) clean -C lib + -rm -f *.o *.so* + $(MAKE) clean -C src diff --git a/export.sh b/export.sh new file mode 100644 index 0000000..3a1d7cc --- /dev/null +++ b/export.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=$(pwd) && \ +make link diff --git a/lib/components/beamer.h b/includes/beamer.h similarity index 99% rename from lib/components/beamer.h rename to includes/beamer.h index 0a5f4ca..6d24dab 100644 --- a/lib/components/beamer.h +++ b/includes/beamer.h @@ -2,6 +2,7 @@ #define BEAMER_H #include <opencv2/opencv.hpp> #include "camera.h" + class Beamer { diff --git a/lib/tools/borderedit.h b/includes/borderedit.h similarity index 100% rename from lib/tools/borderedit.h rename to includes/borderedit.h diff --git a/lib/tools/borderfinder.h b/includes/borderfinder.h similarity index 100% rename from lib/tools/borderfinder.h rename to includes/borderfinder.h diff --git a/lib/components/calibrate.h b/includes/calibrate.h similarity index 100% rename from lib/components/calibrate.h rename to includes/calibrate.h diff --git a/lib/components/camera.h b/includes/camera.h similarity index 100% rename from lib/components/camera.h rename to includes/camera.h diff --git a/lib/controller.h b/includes/controller.h similarity index 87% rename from lib/controller.h rename to includes/controller.h index 0c87a9f..b37c8f0 100644 --- a/lib/controller.h +++ b/includes/controller.h @@ -1,13 +1,15 @@ #ifndef CONTROLLER_H #define CONTROLLER_H -#include "./components/camera.h" -#include "./components/calibrate.h" -#include "./components/beamer.h" -#include "./tools/borderedit.h" -#include "./tools/borderfinder.h" +#include <opencv2/opencv.hpp> +#include "camera.h" +#include "calibrate.h" +#include "beamer.h" +#include "borderedit.h" +#include "borderfinder.h" -class Controller{ +class Controller +{ public: Controller(); cv::Mat getRGBFrame(); @@ -42,4 +44,4 @@ class Controller{ }; -#endif \ No newline at end of file +#endif diff --git a/lib/tools/log.h b/includes/log.h similarity index 100% rename from lib/tools/log.h rename to includes/log.h diff --git a/sandbox.h b/includes/sandbox.h similarity index 74% rename from sandbox.h rename to includes/sandbox.h index ca8cfce..6e13e83 100644 --- a/sandbox.h +++ b/includes/sandbox.h @@ -1,9 +1,11 @@ #ifndef SANDBOX_H #define SANDBOX_H -#include "./lib/controller.h" +#include <opencv2/opencv.hpp> +#include "controller.h" -class Sandbox{ +class Sandbox +{ public: Sandbox(); cv::Mat getRGBFrame(); @@ -13,4 +15,4 @@ class Sandbox{ private: Controller controller; }; -#endif \ No newline at end of file +#endif diff --git a/sandbox_setup.h b/includes/sandbox_setup.h similarity index 100% rename from sandbox_setup.h rename to includes/sandbox_setup.h diff --git a/sandbox.cpp b/sandbox.cpp index cf2a7db..48d31da 100644 --- a/sandbox.cpp +++ b/sandbox.cpp @@ -1,4 +1,4 @@ -#include "./sandbox.h" +#include "includes/sandbox.h" Sandbox::Sandbox(){ //controller = Controller(); diff --git a/lib/Makefile b/src/Makefile similarity index 85% rename from lib/Makefile rename to src/Makefile index c6661fd..4e098e6 100644 --- a/lib/Makefile +++ b/src/Makefile @@ -11,7 +11,7 @@ all: build: $(OBJS) %.o: %.cpp - g++ $(CFLAGS) $(OPENCVFLAG) -c $< -o $@ + g++ $(CFLAGS) -c $< -o $@ clean: -rm -f *.o diff --git a/lib/common.mk b/src/common.mk similarity index 74% rename from lib/common.mk rename to src/common.mk index 07b1dcb..dab528a 100644 --- a/lib/common.mk +++ b/src/common.mk @@ -1,2 +1,4 @@ +CCP=g++ CFLAGS=-std=c++11 -Wall -Wextra -g -Ilib -fPIC OPENCVFLAG=`pkg-config --libs --cflags opencv` +CAMERAFLAG=-lrealsense2 diff --git a/lib/components/Makefile b/src/components/Makefile similarity index 88% rename from lib/components/Makefile rename to src/components/Makefile index bc18834..579a1bf 100644 --- a/lib/components/Makefile +++ b/src/components/Makefile @@ -6,7 +6,7 @@ CAMERAFLAG=-lrealsense2 build: $(OBJS) -camera.o: camera.cpp camera.h +camera.o: camera.cpp g++ -c $(CFLAGS) $(OPENCVFLAG) $(CAMERAFLAG) $< -o $@ %.o: %.cpp diff --git a/lib/components/beamer.cpp b/src/components/beamer.cpp similarity index 99% rename from lib/components/beamer.cpp rename to src/components/beamer.cpp index cccc64c..d953e6c 100644 --- a/lib/components/beamer.cpp +++ b/src/components/beamer.cpp @@ -1,4 +1,4 @@ -#include "beamer.h" +#include "../../includes/beamer.h" using namespace cv; using namespace std; diff --git a/lib/components/calibrate.cpp b/src/components/calibrate.cpp similarity index 97% rename from lib/components/calibrate.cpp rename to src/components/calibrate.cpp index 19f017a..3b5935f 100644 --- a/lib/components/calibrate.cpp +++ b/src/components/calibrate.cpp @@ -1,5 +1,5 @@ -#include "calibrate.h" -#include "camera.h" +#include "../../includes/calibrate.h" +#include "../../includes/camera.h" using namespace cv; using namespace std; diff --git a/lib/components/camera.cpp b/src/components/camera.cpp similarity index 99% rename from lib/components/camera.cpp rename to src/components/camera.cpp index ad64a81..423fae0 100644 --- a/lib/components/camera.cpp +++ b/src/components/camera.cpp @@ -1,4 +1,4 @@ -#include "camera.h" +#include "../../includes/camera.h" using namespace cv; Camera::Camera() {} diff --git a/lib/controller.cpp b/src/controller.cpp similarity index 99% rename from lib/controller.cpp rename to src/controller.cpp index 189acf0..1a9e6bb 100644 --- a/lib/controller.cpp +++ b/src/controller.cpp @@ -1,4 +1,4 @@ -#include "./controller.h" +#include "../includes/controller.h" #include <numeric> #include <fstream> #include <string> diff --git a/lib/tools/Makefile b/src/tools/Makefile similarity index 100% rename from lib/tools/Makefile rename to src/tools/Makefile diff --git a/lib/tools/borderedit.cpp b/src/tools/borderedit.cpp similarity index 98% rename from lib/tools/borderedit.cpp rename to src/tools/borderedit.cpp index 0d14066..0dba3fc 100644 --- a/lib/tools/borderedit.cpp +++ b/src/tools/borderedit.cpp @@ -1,5 +1,5 @@ #include <algorithm> -#include "borderedit.h" +#include "../../includes/borderedit.h" using namespace std; using namespace cv; diff --git a/lib/tools/borderfinder.cpp b/src/tools/borderfinder.cpp similarity index 98% rename from lib/tools/borderfinder.cpp rename to src/tools/borderfinder.cpp index bede005..ba80000 100644 --- a/lib/tools/borderfinder.cpp +++ b/src/tools/borderfinder.cpp @@ -1,5 +1,5 @@ #include <algorithm> -#include "borderfinder.h" +#include "../../includes/borderfinder.h" using namespace std; using namespace cv; diff --git a/lib/tools/log.c b/src/tools/log.c similarity index 97% rename from lib/tools/log.c rename to src/tools/log.c index daa9e51..6c7cab5 100644 --- a/lib/tools/log.c +++ b/src/tools/log.c @@ -3,7 +3,7 @@ #include <unistd.h> #include <strings.h> #include <stdarg.h> -#include "log.h" +#include "../../includes/log.h" -- GitLab