[boost::unit_test] SDL_main build fail
Describe the bug VCPKG install with classic mode.
in my project not use any boost lib,and not include any boost header. when build,the compile show error, this project is a old project compile without vcpkg, use lib and include, When I remove the lib and use vcpkg compile this project, this error is occur. I create a new project,use old source file,but the error already exist.
Environment
- OS: Windows 11
- Compiler: VS2022 17.10.0
To Reproduce Steps to reproduce the behavior:
- ./vcpkg install sdl2[alsa,vulkan]:x86-windows-static
- ./vcpkg install glm:x86-windows-static
- ./vcpkg install sdl2[alsa,vulkan]:x86-windows-static
I delete all file and code only keep this code:
int SDL_main(int argc, char* argv[]) { return 0; }
the error alweays exists!!!
change SDL_main to main the program run!!!
I found console project change main to SDL_main the project compile error! Repro code when
Expected behavior A clear and concise description of what you expected to happen.
Failure logs boost_unit_test_framework-vc144-mt-gd-x32-1_85.lib(unit_test_main.cpp.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite@@YAPAVtest_suite@unit_test@boost@@HQAPAD@Z) referenced in function __catch$?unit_test_main@unit_test@boost@@YAHP6APAVtest_suite@12@HQAPAD@ZH0@Z$4
Additional context Add any other context about the problem here.
### Tasks
Please see #30604 for how to report an issue.
boost/test/unit_test_suite.hpp #ifdef BOOST_TEST_ALTERNATIVE_INIT_API bool init_unit_test() { #else ::boost::unit_test::test_suite* init_unit_test_suite( int, char* [] ) { #endif
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API return true; } #else return 0; } #endif
in SDL2/SDL_main.h #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) #define main SDL_main #endif //-------------------------------------- #include "boost/test/unit_test_suite.hpp" boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { return nullptr;//program run here...... }
int SDL_main(int argc, char* argv[]) { return 0;//program canot run this code!!! }
This error is incredible
This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 28 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.
@warsark, sorry for the late reply, I followed your steps to reproduce:
./vcpkg install sdl2[alsa,vulkan]:x86-windows-static
./vcpkg install glm:x86-windows-static
What's next?