2012-03-28 17 views
6

पर मैं विजुअल स्टूडियो 2010 में Boost.Test का उपयोग करने की कोशिश कर रहा हूं, और मुझे इसे काम करने में कुछ परेशानी हो रही है। यहां स्रोत है:बूस्ट। 64-बिट विंडोज

#include "stdafx.hpp" 

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

BOOST_AUTO_TEST_CASE(morphology) 
{ 
    BOOST_CHECK(true); 
} 

stdafx.hpp सचमुच खाली है। प्रोजेक्ट को एक खाली सी ++ प्रोजेक्ट के रूप में बनाया गया था, जो कि हेडर और libs को बढ़ावा देने के लिए सेट की गई निर्देशिकाओं के साथ एक एप्लिकेशन बनाने के लिए सेट किया गया था। मैं Boost.Test द्वारा प्रदत्त main फ़ंक्शन पर इंगित करने के लिए/प्रविष्टि का उपयोग कर रहा हूं।

कुछ चीजें चल रही हैं। सबसे पहले, निर्माण समय में, लिंकर चेतावनी परीक्षण lib में सभी वस्तुओं को अधिक केवल यह दावा करते हुए ".crt अनुभाग मौजूद है, वहाँ बिना क्रिया स्थिर initializers या टर्मिनेटर्स हो सकता है":

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 

कला क्रम, परीक्षण अनुप्रयोग क्रैश main की कॉल पेड़ Boost.Test द्वारा प्रदान के तहत 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()  

कृपया .... कोई मुझे बता वहाँ सिर्फ एक संकलक झंडा मैं सेट नहीं किया है, या कुछ की तरह बेवकूफ है कि ...

+0

[यह आपकी समस्या को हल करने में सहायक हो सकता है] (http://stackoverflow.com/questions/6529003/crt-section-what-does-this-warning-mean)। Google में एक सरसरी पास पर, इस समय मुझे यह सबसे अच्छा मिल सकता है। – MrGomez

+0

हाँ, यह पहली चीज़ थी जो मैंने पाया था। एमएसडीएन सुझाव उपयोगी नहीं लगते हैं, क्योंकि डिफ़ॉल्ट रूप से सी और सी ++ रनटाइम libs के खिलाफ एक खाली प्रोजेक्ट लिंक भी होते हैं। साथ ही, मैं पहले से ही '/ एंट्री' का उपयोग करने के गुण से "नोन्ट्री का उपयोग नहीं कर रहा हूं"। –

+0

सुनिश्चित करने के लिए - आपने स्वयं को बढ़ावा दिया है? यदि हां, तो आप bjam/b2 पर किस विकल्प को पास करते थे? – ildjarn

उत्तर

10

ठीक है, मुझे यह पता चला है। समस्या मुख्य रूप से मुख्य पर इंगित करने के लिए सेटिंग/एंट्री के कारण हुई थी, जो सभी स्थैतिक ऑब्जेक्ट कन्स्ट्रक्टर और रनटाइम इंटिलाइजेशन को छोड़ देता है। एक बार जब मैं /subsystem:console विकल्प सेट करता हूं और बस कंपाइलर को रनटाइम को सही तरीके से सेट करने दें और Boost.Test द्वारा प्रदान किए गए main फ़ंक्शन को कॉल करें, तो यह अपेक्षित के रूप में काम करता है।

क्या परेशानी है।

/subsystem:console पैरामीटर एमएसवीसी लिंकर के लिए है। इसे कॉन्फ़िगर करने के लिए, अपनी प्रोजेक्ट पर राइट-क्लिक करें, Linker पर जाएं Command Line, और संवाद के नीचे /subsystem:consoleAdditional Options जोड़ें। (वीएस2013)

+0

यिक्स का उपयोग कर रहा हूं, परेशान लगता है। यह सुनकर अच्छा लगा कि अब यह काम करता है। –

+0

वाह, मुझे लगता है कि आपने मुझे बहुत समय बचाया है .. वास्तव में एक ही समस्या थी, इसके लिए धन्यवाद। – MOnsDaR

1

I बिना किसी समस्या के x64 पर Boost.Test का उपयोग करें।

क्या आप सत्यापित कर सकते हैं कि आपके रन में चल रहे सी रनटाइम लाइब्रेरी बूस्ट द्वारा उपयोग किए जाने वाले किसी से मेल खाते हैं? प्रतीत होता है कि आपके लिंकर आउटपुट के अनुसार बूस्ट/एमडीडी का उपयोग किया जा रहा है। (MSDN देखें)।

+0

'डंपबिन/सभी का आउटपुट। \ Libboost_unit_test_framework-vc100-mt-gd-1_49.lib | चयन-स्ट्रिंग DEFAULTLIB' 'msvcprtd' और' MSVCRTD' दिखाता है। मैं अपने आवेदन में '/ MDd' का उपयोग कर रहा हूं (जो' MSVCRTD' से लिंक है)। –

+0

तो आप अपनी परियोजना कैसे स्थापित करते हैं? –

+0

[बूस्ट नामकरण योजना] के अनुसार (http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#library-naming), '-mt-gd' का अर्थ बहुप्रचारित डीबग (गैर - मूल रूप से जुड़ा हुआ)। क्या यह डिफ़ॉल्ट सेटिंग्स (/ परियोजना सेटिंग्स में एमडीडी) से मेल खाता है? –