我有一个项目(有3个子项目),当我在与顶级CMakeLists.txt相同的目录中执行cmake时,CMake可以完美地构建。但是,当我尝试使用源代码构建时,我收到以下错误:
javsalgar@javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ mkdir build
javsalgar@javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ cd build/
javsalgar@javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ ls
javsalgar@javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ cmake ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build
javsalgar@javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ make
/usr/bin/cmake -H/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -B/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/depend
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce/CMakeFiles/pi_mpireduce.dir/DependInfo.cmake --color=
Scanning dependencies of target pi_mpireduce
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 1
[ 20%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/mpi_pi_reduce.c
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 2
[ 40%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/dboard.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/dboard.c
Linking C executable .
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && /usr/bin/cmake -E cmake_link_script CMakeFiles/pi_mpireduce.dir/link.txt --verbose=1
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
/usr/bin/ld: cannot open output file .: Is a directory
collect2: error: ld returned 1 exit status
make[2]: *** [pi_mpireduce] Error 1
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make[1]: *** [pi_mpireduce/CMakeFiles/pi_mpireduce.dir/all] Error 2
make[1]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make: *** [all] Error 2
答案 0 :(得分:4)
我发现了问题所在。可执行文件和子项目的目录具有相同的名称。查找可执行文件名称就可以了。
答案 1 :(得分:0)
该行
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
告诉链接器编译的输出名称应为.
,这不是可执行文件或库的有效名称或任何内容。这可能来自您从配置时间内为空的变量设置目标名称,或者您不小心在那里写了.
。