0

I've been working with boost under linux for awhile now, but I will soon be working on a Windows project, so I decided to setup Boost for windows, and get it working with QtCreator (also worked with under linux).

So, downloaded and built the windows boost libs and went to QtCreator to try them out under windows, and I've been somewhat perplexed.

main.cpp

#include <iostream>
#include <vector>

#include <boost/timer/timer.hpp>

using namespace std;

vector<int> f();

int main()
{
    cout << "Hello World!" << endl;

    vector<int> r;
    {
        boost::timer::auto_cpu_timer ct;
        r = f();
    }
    return 0;
}

vector<int> f() {
    vector<int> result;

    for (auto i = 0U; i < 10000; i++) {
        result.push_back(i);
    }
    return result;
}

test.pro

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

DEFINES += BOOST_ALL_NO_LIB
INCLUDEPATH+= C:/boost/boost_1_57_0/
LIBS += -L$$quote(C:\boost\boost_1_57_0\stage\lib) -llibboost_timer-vc120-mt-1_57 -llibboost_system-vc120-mt-1_57

include(deployment.pri)
qtcAddDeployment()

Now, I've tried -lots- of variations on the libs and the 'define' is recent, but every time, I get unresolved symbol issues:

main.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat@system@boost@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAAEBVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat@system@boost@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::timer::auto_cpu_timer::auto_cpu_timer(short)" (??0auto_cpu_timer@timer@boost@@QEAA@F@Z) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: __cdecl boost::timer::auto_cpu_timer::~auto_cpu_timer(void)" (??1auto_cpu_timer@timer@boost@@QEAA@XZ) referenced in function main

Now, from what I've read, it seems like I shouldn't have to even state which libraries to import from boost... but that doesn't work either.

EDIT: Tried with the /VERBOSE flag set in for the linker, and its very strange; the bits that stand out are:

Referenced in kernel32.lib(KERNEL32.dll)
    Loaded kernel32.lib(KERNEL32.dll)
Searching C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-1_57.lib:
Searching C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-1_57.lib:
Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\msvcprtd.lib:
Searching C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-gd-1_57.lib:
Searching C:\boost\boost_1_57_0\stage\lib\libboost_chrono-vc120-mt-gd-1_57.lib:
Searching C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-gd-1_57.lib:
Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\MSVCRTD.lib:
Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\OLDNAMES.lib:

Finished searching libraries

Finished pass 1


Searching libraries
    Searching C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-1_57.lib:
    Searching C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-1_57.lib:
    Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\msvcprtd.lib:
    Searching C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-gd-1_57.lib:
    Searching C:\boost\boost_1_57_0\stage\lib\libboost_chrono-vc120-mt-gd-1_57.lib:
    Searching C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-gd-1_57.lib:
    Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\MSVCRTD.lib:
      Found _load_config_used
        Loaded MSVCRTD.lib(loadcfg.obj)
    Searching C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\OLDNAMES.lib:
    Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64\kernel32.lib:

and

Unused libraries:
  C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-1_57.lib
  C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-1_57.lib
  C:\boost\boost_1_57_0\stage\lib\libboost_timer-vc120-mt-gd-1_57.lib
  C:\boost\boost_1_57_0\stage\lib\libboost_chrono-vc120-mt-gd-1_57.lib
  C:\boost\boost_1_57_0\stage\lib\libboost_system-vc120-mt-gd-1_57.lib
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\amd64\OLDNAMES.lib

So, clearly its located and looked at the .lib files, and even noticed the extra includes of the libs I asked for, but not located the code objects to link up with.

Possibly something to do with being on Windows 64? I assumed boost would build as x64 on here, but maybe not. Someone suggested trying the pre-built binaries, will have a look for them.

Doug
  • 775
  • 2
  • 11
  • 24
  • have you tried to delete the `BOOST_ALL_NO_LIB` from the pro file? – megabyte1024 Mar 04 '15 at 06:58
  • No difference; I double checked just now, but as I said, that define is a recent addition to the .pro file. – Doug Mar 04 '15 at 07:09
  • Did you try using the pre-built binaries? – D Drmmr Mar 04 '15 at 08:29
  • Dude. The "dramatic narrative" is nice, but it distracts from the question that has been asked dozens of times on SO – sehe Mar 04 '15 at 09:42
  • What is the compiler used? Last time I checked cmake doesn't actually make the stuff right? – sehe Mar 04 '15 at 09:45
  • I'm not using cmake, I'm using qmake via Qt-creator; the makefile doesn't seem to have any problems, and Visual C++ does seem to process everything fine until the linking stage. – Doug Mar 04 '15 at 10:12
  • @Doug, try to add the [/VERBOSE](https://msdn.microsoft.com/en-us/library/wdsk6as6.aspx) linker option to the pro file. Probably it will give a key to understand the problem. Something like, the linker searches the missing functions in the libboost_timer-vc120-mt-gd_57.lib but only libboost_timer-vc120-mt-1_57.lib is pointed. – megabyte1024 Mar 04 '15 at 11:27
  • @Doug, another probable problem cause. Libraries are inсluded as `-llibboost_timer-vc120-mt-1_57`. But as far as I remember that the libraries should be added either without the `lib` prefix (i.e. -lboost_timer-vc120-mt-1_57) or completely (i.e. -llibboost_timer-vc120-mt-1_57.lib) – megabyte1024 Mar 04 '15 at 11:31
  • Updated with new info – Doug Mar 04 '15 at 19:06
  • @Doug, as you added to the original post, the boost is possibly compiled using 32-bit address model. Try to compile it using 64-bit address model. The [link](http://stackoverflow.com/questions/302208/how-do-you-build-the-x64-boost-libraries-on-windows) explains how to do it. Or [here](http://sourceforge.net/projects/boost/files/boost-binaries/1.57.0/) you are able to find Boost 64-bit binaries. – megabyte1024 Mar 04 '15 at 19:58
  • Yeah, I'm rebuilding them 64bit now - will respond when its done. You'd think there could be some sort of print out in the linker "Found library, but it was 32 bit so I'm ignoring it!" – Doug Mar 04 '15 at 20:06

1 Answers1

1

Well, turns out I assumed too much about the build process of Boost under windows, and it needs to be told if its on a 64 bit machine. Rebuilt the library as 64 bit and its compiled fine now.

Thanks for the suggestions from folk.

Doug
  • 775
  • 2
  • 11
  • 24