Я пытаюсь создать библиотеку Boost FileSystem для проекта.Когда я пытаюсь собрать библиотеку, я получаю следующие ошибки:
In file included from /usr/include/boost/filesystem/convenience.hpp:22:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/usr/include/boost/filesystem/operations.hpp:399:8: erreur: ‘bool boost::filesystem::create_directories(const boost::filesystem::path&)’ previously defined here
bool create_directories(const path& p) {return detail::create_directories(p);}
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:38:18: erreur: ‘not_directory_error’ was not declared in this scope
not_directory_error ) );
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp: In function ‘std::string boost::filesystem::extension(const boost::filesystem::path&)’:
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:49:39: erreur: redefinition of ‘std::string boost::filesystem::extension(const boost::filesystem::path&)’
BOOST_FILESYSTEM_DECL std::string extension(const path& ph)
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:0:
/usr/include/boost/filesystem/convenience.hpp:34:24: erreur: ‘std::string boost::filesystem::extension(const boost::filesystem::path&)’ previously defined here
inline std::string extension(const path & p)
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:51:34: erreur: conversion from ‘boost::filesystem::path’ to non-scalar type ‘std::string {aka std::basic_string<char>}’ requested
std::string leaf = ph.leaf();
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp: In function ‘std::string boost::filesystem::basename(const boost::filesystem::path&)’:
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:60:39: erreur: redefinition of ‘std::string boost::filesystem::basename(const boost::filesystem::path&)’
BOOST_FILESYSTEM_DECL std::string basename(const path& ph)
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:0:
/usr/include/boost/filesystem/convenience.hpp:39:24: erreur: ‘std::string boost::filesystem::basename(const boost::filesystem::path&)’ previously defined here
inline std::string basename(const path & p)
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:62:34: erreur: conversion from ‘boost::filesystem::path’ to non-scalar type ‘std::string {aka std::basic_string<char>}’ requested
std::string leaf = ph.leaf();
Это больше похоже на проблему с кодом, чем на ошибку ссылки, которую я не могу понять.
Сначала я подумал, что используемая мной версия GCC (4.8.5) была проблемой, так как я пытаюсь собрать boost 1.33.Тем не менее, я протестировал его с более поздней версией boost и все еще получал похожие ошибки.
Кроме того, вот код из файла Convenience.cpp, который, кажется, является источником ошибок:
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_FILESYSTEM_SOURCE
#include <boost/filesystem/convenience.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/throw_exception.hpp>
#include <boost/config/abi_prefix.hpp> // must be the last header
namespace boost
{
namespace filesystem
{
// create_directories (contributed by Vladimir Prus) -----------------------//
BOOST_FILESYSTEM_DECL bool create_directories(const path& ph)
{
if (ph.empty() || exists(ph))
{
if ( !ph.empty() && !is_directory(ph) )
boost::throw_exception( filesystem_error(
"boost::filesystem::create_directories",
ph, "path exists and is not a directory",
not_directory_error ) );
return false;
}
// First create branch, by calling ourself recursively
create_directories(ph.branch_path());
// Now that parent's path exists, create the directory
create_directory(ph);
return true;
}
BOOST_FILESYSTEM_DECL std::string extension(const path& ph)
{
std::string leaf = ph.leaf();
std::string::size_type n = leaf.rfind('.');
if (n != std::string::npos)
return leaf.substr(n);
else
return std::string();
}
BOOST_FILESYSTEM_DECL std::string basename(const path& ph)
{
std::string leaf = ph.leaf();
std::string::size_type n = leaf.rfind('.');
return leaf.substr(0, n);
}
BOOST_FILESYSTEM_DECL path change_extension(const path& ph, const std::string& new_extension)
{
return ph.branch_path() / (basename(ph) + new_extension);
}
} // namespace filesystem
} // namespace boost
вот make-файл, который я использую.(обратите внимание, что здесь используется несколько переменных окружения. Они уже назначены и имеют правильные значения.
###########################################################################
# Definition of the compiler and it's options
###########################################################################
CCC = ${PRJ_SOLVER} ${PRJ_DEBUG}
CC = ${PRJ_SOLVER_C} ${PRJ_DEBUG}
LD = ${PRJ_LINK} ${PRJ_DEBUG}
###########################################################################
# Definition of the external includes
###########################################################################
INCLUDE_EXT = -I${HOME}/Documents/ASPECT/boost_1_33_1
###########################################################################
# Sources for /home/slendorm/ASPECT/boost_1_33_1/libs/filesystem
###########################################################################
DIR_1 = ${PRJ_MOD_COUR_REP}/src
SRC_1 = \
${DIR_1}/convenience.cpp \
${DIR_1}/exception.cpp \
${DIR_1}/operations_posix_windows.cpp \
${DIR_1}/path_posix_windows.cpp
OBJ_1 = \
${PRJ_LIB_COUR_REP}/convenience.o \
${PRJ_LIB_COUR_REP}/exception.o \
${PRJ_LIB_COUR_REP}/operations_posix_windows.o \
${PRJ_LIB_COUR_REP}/path_posix_windows.o
###########################################################################
###########################################################################
# Includes and object files pour current directory
###########################################################################
INCLUDE_COUR = -I$(DIR_1)
OBJ_COUR = $(OBJ_1)
###########################################################################
# default compilation
###########################################################################
all: lib
###########################################################################
# dependancies rules for the sources of the current directory
###########################################################################
${PRJ_LIB_COUR_REP}/convenience.o : $(DIR_1)/convenience.cpp
@echo "Compilation en C++: $(DIR_1)/convenience.cpp"
$(CCC) -c $(DIR_1)/convenience.cpp -o ${PRJ_LIB_COUR_REP}/convenience.o ${INCLUDE_COUR} ${INCLUDE_EXT}
${PRJ_LIB_COUR_REP}/exception.o : $(DIR_1)/exception.cpp
@echo "Compilation en C++: $(DIR_1)/exception.cpp"
$(CCC) -c $(DIR_1)/exception.cpp -o ${PRJ_LIB_COUR_REP}/exception.o ${INCLUDE_COUR} ${INCLUDE_EXT}
${PRJ_LIB_COUR_REP}/operations_posix_windows.o : $(DIR_1)/operations_posix_windows.cpp
@echo "Compilation en C++: $(DIR_1)/operations_posix_windows.cpp"
$(CCC) -c $(DIR_1)/operations_posix_windows.cpp -o ${PRJ_LIB_COUR_REP}/operations_posix_windows.o ${INCLUDE_COUR} ${INCLUDE_EXT}
${PRJ_LIB_COUR_REP}/path_posix_windows.o : $(DIR_1)/path_posix_windows.cpp
@echo "Compilation en C++: $(DIR_1)/path_posix_windows.cpp"
$(CCC) -c $(DIR_1)/path_posix_windows.cpp -o ${PRJ_LIB_COUR_REP}/path_posix_windows.o ${INCLUDE_COUR} ${INCLUDE_EXT}
###########################################################################
# cleaning object files
###########################################################################
clean:
@echo ""
@echo "Nettoyage des fichiers objets associes a BoostFileSystem"
rm -rf $(PRJ_LIB_COUR_REP)/*
rm -f $(PRJ_LIB_COUR_REP)/.make.state
@echo ""
###########################################################################
# creation of static library .a
###########################################################################
lib: ${OBJ_COUR}
@echo ""
@echo "Creation de la librairie de BoostFileSystem"
ar -r $(PRJ_LIB_COUR_REP)/libBoostFileSystem.a $(OBJ_COUR)
@echo ""
###########################################################################
# miscelanious
###########################################################################
.INIT:
.DONE:
.SILENT:
${PRJ_KEEP_STATE}:
.SUFFIXES: .o .cc .c
[Редактировать]
Полученный мной make-файл имел клятву включения, чтобыло неправильно. Очевидно, это вызвало некоторые проблемы. Однако теперь, когда я исправил это, я получаю другие ошибки. На этот раз похоже, что они связаны с компилятором, который я использую, но я все еще не уверен. Я нашел людей, которые, казалось, имелипохожая проблема, которую, как они говорят, они решили, заменив #elsif на # else.
вот они
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply.hpp:23:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/iterator/iterator_facade.hpp:34,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/path.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/convenience.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply_wrap.hpp:81:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 1
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply_wrap.hpp:173:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 2
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/bind.hpp:27:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/lambda.hpp:18,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply.hpp:25,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/iterator/iterator_facade.hpp:34,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/path.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/convenience.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply_wrap.hpp:81:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 1
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply_wrap.hpp:173:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 2
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/lambda.hpp:18:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply.hpp:25,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/iterator/iterator_facade.hpp:34,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/path.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/convenience.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/bind.hpp:364:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 1
^
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/bind.hpp:531:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 2
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/lambda.hpp:22:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply.hpp:25,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/iterator/iterator_facade.hpp:34,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/path.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/convenience.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/aux_/full_lambda.hpp:230:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 1
^
In file included from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/iterator/iterator_facade.hpp:34:0,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/path.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/boost/filesystem/convenience.hpp:16,
from /home/slendorm/Documents/ASPECT/boost_1_33_1/libs/filesystem/src/convenience.cpp:17:
/home/slendorm/Documents/ASPECT/boost_1_33_1/boost/mpl/apply.hpp:138:31: erreur: missing binary operator before token "("
#elif BOOST_PP_ITERATION_DEPTH() == 1