教训:不能创建多级目录。。。改为逐级创建,或者手动创建上一级目录。
测试cpp:
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>
int main(int argc, char **argv)
{
int status;
std::string foldername = "/home/lyk/test/mm/5.0";//绝对目录
// std::string foldername = "../flor";//当前目录
// std::string foldername = "./flor";//相对目录
// status = mkdir("/home/test/flor", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
// status = mkdir(foldername.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
status = mkdir(foldername.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::cout<<status<<std::endl;
}
测试cmake:
cmake_minimum_required(VERSION 2.8.3)
add_executable(hello_world_node hello_world_node.cpp)
target_link_libraries(hello_world_node ${catkin_LIBRARIES})