Error al construir un proyecto Wt. No se puede abrir el archivo de inclusión: 'boost/any.hpp'

Wt v. 3.2.2 and boost libraries v. 1.47 had succesfully installed in my computer and no errors occured in the installation process. Some simple Wt and Boost examples were compiled and ran correctly in the testing process. I use CMake, configured for MSVC 2008, to create the build files for my own Wt projects.

However, when I try to build my own project, I get this error (Cannot open include file: 'boost/any.hpp'). As I saw, boost/any.hpp is included in Wt/WApplication header file.

For further help, my CMakeLists.txt files contents are: CMakeLists.txt placed on project directory:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(WT_EXAMPLE)

SET (WT_CONNECTOR "wthttp" CACHE STRING "Connector used (wthttp or wtfcgi)")

ADD_SUBDIRECTORY(source)

CMakeLists.txt placed on source directory:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(WT_INSTALL_DIR "C:/Program Files/WT/boost_1_47")
SET(BOOST_INSTALL_DIR "C:/Program Files/boost")

ADD_EXECUTABLE(
 GOP.wt
 Main.C
)

SET(WT_LIBS
 optimized wthttp debug wthttpd
 optimized wt debug wtd)

SET(BOOST_LIBS
 boost_signals boost_regex boost_thread boost_filesystem boost_system
 boost_random boost_date_time boost_program_options)

TARGET_LINK_LIBRARIES (
 GOP.wt
 ${WT_LIBS} ${BOOST_LIBS} ${SYSTEM_LIBS}
)

LINK_DIRECTORIES (
 ${WT_INSTALL_DIR}/lib/
 ${BOOST_INSTALL_DIR}/lib/
)

INCLUDE_DIRECTORIES(${WT_INSTALL_DIR}/include)
INCLUDE_DIRECTORIES(${BOOST_INSTALL_DIR}/include)

As I saw in the CMakeCache.txt placed on Wt build directory, paths to boost libraries were found, but ...what about this line?

//The directory containing a CMake configuration file for Boost.
Boost_DIR:PATH=Boost_DIR-NOTFOUND

I asked this question on Wt support forum but I didn't get an answer for about 24 hours...

Noticias: I found that any.hpp is placed on C:\Program Files\boost\boost_1_47\boost\spirit\home\support\algorithm\any.hpp. So, i suspect that there's a concept with the path that searches any.hpp (it's not directly included in boost directory).

preguntado el 31 de julio de 12 a las 15:07

Changed INCLUDE_DIRECTORIES(${BOOST_INSTALL_DIR}/include) to INCLUDE_DIRECTORIES(${BOOST_INSTALL_DIR}), but it doesn't solve my problem. -

I always do the include_directories before the add_executable. Are you sure the ordering does not matter? -

@lap A moderator on Wt support forum posted it as a CMakeLists file format for generating makefiles to build user apps. See redmine.webtoolkit.eu/boards/2/topics/4714 -

I don't see where are you using FindWt y FindBoost modules. Try to message(STATUS ${BOOST_INSTALL_DIR}) to check if this variable is defined. -

As I know, there's no need to use FindWt and FindBoost if the installation paths of Wt and Boost are known and given. Anyway, I managed to solve this... -

2 Respuestas

Problem solved. I did a new Wt build, I placed and rebuild boost in a new path and I wrote CMakeLists for this project with more caution.

Respondido 05 ago 12, 17:08

To include <boost/any.hpp>

Por ejemplo:

#include <boost/any.hpp>
#include <iostream>
#include <vector>
#include <string>

int main() {
    std::vector<boost::any> some_values;

    some_values.push_back(10);
    const char* c_str = "Hello there!";
    some_values.push_back(c_str);
    some_values.push_back(std::string("Wow!"));

    std::string& s = boost::any_cast<std::string&>(some_values.back());
    s += " That is great!\n";
    std::cout << s;
}

we only need a simple cmake file like

# Defines AppBase library target.
project(recipe_01)
cmake_minimum_required(VERSION 3.5)

include(GNUInstallDirs)

set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})

if(CMAKE_CXX_STANDARD EQUAL 98 OR CMAKE_CXX_STANDARD LESS 14)
   message(FATAL_ERROR "app requires c++14 or newer")
elseif(NOT CMAKE_CXX_STANDARD)
   set(CMAKE_CXX_STANDARD 14)
   set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

find_package(Boost 1.60 REQUIRED)

add_executable(main main.cpp)

target_link_libraries(main)

Respondido el 26 de junio de 21 a las 15:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.