2012-03-28 19 views
6

Estoy tratando de utilizar Boost.Test en Visual Studio 2010, y estoy teniendo algunos problemas para hacerlo funcionar. Aquí está la fuente:Boost.Test en Windows de 64 bits

#include "stdafx.hpp" 

#define BOOST_TEST_MODULE (main) 
#include <boost/test/unit_test.hpp> 

BOOST_AUTO_TEST_CASE(morphology) 
{ 
    BOOST_CHECK(true); 
} 

stdafx.hpp es literalmente vacía. El proyecto se creó como un proyecto C++ vacío, configurado para crear una aplicación, con directorios configurados para apuntar a impulsar encabezados y librerías. Estoy usando/entry para apuntar a la función main proporcionada por Boost.Test.

Parece que suceden un par de cosas. En primer lugar, en tiempo de compilación, el enlazador informa advertencias sobre todos los objetos en el lib prueba, afirmando que "existe la sección .CRT; puede haber inicializadores estáticos no controladas o terminadores":

1>msvcprtd.lib(locale0_implib.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>morphology.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(unit_test_main.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(framework.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(test_tools.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(unit_test_log.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(unit_test_suite.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(results_reporter.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(results_collector.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(unit_test_parameters.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(unit_test_monitor.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(debug.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(progress_monitor.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(plain_report_formatter.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 
1>libboost_unit_test_framework-vc100-mt-gd-1_49.lib(xml_report_formatter.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators 

Arte de tiempo de ejecución, la aplicación se bloquea prueba en algún lugar de la biblioteca Boost.Test bajo el árbol de llamadas de la main proporcionada por Boost.Test:

> Pentachoron.Test.exe!std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > >::begin() Line 787 + 0x13 bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::for_each::begin<std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > > >(const std::list<boost::shared_ptr<boost::runtime::cla::parameter>,std::allocator<boost::shared_ptr<boost::runtime::cla::parameter> > > & t, boost::mpl::bool_<1> __formal) Line 107 + 0xf bytes C++ 
    Pentachoron.Test.exe!boost::runtime::cla::parser::operator[](boost::unit_test::basic_cstring<char const > string_id) Line 169 + 0x41 bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::runtime_config::`anonymous namespace'::retrieve_parameter<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >(boost::unit_test::basic_cstring<char const > parameter_name, const boost::runtime::cla::parser & s_cla_parser, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & default_value, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & optional_value) Line 216 + 0x34 bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::runtime_config::report_sink() Line 470 + 0x8b bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::results_reporter::`anonymous namespace'::results_reporter_impl::results_reporter_impl() Line 59 + 0x31 bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::results_reporter::`anonymous namespace'::s_rr_impl() Line 91 + 0x35 bytes C++ 
    Pentachoron.Test.exe!boost::unit_test::results_reporter::get_stream() Line 120 + 0x5 bytes C++ 
    Pentachoron.Test.exe!`boost::unit_test::unit_test_main'::`1'::catch$3() Line 207 + 0x5 bytes C++ 
    msvcr100d.dll!_CallSettingFrame() Line 44 Asm 
    msvcr100d.dll!__CxxCallCatchBlock(_EXCEPTION_RECORD * pExcept) Line 1337 + 0x15 bytes C++ 
    ntdll.dll!0000000077c50c21()  
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
    Pentachoron.Test.exe!boost::unit_test::unit_test_main(boost::unit_test::test_suite * (int, char * *)* init_func, int argc, char * * argv) Line 179 C++ 
    Pentachoron.Test.exe!main(int argc, char * * argv) Line 238 C++ 
    kernel32.dll!000000007753652d()  
    ntdll.dll!0000000077c2c521()  

por favor, que alguien me diga .... sólo hay una bandera compilador que no puse, o algo estúpido como que ...

+0

[Esto puede ser útil para resolver su problema] (http://stackoverflow.com/questions/6529003/crt-section-what-does-this-warning-mean). En un pase superficial en Google, este es el mejor que puedo encontrar en este momento. – MrGomez

+0

Sí, eso fue lo primero que encontré, también. Las sugerencias de MSDN no parecen útiles, ya que, por defecto, incluso un proyecto vacío se vincula con las bibliotecas de tiempo de ejecución C y C++. Además, ya estoy "no usando/noentry" por la virtud de usar '/ entry'. –

+0

Para estar seguro, ¿ha creado Boost usted mismo? Si es así, ¿qué opciones pasaste a bjam/b2? – ildjarn

Respuesta

10

De acuerdo, lo entendí. El problema fue causado por mi configuración/entrada para apuntar directamente a main, que omite todos los constructores de objetos estáticos y la inicialización de tiempo de ejecución. Una vez que establecí la opción /subsystem:console y dejé que el compilador configurara el tiempo de ejecución correctamente y llamé a la función main suministrada por Boost.Test, funcionó como se esperaba.

¡Qué molestia. El parámetro /subsystem:console es para el enlazador MSVC. Para configurar esto, haga clic derecho en su proyecto, vaya a Linker | Command Line, y agregue /subsystem:console al Additional Options en la parte inferior del cuadro de diálogo. (VS2013)

+0

Yikes, suena molesto. Es bueno saber que ahora funciona. –

+0

Guau, creo que me ahorraste mucho tiempo ... . Tenía exactamente el mismo problema, gracias por eso. – MOnsDaR

1

I usa Boost.Test en x64 sin problemas.

¿Puede verificar que las bibliotecas de tiempo de ejecución de C que está vinculando en su aplicación coinciden con las utilizadas por Boost? Boost parece estar usando/MDd de acuerdo con la salida de su enlazador. (Ver MSDN).

+0

Salida de 'dumpbin/all. \ Libboost_unit_test_framework-vc100-mt-gd-1_49.lib | select-string DEFAULTLIB' muestra 'msvcprtd' y' MSVCRTD'. Estoy usando '/ MDd' en mi aplicación (que enlaza a' MSVCRTD'). –

+0

Entonces, ¿cómo configuras tu proyecto? –

+0

Según el [esquema de nombres de Boost] (http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#library-naming), '-mt-gd' significa depuración multiproceso (no -establemente vinculado). ¿Coincide esto con la configuración predeterminada (/ MDd en la configuración del proyecto)? –

Cuestiones relacionadas