当前位置:   article > 正文

Mac下安装Xcode、PCL、Homebrew、Cmake_mac brew安装xcode

mac brew安装xcode

第一步:mac下镜像飞速安装Homebrew教程

在网上找的教程出现错误:

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Operation timed out

参考了该帖子:

mac下镜像飞速安装Homebrew教程 - 知乎

1.终端输入:

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

回车安装

2.终端继续输入:brew update

再测试一下有没有安装成功:brew -v

软件都会安装到 /usr/local/Cellar

安装完成后,执行brew,就有提示

第二步:下载Xcode

 由于AppStore下载不到Xcode的历史版本,需要我升级系统,这不科学!

用下面这个网址去搜索Xcode,然后下载系统可以下载的版本,我下载的11.5的

Sign In - Apple

第三步:安装Cmake 

 1.Cmake官网下载地址:Download | CMake

2.安装

3.cmake配置

从菜单栏选择:Tools--How to Install For Command Line Use

如果你在命令行中输入 cmake --version,你会发现系统并不认识cmake这个命令。然后使用上面图中给出的第一种方法,即在命令行中输入:

PATH="/Applications/CMake.app/Contents/bin":"$PATH"

然后再执行cmake --version,系统就可以正确识别它了。

但是,这个方法只能管一时,在新开的命令行窗口中输入:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

​​​​​​​

 成功!

参考链接:在Mac OS中配置CMake的详细图文教程_libaineu2004的博客-CSDN博客

第四步:安装PCL 

1.终端输入: brew install pcl

2.下载到一半断网了,不知道如何继续下载,然后就报错:curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60

Error: pcl: Failed to download resource "boost"

终端重新输入:brew install pcl

这时,下载过的不会重新下载,他就会继续下载了~

3.出现报错:xcrun: error: active developer path ("/Users/zhanghong/Downloads/Xcode.app/Contents/Developer") does not exist Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.See `man xcode-select` for more details.

打开新的终端窗口:

输入命令查看安装路径:xcode-select -print-path

/Users/zhanghong/Downloads/Xcode.app/Contents/Developer

但我已经将 Xcode.app从下载文件夹移动到应用程序中了

真正的路径应该是:/Applications/Xcode.app/Contents/Developer

所以设置xcode-select到指定位置:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

输入密码,再验证是否设置成功:xcode-select --print-path

得到:/Applications/Xcode.app/Contents/Developer  ;说明安装路径修改成功

然后再次重新下载: brew install pcl

4.报错:

  1. Error: The `brew link` step did not complete successfully
  2. The formula built, but is not symlinked into /usr/local
  3. Could not symlink bin/2to3
  4. Target /usr/local/bin/2to3
  5. already exists. You may want to remove it:
  6. rm '/usr/local/bin/2to3'
  7. To force the link and overwrite all conflicting files:
  8. brew link --overwrite python@3.9
  9. To list all files that would be deleted:
  10. brew link --overwrite --dry-run python@3.9
  11. Possible conflicting files are:
  12. /usr/local/bin/2to3 -> /Library/Frameworks/Python.framework/Versions/3.8/bin/2to3
  13. /usr/local/bin/idle3 -> /Library/Frameworks/Python.framework/Versions/3.8/bin/idle3
  14. /usr/local/bin/pydoc3 -> /Library/Frameworks/Python.framework/Versions/3.8/bin/pydoc3
  15. /usr/local/bin/python3 -> /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
  16. /usr/local/bin/python3-config -> /Library/Frameworks/Python.framework/Versions/3.8/bin/python3-config

查一下冲突的文件:brew link --dry-run python@3.9 

  1. Would link:
  2. /usr/local/bin/2to3
  3. /usr/local/bin/2to3-3.9
  4. /usr/local/bin/idle3
  5. /usr/local/bin/idle3.9
  6. /usr/local/bin/pydoc3
  7. /usr/local/bin/pydoc3.9
  8. /usr/local/bin/python3
  9. /usr/local/bin/python3-config
  10. /usr/local/bin/python3.9
  11. /usr/local/bin/python3.9-config
  12. /usr/local/share/man/man1/python3.1
  13. /usr/local/share/man/man1/python3.9.1
  14. /usr/local/lib/pkgconfig/python-3.9-embed.pc
  15. /usr/local/lib/pkgconfig/python-3.9.pc
  16. /usr/local/lib/pkgconfig/python3-embed.pc
  17. /usr/local/lib/pkgconfig/python3.pc
  18. /usr/local/Frameworks/Python.framework/Headers
  19. /usr/local/Frameworks/Python.framework/Python
  20. /usr/local/Frameworks/Python.framework/Resources
  21. /usr/local/Frameworks/Python.framework/Versions/3.9
  22. /usr/local/Frameworks/Python.framework/Versions/Current

强制链接并覆盖所有冲突文件,终端输入:brew link --overwrite python@3.9

5.查询安装信息:brew info pcl

 第五步:Xcode创建PCL工程 

1.Xcode —— 新建project-->Application-->Command Line Tool,名字就叫PCL_Test, language选择C++。

2.在PCL_Test文件夹下建立:CMakeLists.txt  , 内容为:

  1. #cmake最低版本需求,不加入此行会受到警告信息
  2. CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
  3. PROJECT(PCL_Test) #项目名称
  4. find_package(PCL 1.3 REQUIRED)
  5. include_directories(${PCL_INCLUDE_DIRS})
  6. link_directories(${PCL_LIBRARY_DIRS})
  7. add_definitions(${PCL_DEFINITIONS})
  8. add_executable(PCL_Test main.cpp)
  9. target_link_libraries(PCL_Test ${PCL_LIBRARIES})

3.在工程目录下的文件main.cpp写入:

  1. #include <iostream>
  2. #include <pcl/io/pcd_io.h>
  3. #include <pcl/point_types.h>
  4. int
  5. main (int argc, char** argv)
  6. {
  7. pcl::PointCloud<pcl::PointXYZ> cloud;
  8. // Fill in the cloud data
  9. cloud.width = 5;
  10. cloud.height = 1;
  11. cloud.is_dense = false;
  12. cloud.points.resize (cloud.width * cloud.height);
  13. for (size_t i = 0; i < cloud.points.size (); ++i)
  14. {
  15. cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
  16. cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
  17. cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  18. }
  19. pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
  20. std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;
  21. for (size_t i = 0; i < cloud.points.size (); ++i)
  22. std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;
  23. return (0);
  24. }

4.在PCL_Test文件夹下新建build文件夹:mkdir build

用Cmake.app来构建

CMake Error at CMakeLists.txt:4:Parse error. Expected a newline, got identifier with text"include_directories".这种错误表示CMakeLists.txt文件第四行的换行符有问题

解决办法:后来我重新找到一个CMakeLists.txt文件,在人家文件的基础上去改的

然后又报错第四行有问题:(忘了记录下来了)

解决办法:把第四行的括号()改成英文的括号()就可以了

接着又报错:

  1. CMake Warning at /usr/local/lib/cmake/vtk-9.1/VTK-vtk-module-find-packages.cmake:1243 (find_package):
  2. By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  3. asked CMake to find a package configuration file provided by "Qt5", but
  4. CMake did not find one.
  5. Could not find a package configuration file provided by "Qt5" (requested
  6. version 5.15) with any of the following names:
  7. Qt5Config.cmake
  8. qt5-config.cmake
  9. Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  10. to a directory containing one of the above files. If "Qt5" provides a
  11. separate development package or SDK, be sure it has been installed.
  12. Call Stack (most recent call first):
  13. /usr/local/lib/cmake/vtk-9.1/vtk-config.cmake:150 (include)
  14. /usr/local/share/pcl-1.12/PCLConfig.cmake:270 (find_package)
  15. /usr/local/share/pcl-1.12/PCLConfig.cmake:319 (find_VTK)
  16. /usr/local/share/pcl-1.12/PCLConfig.cmake:543 (find_external_library)
  17. CMakeLists.txt:4 (find_package)
  18. Could not find the VTK package due to a missing dependency: Qt5

解决办法:要在CMakeLists.txt文件里的find_package前添加一行:(注意,这里/usr/local/Cellar/qt@5/5.15.5_1/lib/cmake/Qt5 写你自己QT5文件夹所处的位置)

set(CMAKE_PREFIX_PATH "/usr/local/Cellar/qt@5/5.15.5_1/lib/cmake/Qt5")

继续点击Configure构建

发现只有第三行一个警告** WARNING ** io features related to pcap will be disabled

最后写着Configuring done

  1. Eigen found (include: /usr/local/include/eigen3, version: 3.4.0)
  2. FLANN found (include: /usr/local/include, lib: /usr/local/lib/libflann_cpp.dylib)
  3. ** WARNING ** io features related to pcap will be disabled
  4. Eigen found (include: /usr/local/include/eigen3, version: 3.4.0)
  5. Found Qhull version 8.0.2
  6. Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework
  7. Found GLEW: /usr/local/include
  8. looking for PCL_COMMON
  9. Found PCL_COMMON: /usr/local/lib/libpcl_common.dylib
  10. looking for PCL_KDTREE
  11. Found PCL_KDTREE: /usr/local/lib/libpcl_kdtree.dylib
  12. looking for PCL_OCTREE
  13. Found PCL_OCTREE: /usr/local/lib/libpcl_octree.dylib
  14. looking for PCL_SEARCH
  15. Found PCL_SEARCH: /usr/local/lib/libpcl_search.dylib
  16. looking for PCL_SAMPLE_CONSENSUS
  17. Found PCL_SAMPLE_CONSENSUS: /usr/local/lib/libpcl_sample_consensus.dylib
  18. looking for PCL_FILTERS
  19. Found PCL_FILTERS: /usr/local/lib/libpcl_filters.dylib
  20. looking for PCL_2D
  21. Found PCL_2D: /usr/local/include/pcl-1.12
  22. looking for PCL_GEOMETRY
  23. Found PCL_GEOMETRY: /usr/local/include/pcl-1.12
  24. looking for PCL_IO
  25. Found PCL_IO: /usr/local/lib/libpcl_io.dylib
  26. looking for PCL_FEATURES
  27. Found PCL_FEATURES: /usr/local/lib/libpcl_features.dylib
  28. looking for PCL_ML
  29. Found PCL_ML: /usr/local/lib/libpcl_ml.dylib
  30. looking for PCL_SEGMENTATION
  31. Found PCL_SEGMENTATION: /usr/local/lib/libpcl_segmentation.dylib
  32. looking for PCL_VISUALIZATION
  33. Found PCL_VISUALIZATION: /usr/local/lib/libpcl_visualization.dylib
  34. looking for PCL_SURFACE
  35. Found PCL_SURFACE: /usr/local/lib/libpcl_surface.dylib
  36. looking for PCL_REGISTRATION
  37. Found PCL_REGISTRATION: /usr/local/lib/libpcl_registration.dylib
  38. looking for PCL_KEYPOINTS
  39. Found PCL_KEYPOINTS: /usr/local/lib/libpcl_keypoints.dylib
  40. looking for PCL_TRACKING
  41. Found PCL_TRACKING: /usr/local/lib/libpcl_tracking.dylib
  42. looking for PCL_RECOGNITION
  43. Found PCL_RECOGNITION: /usr/local/lib/libpcl_recognition.dylib
  44. looking for PCL_STEREO
  45. Found PCL_STEREO: /usr/local/lib/libpcl_stereo.dylib
  46. looking for PCL_APPS
  47. Found PCL_APPS: /usr/local/lib/libpcl_apps.dylib
  48. looking for PCL_CLOUD_COMPOSER
  49. Found PCL_CLOUD_COMPOSER: /usr/local/include/pcl-1.12
  50. looking for PCL_POINT_CLOUD_EDITOR
  51. Found PCL_POINT_CLOUD_EDITOR: /usr/local/include/pcl-1.12
  52. looking for PCL_OUTOFCORE
  53. Found PCL_OUTOFCORE: /usr/local/lib/libpcl_outofcore.dylib
  54. looking for PCL_PEOPLE
  55. Found PCL_PEOPLE: /usr/local/lib/libpcl_people.dylib
  56. looking for PCL_SIMULATION
  57. Found PCL_SIMULATION: /usr/local/lib/libpcl_simulation.dylib
  58. Found PCL: pcl_common;pcl_kdtree;pcl_octree;pcl_search;pcl_sample_consensus;pcl_filters;pcl_io;pcl_features;pcl_ml;pcl_segmentation;pcl_visualization;pcl_surface;pcl_registration;pcl_keypoints;pcl_tracking;pcl_recognition;pcl_stereo;pcl_apps;pcl_outofcore;pcl_people;pcl_simulation;Boost::system;Boost::filesystem;Boost::date_time;Boost::iostreams;Boost::serialization;VTK::ChartsCore;VTK::CommonColor;VTK::CommonComputationalGeometry;VTK::CommonCore;VTK::CommonDataModel;VTK::CommonExecutionModel;VTK::CommonMath;VTK::CommonMisc;VTK::CommonTransforms;VTK::FiltersCore;VTK::FiltersExtraction;VTK::FiltersGeneral;VTK::FiltersGeometry;VTK::FiltersModeling;VTK::FiltersSources;VTK::ImagingCore;VTK::ImagingSources;VTK::InteractionImage;VTK::InteractionStyle;VTK::InteractionWidgets;VTK::IOCore;VTK::IOGeometry;VTK::IOImage;VTK::IOLegacy;VTK::IOPLY;VTK::RenderingAnnotation;VTK::RenderingCore;VTK::RenderingContext2D;VTK::RenderingLOD;VTK::RenderingFreeType;VTK::ViewsCore;VTK::ViewsContext2D;VTK::RenderingOpenGL2;VTK::GUISupportQt;FLANN::FLANN;QHULL::QHULL (Required is at least version "1.3")
  59. Configuring done

一个警告先不管了!

接下来Generate

 老天爷啊,终于成功了!!!

接下来有个.xcodeproj文件,打开,进入Xcode的界面,Command+b,编译

 出现错误:

error: Build input file cannot be found: '/Users/zhanghong/Desktop/PCL_Test/PCL_Test/main.cpp' (in target 'PCL_Test' from project 'PCL_Test')

warning: Could not read serialized diagnostics file: Cannot Load File: Failed to open diagnostics file (in target 'PCL_Test' from project 'PCL_Test')

是因为之前我更改了main.cpp的位置......

实在找不到解决办法,只好把main.cpp移回去了,妥协...

然后重新:Command+b   编译

又报错:'pcl/io/pcd_io.h' file not found

当我把这几行挨个注释后发现,这四个库其实都找不到!

解决办法:

 继续编译:main.cpp --> Command+b

又有十个报错!

三天了,依旧没弄好,放弃了,不弄了!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/518405
推荐阅读
相关标签