浅析OpenNI2---Build System 与KDE

本文介绍了OpenNI2的构建系统,详细解析了其Makefile结构,并探讨了Linux下的KDE集成开发环境的使用方法,包括KDE的安装、OpenNI2项目的导入与配置,以及如何在KDE中进行编译和调试。
摘要由CSDN通过智能技术生成

Build system 与KDE

上一篇已经介绍到直接采用make就可以编译OpenNI2,这篇文章主要介绍下OpenNI2的makefile文件以及Linux下KDE集成开发环境的使用;
.
├── Makefile
├── Samples
│ ├── SimpleRead
│ │ └── Makefile
│ └── SimpleViewer
│ … └── Makefile
├── Source
│ ├── Core
│ │ └── Makefile
│ └── Drivers
│ … ├── DummyDevice
│ … │ └── Makefile
│ … ├── Kinect
│ … ├── OniFile
│ … │ └── Makefile
│ … ├── PS1080
│ … │ └── Makefile
│ … └── PSLink
│ … … └── Makefile
└── ThirdParty
… └── PSCommon
… ├── BuildSystem
… … ├── CommonCppMakefile
… … ├── CommonCSMakefile
… … ├── CommonDefs.mak
… … ├── CommonJavaMakefile
… … ├── CommonTargets.mak
… … ├── Platform.Arm
… … ├── Platform.x64
… … └── Platform.x86

顶层Makefile用于编译整个工程暂时先不去分析,我们先看下Sample目录下的Makefile

# SimpleViewer Makefile
include ../../ThirdParty/PSCommon/BuildSystem/CommonDefs.mak

BIN_DIR = ../../Bin
INC_DIRS = \
    ../../Include \
    ../../ThirdParty/GL/ \
    ../Common

SRC_FILES = *.cpp

ifeq ("$(OSTYPE)","Darwin")
    CFLAGS += -DMACOS
    LDFLAGS += -framework OpenGL -framework GLUT
else
    CFLAGS += -DUNIX -DGLX_GLXEXT_LEGACY
    USED_LIBS += glut GL
endif

USED_LIBS += OpenNI2

EXE_NAME = SimpleViewer

CFLAGS += -Wall

include ../../ThirdParty/PSCommon/BuildSystem/CommonCppMakefile

上面的各个变量都显而易见
- INC_DIRS 为头件目录
- SRC_FILES为源文件
- USED_LIBS为编译时需要链接的库
- EXE_NAME为生成可执行文件的名称
该文件主要定义EXE_NAME来表示该文件用于生成可执行文件,下面我们来看看CommonDefs.mak与CommonCppMakefile

# CommonDefs.mak
ifndef _COMMON_DEFS_MAKE_
_COMMON_DEFS_MAKE_=1

# some defaults
ifndef CFG
    CFG = Release
endif

# find out the platform on which we're running
MACHINE = $(shell uname -m)
ifneq (,$(findstring x86_64,$(MACHINE)))
    HOST_PLATFORM = x64
else ifneq (,$(findstring x86,$(MACHINE)))
    HOST_PLATFORM = x86
else ifneq (,$(findstring i686,$(MACHINE)))
    HOST_PLATFORM = x86
else ifneq (,$(findstring i386,$(MACHINE)))
    HOST_PLATFORM = x86
else ifneq (,$(findstring arm,$(MACHINE)))
    HOST_PLATFORM = Arm
else
    DUMMY:=$(error Can't determine host platform)
endif

# now check if this is a cross-compilation or not
ifeq "$(PLATFORM)" ""
    PLATFORM = $(HOST_PLATFORM)
else
    ifneq "$(PLATFORM)" "$(HOST_PLATFORM)"
        # cross compiling. Take CXX and STAGING_DIR from environment
        PLATFORM_UPPER = $(shell echo $(PLATFORM) | tr 'a-z' 'A-Z')
        DUMMY:=$(eval CXX = $($(PLATFORM_UPPER)_CXX))
        DUMMY:=$(eval TARGET_SYS_ROOT = $($(PLATFORM_UPPER)_STAGING))

        ifeq "$(and $(CXX), $(TARGET_SYS_ROOT))" ""
            DUMMY:=$(error Cross-Compilation error. Can't find $(PLATFORM_UPPER)_CXX and $(PLATFORM_UPPER)_STAGING)
        endif
    endif
endif

# expand file list
SRC_FILES_LIST = $(wildcard $(SRC_FILES))

# define the intermediate directory
INT_DIR = $(BIN_DIR)/Intermediate/$(PLATFORM)-$(CFG)/$(OUTPUT_NAME)

# define output directory
OUT_DIR = $(BIN_DIR)/$(PLATFORM)-$(CFG)

# full path to output file
OUTPUT_FILE = $(OUT_DIR)/$(OUTPUT_NAME)

# take this file's dir
COMMON_MAK_DIR = $(dir $(lastword $(MAKEFILE_LIST)))

# get the OS type
OSTYPE := $(shell uname -s)

# platform specific args
include $(COMMON_MAK_DIR)Platform.$(PLATFORM)

endif # _COMMON_DEFS_MAKE_
# CommonCppMakefile
#############################################################################
# Primesense template makefile.
# This file should not be made, but only included from other makefiles.
# By default, this makefile compiles in release. To compile a debug version:
#    make CFG=Debug
#
# Project makefile should define the following BEFORE including this file:
# SRC_FILES - a list of all source files
# Output name under one of the following:
#     EXE_NAME (executable), 
#     LIB_NAME (dynamic library) or 
#     SLIB_NAME (static library) or
# BIN_DIR - Bin directory (output dir)
# INC_DIRS - a list of additional include directories
# LIB_DIRS - a list 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值