eclipse创建包怎么不在src目录下

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eclipse创建包怎么不在src目录下相关的知识,希望对你有一定的参考价值。

参考技术A 不太可能,应该是视图的问题让你觉得是平级的吧。 一般在src下是建立package ,直接新建一个 aaa.bbb.ccc的package,系统会自动建立3级目录 或者你直接建class,如果有package,系统也会自动建立目录的

c++的程序在ros下怎么运行

参考技术A 1 先建立工作空间~/catkin_ws
2 在工作空间~/catkin_ws下创建包pkg目录second
好处是通过创建包自动生成package.xml和CMakeLists.txt
3 在second目录下创建hello.cpp源代码文件
~~~~~~~~~~~~~~~~~~~~~~~~~~~
eagle:~/catkin_ws$ cd src
eagle:~/catkin_ws/src$ tree second/
second/
├── CMakeLists.txt
├── package.xml
└── src
└── hello.cpp
1 directory, 3 files

4 编写hello.cpp文件
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <ros/ros.h>
int main(int argc, char **argv)
ros::init(argc, argv, "helloros1234444");
ros::NodeHandle n;
ROS_INFO("Hello, ROS!");
ros::spinOnce();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

5 修改编译makefile文件 CMakeLists.txt
~~~~~~~~~~~~~~~~~~
cmake_minimum_required(VERSION 2.8.3)
project(simple_examples)
find_package(catkin REQUIRED COMPONENTS roscpp)
catkin_package()
include_directories(include $catkin_INCLUDE_DIRS)
add_executable(hello hello.cpp)
target_link_libraries(hello $catkin_LIBRARIES)
~~~~~~~~~~~~~~~~~~

6 回到~/catkin_ws编译程序
liao@liao-eagle:~/catkin_ws$ catkin_make
Base path: /home/liao/catkin_ws
Source space: /home/liao/catkin_ws/src
Build space: /home/liao/catkin_ws/build
Devel space: /home/liao/catkin_ws/devel
Install space: /home/liao/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/liao/catkin_ws/build"
####
####
#### Running command: "make -j2 -l2" in "/home/liao/catkin_ws/build"
####
Scanning dependencies of target hello
[100%] Building CXX object second/CMakeFiles/hello.dir/src/hello.cpp.o
Linking CXX executable /home/liao/catkin_ws/devel/lib/second/hello
[100%] Built target hello
liao@liao-eagle:~/catkin_ws$

7 测试c++程序
7.1一个终端里运行roscore
7.2 另外一个终端里运行 rosrun second hello
liao@liao-eagle:~/catkin_ws$ rosrun second hello
[ INFO] [1442208641.400826666]: Hello, ROS!
liao@liao-eagle:~/catkin_ws$ rospack find second
/home/liao/catkin_ws/src/second
liao@liao-eagle:~/catkin_ws$
望采纳

以上是关于eclipse创建包怎么不在src目录下的主要内容,如果未能解决你的问题,请参考以下文章

eclipse中怎么在一个新的工程下的src文件夹中建立一个子文件夹呢?

eclipse创建新项目后src 没有default package 包 怎么回事 谢谢给位大哥大姐 求求

eclipse新建包只显示文件结构不显示包

eclipse maven工程中src/main/resources目录下创建的文件夹是包图标的解决方法

使用eclipse创建包以及子包

eclipse我导入了jar包,但是build后里面的class文件都不在啊,这是怎么回事?