chikuba
chikuba

Reputation: 4357

Qt creator: undefined reference to `boost::gregorian::greg_month::as_short_string() const'

Trying to run the following code in Qt Creator on Win7 64bit.

#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>

int main() {
    using namespace boost::posix_time;
    ptime t = microsec_clock::universal_time();
    std::cout << to_iso_extended_string(t) << "Z\n";
}

This is my *.pro file:

INCLUDEPATH += "C:\Program Files (x86)\boost\boost_1_47"
CONFIG += boost
LIBS += -L"C:\Program Files (x86)\boost\boost_1_47\lib"
LIBS += -lboost_date_time-vc71-mt-1_47

I get the following error:

c:\Program Files (x86)\boost\boost_1_47\boost\date_time\date_formatting.hpp:49: error: undefined reference to `boost::gregorian::greg_month::as_long_string() const'

c:\Program Files (x86)\boost\boost_1_47\boost\date_time\date_formatting.hpp:44: error: undefined reference to `boost::gregorian::greg_month::as_short_string() const'

How can I get this to work? I read that I need to build the date time lib but I'm not to sure how I would do that.

Upvotes: 2

Views: 2032

Answers (1)

alexisdm
alexisdm

Reputation: 29896

These boost library binaries are compiled with and for the Visual C++ compiler (you can guess by the 'vc71' in the file name), but you are using QtCreator with the MinGW compiler and you can't mix C++ libraries compiled with different compilers (only the C part of the library would be usable).

You can either continue to use MinGW and recompile boost yourself *, or change the compiler used by QtCreator in the project configuration, assuming you have installed any version of Visual C++ and the Qt binaries for that compiler.

* : Since MinGW can be configured with lot of different incompatible options, it is safer to recompile boost than using precompiled binaries, unless you are sure they were built with the same MinGW that is included in your Qt SDK.

Upvotes: 3

Related Questions