a.out.h 头文件分析 \linux-1.0\linux\include\linux\a.out.h

本文详细介绍了Linux内核中a.out头文件的结构,包括执行文件的结构定义、机器类型枚举、魔法值宏定义等,以及如何设置和获取这些信息的方法,是理解Linux可执行文件格式的重要参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__

#define __GNU_EXEC_MACROS__

#ifndef __STRUCT_EXEC_OVERRIDE__

//定义执行文件结构
struct exec
{
  unsigned long a_info;		/* Use macros N_MAGIC, etc for access */
  unsigned a_text;		/* length of text, in bytes */
  unsigned a_data;		/* length of data, in bytes */
  unsigned a_bss;		/* length of uninitialized data area for file, in bytes */
  unsigned a_syms;		/* length of symbol table data in file, in bytes */
  unsigned a_entry;		/* start address */
  unsigned a_trsize;		/* length of relocation info for text, in bytes */
  unsigned a_drsize;		/* length of relocation info for data, in bytes */
};

#endif /* __STRUCT_EXEC_OVERRIDE__ */

//机器类型设定
/* these go in the N_MACHTYPE field */
enum machine_type {
#if defined (M_OLDSUN2)
  M__OLDSUN2 = M_OLDSUN2,
#else
  M_OLDSUN2 = 0,
#endif
#if defined (M_68010)
  M__68010 = M_68010,
#else
  M_68010 = 1,
#endif
#if defined (M_68020)
  M__68020 = M_68020,
#else
  M_68020 = 2,
#endif
#if defined (M_SPARC)
  M__SPARC = M_SPARC,
#else
  M_SPARC = 3,
#endif
  /* skip a bunch so we don't run into any of sun's numbers */
  M_386 = 100,
};

//定义MAGIC地址为32位的有效值。0-16位
#if !defined (N_MAGIC)
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#endif

//获取机器类型 16-23位
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))

//标记 24-31位
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)

//设定Magic,机器类型,标记
#define N_SET_INFO(exec, magic, type, flags) \
	((exec).a_info = ((magic) & 0xffff) \
	 | (((int)(type) & 0xff) << 16) \
	 | (((flags) & 0xff) << 24))

//单独设定Magic值
#define N_SET_MAGIC(exec, magic) \
	((exec).a_info = (((exec).a_info & 0x
saber@ubuntu:~/fastplanner_ws$ catkin_make Base path: /home/saber/fastplanner_ws Source space: /home/saber/fastplanner_ws/src Build space: /home/saber/fastplanner_ws/build Devel space: /home/saber/fastplanner_ws/devel Install space: /home/saber/fastplanner_ws/install #### #### Running command: "cmake /home/saber/fastplanner_ws/src -DCATKIN_DEVEL_PREFIX=/home/saber/fastplanner_ws/devel -DCMAKE_INSTALL_PREFIX=/home/saber/fastplanner_ws/install -G Unix Makefiles" in "/home/saber/fastplanner_ws/build" #### -- Using CATKIN_DEVEL_PREFIX: /home/saber/fastplanner_ws/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/noetic -- This workspace overlays: /opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Using Debian Python package layout -- Using empy: /usr/lib/python3/dist-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/saber/fastplanner_ws/build/test_results -- Forcing gtest/gmock from source, though one was otherwise available. -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") -- Using Python nosetests: /usr/bin/nosetests3 -- catkin 0.8.12 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~ traversing 20 packages in topological order: -- ~~ - quadrotor_msgs -- ~~ - cmake_utils -- ~~ - map_generator -- ~~ - plan_env -- ~~ - bspline -- ~~ - bspline_opt -- ~~ - path_searching -- ~~ - poly_traj -- ~~ - pose_utils -- ~~ - so3_disturbance_generator -- ~~ - odom_visualization -- ~~ - local_sensing_node -- ~~ - so3_control -- ~~ - multi_map_server -- ~~ - traj_utils -- ~~ - plan_manage -- ~~ - uav_utils -- ~~ - so3_quadrotor_simulator -- ~~ - rviz_plugins -- ~~ - waypoint_generator -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- +++ processing catkin package: 'quadrotor_msgs' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/quadrotor_msgs) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- quadrotor_msgs: 13 messages, 0 services -- +++ processing catkin package: 'cmake_utils' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/cmake_utils) -- +++ processing catkin package: 'map_generator' -- ==> add_subdirectory(Fast-Planner/uav_simulator/map_generator) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- +++ processing catkin package: 'plan_env' -- ==> add_subdirectory(Fast-Planner/fast_planner/plan_env) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- 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;/usr/lib/x86_64-linux-gnu/libboost_system.so;/usr/lib/x86_64-linux-gnu/libboost_filesystem.so;/usr/lib/x86_64-linux-gnu/libboost_date_time.so;/usr/lib/x86_64-linux-gnu/libboost_iostreams.so;/usr/lib/x86_64-linux-gnu/libboost_regex.so;optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so;/usr/lib/libOpenNI.so;/usr/lib/libOpenNI2.so;vtkChartsCore;vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonExecutionModel;vtkFiltersGeneral;vtkCommonComputationalGeometry;vtkFiltersCore;vtkInfovisCore;vtkFiltersExtraction;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkRenderingContext2D;vtkRenderingCore;vtkFiltersGeometry;vtkFiltersSources;vtkRenderingFreeType;/usr/lib/x86_64-linux-gnu/libfreetype.so;/usr/lib/x86_64-linux-gnu/libz.so;vtkFiltersModeling;vtkImagingSources;vtkInteractionStyle;vtkInteractionWidgets;vtkFiltersHybrid;vtkImagingColor;vtkImagingGeneral;vtkImagingHybrid;vtkIOImage;vtkDICOMParser;vtkmetaio;/usr/lib/x86_64-linux-gnu/libjpeg.so;/usr/lib/x86_64-linux-gnu/libpng.so;/usr/lib/x86_64-linux-gnu/libtiff.so;vtkRenderingAnnotation;vtkRenderingVolume;vtkIOXML;vtkIOCore;vtkIOXMLParser;/usr/lib/x86_64-linux-gnu/libexpat.so;vtkIOGeometry;vtkIOLegacy;vtkIOPLY;vtkRenderingLOD;vtkViewsContext2D;vtkViewsCore;vtkRenderingContextOpenGL2;vtkRenderingOpenGL2;FLANN::FLANN (Required is at least version "1.7") -- +++ processing catkin package: 'bspline' -- ==> add_subdirectory(Fast-Planner/fast_planner/bspline) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- +++ processing catkin package: 'bspline_opt' -- ==> add_subdirectory(Fast-Planner/fast_planner/bspline_opt) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- +++ processing catkin package: 'path_searching' -- ==> add_subdirectory(Fast-Planner/fast_planner/path_searching) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- +++ processing catkin package: 'poly_traj' -- ==> add_subdirectory(Fast-Planner/fast_planner/poly_traj) -- +++ processing catkin package: 'pose_utils' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/pose_utils) -- Found Armadillo: /usr/lib/libarmadillo.so (found version "9.800.4") -- +++ processing catkin package: 'so3_disturbance_generator' -- ==> add_subdirectory(Fast-Planner/uav_simulator/so3_disturbance_generator) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- +++ processing catkin package: 'odom_visualization' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/odom_visualization) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- +++ processing catkin package: 'local_sensing_node' -- ==> add_subdirectory(Fast-Planner/uav_simulator/local_sensing) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy CMake Warning at /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:166 (message): catkin_package() DEPENDS on 'Eigen' but neither 'Eigen_INCLUDE_DIRS' nor 'Eigen_LIBRARIES' is defined. Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package) Fast-Planner/uav_simulator/local_sensing/CMakeLists.txt:70 (catkin_package) -- +++ processing catkin package: 'so3_control' -- ==> add_subdirectory(Fast-Planner/uav_simulator/so3_control) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- +++ processing catkin package: 'multi_map_server' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/multi_map_server) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- multi_map_server: 4 messages, 0 services -- +++ processing catkin package: 'traj_utils' -- ==> add_subdirectory(Fast-Planner/fast_planner/traj_utils) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- +++ processing catkin package: 'plan_manage' -- ==> add_subdirectory(Fast-Planner/fast_planner/plan_manage) -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- plan_manage: 1 messages, 0 services -- +++ processing catkin package: 'uav_utils' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/uav_utils) -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Found Eigen: /usr/include/eigen3 (found version "3.3.7") -- +++ processing catkin package: 'so3_quadrotor_simulator' -- ==> add_subdirectory(Fast-Planner/uav_simulator/so3_quadrotor_simulator) CMake Warning at /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:166 (message): catkin_package() DEPENDS on 'Eigen3' but neither 'Eigen3_INCLUDE_DIRS' nor 'Eigen3_LIBRARIES' is defined. Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package) Fast-Planner/uav_simulator/so3_quadrotor_simulator/CMakeLists.txt:25 (catkin_package) CMake Warning at /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:166 (message): catkin_package() DEPENDS on 'system_lib' but neither 'system_lib_INCLUDE_DIRS' nor 'system_lib_LIBRARIES' is defined. Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package) Fast-Planner/uav_simulator/so3_quadrotor_simulator/CMakeLists.txt:25 (catkin_package) -- +++ processing catkin package: 'rviz_plugins' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/rviz_plugins) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy CMake Warning at /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:166 (message): catkin_package() DEPENDS on 'system_lib' but neither 'system_lib_INCLUDE_DIRS' nor 'system_lib_LIBRARIES' is defined. Call Stack (most recent call first): /opt/ros/noetic/share/catkin/cmake/catkin_package.cmake:102 (_catkin_package) Fast-Planner/uav_simulator/Utils/rviz_plugins/CMakeLists.txt:12 (catkin_package) -- Using Qt5 based on the rviz_QT_VERSION: 5.12.8 -- +++ processing catkin package: 'waypoint_generator' -- ==> add_subdirectory(Fast-Planner/uav_simulator/Utils/waypoint_generator) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- Configuring done CMake Warning (dev) at Fast-Planner/uav_simulator/so3_disturbance_generator/CMakeLists.txt:70 (add_dependencies): Policy CMP0046 is not set: Error on non-existent dependency in add_dependencies. Run "cmake --help-policy CMP0046" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The dependency target "so3_disturbance_generator_gencfg" of target "so3_disturbance_generator" does not exist. This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /home/saber/fastplanner_ws/build #### #### Running command: "make -j2 -l2" in "/home/saber/fastplanner_ws/build" #### Scanning dependencies of target geometry_msgs_generate_messages_py Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_StatusData [ 0%] Built target geometry_msgs_generate_messages_py Scanning dependencies of target nav_msgs_generate_messages_py [ 0%] Built target nav_msgs_generate_messages_py Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_Odometry [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_StatusData Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_LQRTrajectory [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_Odometry Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_AuxCommand [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_LQRTrajectory Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_Corrections [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_AuxCommand Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_Gains [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_Corrections Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_OutputData [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_Gains Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_PositionCommand [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_OutputData Scanning dependencies of target _quadrotor_msgs_generate_messages_check_deps_PPROutputData [ 0%] Built target _quadrotor_msgs_generate_messages_check_deps_Pos
最新发布
07-13
<think>我们正在解决用户在使用catkin_make构建ROS工作空间时遇到的CMake配置问题。用户提到了两个主要问题: 1. VTK文件缺失的警告(如vtkRenderingOpenGL2、vtkGUISupportQt等) 2. Eigen3依赖问题(找不到Eigen3Config.cmake或eigen3-config.cmake) 根据用户提供的引用[1],在CMakeLists.txt中正确配置VTK和Eigen3是关键。同时,引用[2]提到catkin_make是对cmake的封装,因此我们可以通过修改CMakeLists.txt来解决。 解决方案步骤: 1. **确保已安装必要的VTK和Eigen3开发包**: 在Ubuntu上,使用apt安装: ```bash sudo apt-get install libvtk7-dev libeigen3-dev ``` 注意:ROS Kinetic默认使用VTK7,所以安装libvtk7-dev。如果使用其他ROS版本,请确认对应的VTK版本。 2. **修改CMakeLists.txt**: 参考引用[1]中的配置,我们需要: - 使用`find_package`正确查找VTK和Eigen3 - 包含必要的头文件目录和链接库 示例CMakeLists.txt关键部分: ```cmake cmake_minimum_required(VERSION 3.10.2) # 建议至少3.10,因为VTK需要较新的CMake project(my_vtk_ros_project) # 查找catkin,确保包含roscpp等组件 find_package(catkin REQUIRED COMPONENTS roscpp std_msgs vtk # 这里添加vtk组件,确保catkin能找到ROS封装的VTK ) # 查找VTK find_package(VTK REQUIRED) include(${VTK_USE_FILE}) # 查找Eigen3 find_package(Eigen3 REQUIRED) include_directories(${EIGEN3_INCLUDE_DIR}) # 声明可执行文件 add_executable(my_vtk_ros_node src/main.cpp) # 指定链接库 target_link_libraries(my_vtk_ros_node ${catkin_LIBRARIES} ${VTK_LIBRARIES} ) # 包含目录 include_directories( ${catkin_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ) ``` 3. **处理VTK警告**: 出现的警告如`Could NOT find VTK (missing: vtkRenderingOpenGL2)`通常是因为VTK编译时没有打开某些模块(如OpenGL2或Qt支持)。在Ubuntu中,安装`libvtk7-dev`通常已经包含了这些模块。如果仍然出现警告,可以尝试: - 确保安装了相关依赖:`sudo apt-get install libqt5opengl5-dev` - 在CMake中显式指定需要的VTK组件: ```cmake find_package(VTK REQUIRED COMPONENTS vtkRenderingOpenGL2 vtkGUISupportQt vtkRenderingQt # 其他需要的模块 ) ``` 4. **处理Eigen3警告**: 警告`Could not find a package configuration file provided by "Eigen3"`通常是因为Eigen3的CMake配置文件没有正确安装。安装`libeigen3-dev`会提供这个文件。如果仍然找不到,可以手动指定Eigen3的路径: ```cmake set(Eigen3_DIR /usr/include/eigen3) # 或者使用find_path查找 ``` 或者使用: ```cmake find_package(Eigen3 REQUIRED HINTS /usr/include/eigen3) ``` 5. **清理并重新构建**: 修改CMakeLists.txt后,需要清理构建目录并重新构建: ```bash cd ~/catkin_ws rm -rf build devel catkin_make ``` 注意:如果用户使用的是ROS Noetic,则默认使用VTK7,但需要安装`libvtk7-dev`。如果使用较新的ROS版本(如Noetic),可能需要更新CMake版本(要求3.10以上)。 如果问题仍然存在,请检查系统安装的VTK版本,并确保CMakeLists.txt中的配置与安装的版本一致。 相关问题: 1. 如何检查系统中安装的VTK版本? 2. 在ROS中如何正确配置CMakeLists.txt以使用PCL库? 3. 当多个版本的VTK存在时,如何指定CMake使用特定版本?</think>### ROS catkin_make 构建中 VTK 文件缺失和 Eigen 依赖问题的解决方案 在 ROS 中使用 `catkin_make` 构建时遇到 VTK 文件缺失和 Eigen 依赖问题,通常是由 CMake 配置不当或依赖缺失导致的。以下是系统化的解决方案: #### 1. **安装完整依赖** ```bash # 安装完整 VTK 和 Eigen 开发包 sudo apt-get install libvtk7-dev libeigen3-dev # 安装 ROS 相关组件(根据发行版调整) sudo apt-get install ros-${ROS_DISTRO}-pcl-ros ros-${ROS_DISTRO}-pcl-conversions ``` > 说明:确保 `${ROS_DISTRO}` 替换为实际版本(如 `noetic`) #### 2. **修改 CMakeLists.txt 配置** 参考引用[1][^1]的配置模式,在包的 `CMakeLists.txt` 中添加以下关键配置: ```cmake cmake_minimum_required(VERSION 3.10) # 确保CMake版本≥3.10 find_package(catkin REQUIRED COMPONENTS roscpp vtk # 显式声明VTK组件 pcl_ros # 包含PCL相关依赖 ) # 显式查找VTK并包含其配置 find_package(VTK REQUIRED COMPONENTS vtkRenderingOpenGL2 vtkGUISupportQt vtkRenderingQt ) include(${VTK_USE_FILE}) # 正确配置Eigen3 find_package(Eigen3 REQUIRED) include_directories( ${EIGEN3_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ) # 链接阶段包含所有依赖 target_link_libraries(your_node ${catkin_LIBRARIES} ${VTK_LIBRARIES} ) ``` #### 3. **解决 VTK 模块缺失问题** 若出现类似 `Could NOT find VTK (missing: vtkRenderingOpenGL2)` 的警告: ```cmake # 在find_package(VTK)中明确指定所需模块 find_package(VTK REQUIRED COMPONENTS vtkCommonCore vtkFiltersSources vtkRenderingOpenGL2 vtkInteractionStyle ) ``` #### 4. **处理 Eigen3 路径问题** 若报错 `Could not find a package configuration file provided by "Eigen3"`: ```bash # 手动设置Eigen3路径 sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen ``` 或在 CMake 中显式指定: ```cmake set(Eigen3_DIR /usr/share/eigen3/cmake) # 添加在find_package前 ``` #### 5. **清理重建工作空间** ```bash cd ~/catkin_ws rm -rf build devel # 彻底清理旧构建 catkin_make -DCMAKE_BUILD_TYPE=Release ``` #### 6. **验证环境变量** 确保 `VTK_DIR` 环境变量正确指向 VTK 的 CMake 配置路径: ```bash echo "export VTK_DIR=/usr/lib/cmake/vtk-7.1" >> ~/.bashrc source ~/.bashrc ``` > **关键原理**: > 1. ROS 的 VTK 依赖需要显式声明所有子模块[^1] > 2. Eigen3 在 Ubuntu 中默认不提供 CMake 配置文件,需手动链接[^3] > 3. PCL 相关组件(`pcl_ros`)必须包含在 `find_package` 中以避免符号冲突[^3]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值