4

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??

user992113
  • 163
  • 1
  • 9
  • Do you have the same link issues with the DLL built on your colleague's machine? – Alexey Kukanov Jan 11 '12 at 15:23
  • Yes. If I link against tbb.dll built on my colleague's machine then I see the same undefined reference to "initialize" and "terminate" errors. If I build against the tbb.dll built on my own machine then everything is fine. Which leads me to believe the problem has something to do with the way his tbb.dll is built. – user992113 Jan 11 '12 at 21:56
  • It might make sense to compare the content of the DLLs (using nm or a similar tool) and look for differences that you cannot easily explain. Maybe this will give you some clue of what can be wrong. – Alexey Kukanov Jan 12 '12 at 14:00

1 Answers1

6

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

user992113
  • 163
  • 1
  • 9