2

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...

Update: 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).

4

2 回答 2

1

问题解决了。我做了一个新的 Wt 构建,我在一个新的路径中放置和重建了 boost,我更加谨慎地为这个项目编写了 CMakeLists 。

于 2012-08-01T16:25:13.407 回答
0

包括 <boost/any.hpp>

例如

#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;
}

我们只需要一个简单的 cmake 文件,比如

# 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)

于 2021-06-26T14:31:55.103 回答