Skip to content

Commit

Permalink
Merge pull request #7 from qpc001/master
Browse files Browse the repository at this point in the history
<chore>(CMake):新增对Ubuntu18.04适配(需要安装GCC-9).
  • Loading branch information
gaoxiang12 authored Feb 14, 2023
2 parents 400cb62 + 9811b34 commit a1afea3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

option(BUILD_WITH_UBUNTU1804 OFF)

include(cmake/packages.cmake)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR})
Expand Down
71 changes: 60 additions & 11 deletions cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,63 @@ include_directories(${yaml-cpp_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/velodyne/include)

set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
tbb
)
if(BUILD_WITH_UBUNTU1804)
function(extract_file filename extract_dir)
message(STATUS "Extract ${filename} to ${extract_dir} ...")
set(temp_dir ${extract_dir})
if(EXISTS ${temp_dir})
file(REMOVE_RECURSE ${temp_dir})
endif()
file(MAKE_DIRECTORY ${temp_dir})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvzf ${filename}
WORKING_DIRECTORY ${temp_dir})
endfunction()

set(TBB_ROOT_DIR ${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8/oneTBB-2019_U8)
set(TBB_BUILD_DIR "tbb_build_dir=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
set(TBB_BUILD_PREFIX "tbb_build_prefix=tbb")

extract_file(${PROJECT_SOURCE_DIR}/thirdparty/tbb/2019_U8.tar.gz ${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8)

include(${TBB_ROOT_DIR}/cmake/TBBBuild.cmake)

#message(STATUS "======TBB_BUILD_DIR = ${TBB_BUILD_DIR}")
#message(STATUS "======TBB_BUILD_PREFIX = ${TBB_BUILD_PREFIX}")

tbb_build(TBB_ROOT ${TBB_ROOT_DIR}
compiler=gcc-9
stdver=c++17
${TBB_BUILD_DIR}
${TBB_BUILD_PREFIX}
CONFIG_DIR
TBB_DIR)

find_package(TBB REQUIRED)

include_directories(${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8/oneTBB-2019_U8/include)
link_directories(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tbb_release)

set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
TBB::tbb
)
else()
set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
tbb
)
endif ()
31 changes: 31 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,37 @@
- 在编译本书代码之前,请编译安装本书thirdparty/下的三方库(如果您机器上没有安装的话)。
- 之后,使用通常的cmake, make 方式就可以编译本书所有内容了。

### 适配Ubuntu18.04

为了在Ubuntu18.04上编译运行,需要安装gcc-9,并且使用对应版本的TBB

**安装gcc-9**
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++

#命令最后的1和10是优先级,如果使用auto选择模式,系统将默认使用优先级高的
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 10
```

**检查版本**
```bash
g++ -v
```

**编译程序**
```bash
mkdir build
cd build
cmake .. -DBUILD_WITH_UBUNTU1804=ON
make -j8
```

## TODO项

- 将UI里的不必要信息去除
Expand Down
2 changes: 1 addition & 1 deletion src/ch7/loam-like/feature_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void FeatureExtraction::Extract(FullCloudPtr pc_in, CloudPtr pc_out_edge, CloudP
p.z = pt.z;
p.intensity = pt.intensity;

scans_in_each_line[pt.ring]->emplace_back(p);
scans_in_each_line[pt.ring]->points.emplace_back(p);
}

// 处理曲率
Expand Down
Binary file added thirdparty/tbb/2019_U8.tar.gz
Binary file not shown.

0 comments on commit a1afea3

Please sign in to comment.