Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost库默认配置存在问题 #5693

Open
heheda123123 opened this issue Nov 7, 2024 · 3 comments
Open

boost库默认配置存在问题 #5693

heheda123123 opened this issue Nov 7, 2024 · 3 comments
Labels

Comments

@heheda123123
Copy link
Contributor

Xmake 版本

v2.9.6+dev.86936573d

操作系统版本和架构

windows 11

描述问题

写如下的代码

#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char** argv) {
    std::cout << "hello world!" << std::endl;
    return 0;
}

xmake.lua如下

add_rules("mode.debug", "mode.release")
add_requires("boost")

target("testboost")
    set_kind("binary")
    add_files("src/*.cpp")
    add_packages("boost")

编译会报错如下

PS C:\Users\Administrator\temp\testboost> xx
[ 50%]: compiling.release src\main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe" -c -nologo -O2 -DBOOST_ALL_NO_LIB /EHsc -external:W0 -external:IC:\Users\Administrator\AppData\Local\.xmake\packages\b\boost\1.86.0\b6d5253e19074abb822445198b75eace\include -DNDEBUG -Fobuild\.objs\testboost\windows\x64\release\src\main.cpp.obj src\main.cpp
error: @programdir\core\main.lua:329: @programdir\actions\build\main.lua:148: @programdir\modules\async\runjobs.lua:325: @programdir\modules\private\action\build\object.lua:91: @programdir\modules\core\tools\cl.lua:741: main.cpp
Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
C:\Users\Administrator\AppData\Local\.xmake\packages\b\boost\1.86.0\b6d5253e19074abb822445198b75eace\include\boost/asio/time_traits.hpp(23): fatal error C1083: 无法打开包括文件: “boost/date_time/posix_time/posix_time_types.hpp”: No such file or directory

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:1004]:
    [@programdir\modules\core\tools\cl.lua:741]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [@programdir\modules\core\tools\cl.lua:680]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:244]:
    [@programdir\core\tool\compiler.lua:288]: in function 'compile'
    [@programdir\modules\private\action\build\object.lua:91]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:122]: in function 'build_object'
    [@programdir\modules\private\action\build\object.lua:147]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:241]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:244]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:223]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:1004: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>
PS C:\Users\Administrator\temp\testboost>

可以看到是找不到 boost/date_time/posix_time/posix_time_types.hpp,对于什么config都不带的boost库,是否应该保证启用的这些库都能正常使用呢,不然启用这个库不能使用也没用

期待的结果

什么config都不带的情况下,加入了boost依赖,对于包含进去的库,应该都能正常使用

工程配置

已提供

附加信息和错误日志

已提供

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: There is a problem with the boost library

@heheda123123 heheda123123 changed the title boost库存在问题 boost库默认配置存在问题 Nov 7, 2024
@star-hengxing
Copy link
Contributor

boost 一些头文件库 ,依赖一些 buildable (非头文件库),目前 cmake 处理不了这种 asio(header-only) 和 data_time(buildable) 的依赖问题。
以前 b2 大概也会出现这种问题,不过只会安装 buildable 库的头文件而不会编译(不确保所有依赖 buildable 的头文件库是否都这样处理)。

现在有几个选择:

  1. 安装所有头文件库 ,如果因为依赖编译不过,让用户自己开启 buildable library 的选项安装所需依赖。
  2. 安装所有头文件库 ,包管理根据依赖信息自动去安装 buildable library ,但因为要安装所有头文件库,差不多把 boost 完全构建一遍了。
  3. 提供新的选项,让用户选择用哪些头文件库,包管理根据依赖关系自动处理。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Some boost header libraries depend on some buildable (non-header libraries). Currently, cmake cannot handle this dependency problem of asio (header-only) and data_time (buildable).
This problem may also have occurred in b2 in the past, but only the header files of the buildable library will be installed and not compiled (it is not guaranteed whether all header file libraries that rely on buildable are handled this way).

There are several options now:

  1. Install all header file libraries. If it cannot be compiled due to dependencies, let the user enable the buildable library option to install the required dependencies.
  2. Install all header libraries. The package management will automatically install the buildable library based on the dependency information. However, because all header libraries need to be installed, boost is almost completely built.
  3. Provide new options to allow users to choose which header file libraries to use, and package management will automatically handle them based on dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants