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

[question] Problem when boost depends on gtest_main / gmock_main #9623

Closed
playgithub opened this issue Sep 17, 2021 · 1 comment
Closed

[question] Problem when boost depends on gtest_main / gmock_main #9623

playgithub opened this issue Sep 17, 2021 · 1 comment

Comments

@playgithub
Copy link

playgithub commented Sep 17, 2021

Env

  • Windows
  • MSVC
  • conan 1.40.1

CMakeLists.txt

...
find_package(Boost 1.70.0 REQUIRED COMPONENTS locale chrono)
...
target_link_libraries(${PROJECT_NAME}
                      PRIVATE
                          Boost::headers
                          Boost::locale
                          Boost::chrono)
...

Link error

x64-Release\libboost_test_exec_monitor.lib(test_main.obj) : error LNK2019: unresolved external symbol "int __cdecl test_main(int,char * * const)" (?test_main@@YAHHQEAPEAD@Z) referenced in function "public: static void __cdecl boost::detail::function::void_function_obj_invoker0<struct test_main_caller,void>::invoke(union boost::detail::function::function_buffer &)" (?invoke@?$void_function_obj_invoker0@Utest_main_caller@@X@function@detail@boost@@SAXAEATfunction_buffer@234@@Z)

Link error solved

find_package(Boost 1.70.0 REQUIRED COMPONENTS locale chrono)
find_package(GTest REQUIRED)
...
target_link_libraries(${PROJECT_NAME}
                      PRIVATE
                          Boost::headers
                          Boost::locale
                          Boost::chrono
                          GTest::gtest_main)

Problem

The application's entry fucntion becomes main for gtest_main, so the original GUI application (wxWidgets based) never executes. Output as below

Running main() from C:\J\w\BuildSingleReference@6\.conan\data\gtest\cci.20210126\_\_\build\5ad274d83035c78ba2b205e6cf4f1b317aee8e05\source_subfolder\googletest\src\gtest_main.cc
[==========] Running 0 tests from 0 test suites.
[==========] 0 tests from 0 test suites ran. (0 ms total)
[  PASSED  ] 0 tests. 

Questions

How to solve it?
Why does boost depend on gtest in this case?

More Info

similar to bincrafters/community#94

@playgithub playgithub changed the title [question] Problem when boost depends on gtest_main / gmock_main [question] Problem when boost depends on gtest_main / gmock_main Sep 17, 2021
@playgithub
Copy link
Author

It can't be reproduced with a minimal example.

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

No branches or pull requests

1 participant