我创建了一个“build”目录并运行cmake ..
来运行ViennaTS软件。它工作了,但是当我运行make
时,我得到了以下错误。
Username@DESKTOP-DMU7A5N:~/ViennaTS/build$ make
[ 50%] Building CXX object src/CMakeFiles/viennats.dir/viennats.cpp.o
In file included from /home/Username/ViennaTS/src/viennats.cpp:61:
/home/Username/ViennaTS/viennats/Parameters.h:35:10: fatal error: sprng/sprng.h: No such file or directory
35 | #include "sprng/sprng.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/viennats.dir/build.make:76: src/CMakeFiles/viennats.dir/viennats.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:125: src/CMakeFiles/viennats.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
字符串
我知道sprng目录中的文件sprng. h丢失,但SPRNG目录中不存在文件sprng/sprng. h。文件sprng. h存在于以下路径中。
/home/Username/sprng/SRC
/home/Username/sprng/include
型
在这种情况下,我应该修改#include "sprng/sprng.h"
还是修改includePath ${workspaceFolder}/**
?我很困惑,所以如果你知道更多,请帮助我。Parameters.h
中的代码包含部分如下。
#ifndef DEF_PARAMETERS
#define DEF_PARAMETERS
/* =========================================================================
Copyright (c) 2008-2015, Institute for Microelectronics, TU Wien.
-----------------
ViennaTS - The Vienna Topography Simulator
-----------------
Contact: [email protected]
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <string>
#include <map>
#include <fstream>
#include <algorithm>
#include <boost/spirit/include/classic.hpp>
#include <boost/spirit/include/classic_clear_actor.hpp>
#include <boost/spirit/include/classic_push_back_actor.hpp>
#include <boost/spirit/include/classic_increment_actor.hpp>
#include <boost/spirit/include/classic_decrement_actor.hpp>
#include <boost/spirit/include/classic_assign_actor.hpp>
#include <boost/spirit/include/classic_if.hpp>
#include "Partition/Partition.h"
#include "boundaries.h"
#include "message.h"
#include "parser_actors.h"
#include "sprng/sprng.h"
#define BOOST_SPIRIT_DEBUG
型CMakeList.txt
是这样的:
# Required CMake Version
###############
cmake_minimum_required(VERSION 2.8)
#cmake_minimum_required(VERSION 3.1.0)
# Project setup
###############
PROJECT(ViennaLS)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Default build type
##############
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release")
ENDIF()
# Default compile options
#################
SET(CMAKE_CXX_FLAGS "-Wall -pedantic")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 ")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
# Specify general include directory
################
INCLUDE_DIRECTORIES(".")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/viennats/)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/viennats/LSlib/)
# Specify that the output executable is placed in the root build directory
################
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# Find prerequisites
####################
# Look for additiona CMake modules in the cmake subdirectory ..
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# OpenMP ..
FIND_PACKAGE(OpenMP REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# Boost ..
SET(BOOST_MIN_VERSION 1.46.0)
FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# SPRNG ..
FIND_PACKAGE(SPRNG REQUIRED)
INCLUDE_DIRECTORIES(${SPRNG_INCLUDE_DIR})
SET(LIBRARIES ${LIBRARIES} ${SPRNG_LIBRARY})
# HDF5
FIND_PACKAGE(HDF5 COMPONENTS CXX)
IF(HDF5_FOUND)
IF(HDF5_hdf5_cpp_LIBRARY)
add_definitions(-DUSE_HDF5)
add_definitions(${HDF5_DEFINITIONS})
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
SET(LIBRARIES ${LIBRARIES} ${HDF5_LIBRARIES})
ELSE(HDF5_hdf5_cpp_LIBRARY)
message(FATAL_ERROR "Missing HDF5 C++ library")
ENDIF(HDF5_hdf5_cpp_LIBRARY)
ELSE(HDF5_FOUND)
message(STATUS "Missing HDF5 library: ViennaTS will be built without TDR file support")
ENDIF(HDF5_FOUND)
# Subdirectories
################
add_subdirectory(src)
# Add visibility of headers
# Necessary for Qt-Creator usage.
################
file( GLOB_RECURSE MAKE_HEADERS_VISIBLE_SRC *.hpp *.h)
add_custom_target( MAKE_HEADERS_VISIBLE SOURCES ${MAKE_HEADERS_VISIBLE_SRC} )
型cmake ..
生成了以下Makefile。
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.22
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Disable VCS-based implicit rules.
% : %,v
# Disable VCS-based implicit rules.
% : RCS/%
# Disable VCS-based implicit rules.
% : RCS/%,v
# Disable VCS-based implicit rules.
% : SCCS/s.%
# Disable VCS-based implicit rules.
% : s.%
.SUFFIXES: .hpux_make_needs_suffix_list
# Command-line flag to silence nested $(MAKE).
$(VERBOSE)MAKESILENT = -s
#Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/ishitanaken23/ViennaTS
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/ishitanaken23/ViennaTS/build
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "No interactive CMake dialog available..."
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /home/ishitanaken23/ViennaTS/build/CMakeFiles /home/ishitanaken23/ViennaTS/build//CMakeFiles/progress.marks
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /home/ishitanaken23/ViennaTS/build/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named MAKE_HEADERS_VISIBLE
# Build rule for target.
MAKE_HEADERS_VISIBLE: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 MAKE_HEADERS_VISIBLE
.PHONY : MAKE_HEADERS_VISIBLE
# fast build rule for target.
MAKE_HEADERS_VISIBLE/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/MAKE_HEADERS_VISIBLE.dir/build.make CMakeFiles/MAKE_HEADERS_VISIBLE.dir/build
.PHONY : MAKE_HEADERS_VISIBLE/fast
#=============================================================================
# Target rules for targets named viennats
# Build rule for target.
viennats: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 viennats
.PHONY : viennats
# fast build rule for target.
viennats/fast:
$(MAKE) $(MAKESILENT) -f src/CMakeFiles/viennats.dir/build.make src/CMakeFiles/viennats.dir/build
.PHONY : viennats/fast
# Help Target
help:
@echo "The following are some of the valid targets for this Makefile:"
@echo "... all (the default if no target is provided)"
@echo "... clean"
@echo "... depend"
@echo "... edit_cache"
@echo "... rebuild_cache"
@echo "... MAKE_HEADERS_VISIBLE"
@echo "... viennats"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
型
1条答案
按热度按时间ghhaqwfi1#
首先,你使用的是什么编辑器/环境?这有时会造成差异。
永远不要修改includes指令。如果它应该是
"sprng/sprng.h"
,那么它需要保持这样。一旦其他文件包含在"sprng/sprng.h"
文件中,尝试修改指令将立即失败。您需要发布
CMakeList.txt
或Makefile
。但先想想:如果你正在使用makefile并使用
gcc
编译,那么你可以将-I/home/Username/sprng/SRC -I/home/Username/sprng/SRC
附加到build命令中。例如:字符串
编辑:为什么你对
INCLUDE_DIRECTORIES(...)
的调用不包括上面列出的两个目录?结果Makefile
看起来是什么样的?