我在 C++ 中有以下代码
if (should_run_make) {
std::string make = "make -C ";
make.append(outdir);
std::cout << "Make cmd is " << make << std::endl;
system(make.c_str());
}
这会报告以下内容:
make cmd 是 make -C /home/hamiltont/temp/ make: 进入目录
/home/hamiltont/temp' make: *** No targets. Stop. make: Leaving directory
/home/hamiltont/temp'
但是,手动操作可以通过多种方式正常工作,例如
[hamiltont@4 generator]$ make -C /home/hamiltont/temp/
make: Entering directory `/home/hamiltont/temp'
g++ -O3 -I/usr/include/openmpi-x86_64 -L/usr/local/lib -L/usr/lib64/openmpi/lib -lmpi -lmpi_cxx -lboost_serialization -lboost_mpi stg_impl.cpp -o impl
make: Leaving directory `/home/hamiltont/temp'
[hamiltont@4 generator]$ cd /home/hamiltont/temp/
[hamiltont@4 temp]$ make
g++ -O3 -I/usr/include/openmpi-x86_64 -L/usr/local/lib -L/usr/lib64/openmpi/lib -lmpi -lmpi_cxx -lboost_serialization -lboost_mpi stg_impl.cpp -o impl