Question

I am building TBB under MinGW32 (on Windows 7 64 bit) and linking a simple program to it successfully. Unfortunately, my colleague is unable to do link successfully. We are both running the same version of Windows, the same version of MinGW (mingw-get-inst-20110802), and atttempting to compile the exact same code. Our PATH environment variable is exactly the same (.:/usr/local/bin:/mingw/bin:/bin). Yet, despite all things being equal (as far as I can tell), I can successfully build and run the program, my colleages attempts have failed at the link step. If I give him my tbb.dll, then he can successfully link his program. Thus, I am led to believe that there is something wrong about his build of tbb.dll. We have confirmed (using file) that we are producing 32-bit binaries for all object files and libraries

    $ file a.exe
    a.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit
    $ file ./tbb/tbb30_20110704oss/lib/tbb.dll
    ./tbb/tbb30_20110704oss/lib/tbb.dll: PE32 executable for MS Windows (DLL) (console) Intel 80386 32-bit

The command line we are using to build TBB is:

    mingw32-make compiler=gcc arch=ia32 runtime=mingw tbb

The simple test program we are compiling is:

    #include <tbb/task_scheduler_init.h>
    using namespace tbb;
    int main() {
    task_scheduler_init init;
    return 0;
    }

The command line we are using to build the simple test program

    g++ test1.cpp -I ./tbb/tbb30_20110704oss/include -L ./tbb/tbb30_20110704oss/lib -ltbb

In my case, it builds and links flawlessly. In his case, he gets the error message:

    test1.o: In function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)':
    test1.cpp:(.text._ZN3tbb19task_scheduler_initC1Eij[tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)]+0x33): undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
    test1.o: In function `tbb::task_scheduler_init::~task_scheduler_init()':
    test1.cpp:(.text._ZN3tbb19task_scheduler_initD1Ev[tbb::task_scheduler_init::~task_scheduler_init()]+0x16): undefined reference to `tbb::task_scheduler_init::terminate()'

The message seems to indicate that the linker is having a problem finding the symbols tbb::task_scheduler_init::initialize() and tbb_task_schedule_init::terminate(). However both of these symbols exist in tbb.dll (the nm output below is identical for both him and I):

    $ nm ../tbb/tbb30_20110704oss/lib/tbb.dll | grep task_scheduler_init
    676c9cb8 T __ZN3tbb19task_scheduler_init10initializeEi
    676c9c2c T __ZN3tbb19task_scheduler_init10initializeEij
    676c9b64 T __ZN3tbb19task_scheduler_init19default_num_threadsEv
    676c9afc T __ZN3tbb19task_scheduler_init9terminateEv

Can anyone offer any suggestion as to why I would be able to build and link this simple example, when my colleague cannot link, despite the fact that we are using the same exact tools, binaries, source code, operating system, etc??

Was it helpful?

Solution

SOLVED. This appears to be a defect in MinGW, specifically ld.exe. Reverting from ld version 2.21.1 to ld version 2.21 solves the issue. My colleague and I were using different versions of ld

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top