Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

Help with TBB in Ubuntu 9.04

newbie_tbb
Beginner
771 Views
Hello everybody!

First of all, sorry if I made any mistakes writting this... my English is a bit rusty...

I've downloaded tbb22_20090809oss_lin.tgz and uncompressed it in my home directory.

I've set the environment variable TBB22_INSTALL_DIR in my .bashrc file -> TBB22_INSTALL_DIR=/home/me/tbb22_20090809oss and exported it.

Also, I'vet set the enviornment variables LIBRARY_PATH and CPATH in .bashrc as shown below:
  • CPATH=$TBB22_INSTALL_DIR/include
  • LIBRARY_PATH=$TBB22_INSTALL_DIR/ia32/cc4.1.0_libc2.4_kernel2.6.16.21/lib
(my gcc version is 4.3.3 and my kernel version is2.6.28-17 ; so I chose cc4.1.0_libc2.4_kernel2.6.16.21 'cause it was the most similar one...)
and exported them.

So I tried to compile this piece of code:

#include "tbb/task_scheduler_init.h"

using namespace tbb;

int main() {
task_scheduler_init init;
return 0;
}


and received this message:

g++ foo_2.cpp
/tmp/ccqTeeLT.o: In function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)':
foo_2.cpp:(.text._ZN3tbb19task_scheduler_initC1Eij[tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)]+0x2f): undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
/tmp/ccqTeeLT.o: In function `tbb::task_scheduler_init::~task_scheduler_init()':
foo_2.cpp:(.text._ZN3tbb19task_scheduler_initD1Ev[tbb::task_scheduler_init::~task_scheduler_init()]+0x16): undefined reference to `tbb::task_scheduler_init::terminate()'
collect2: ld returned exit status 1

Any help?

Thanx!!


0 Kudos
14 Replies
Vladimir_P_1234567890
771 Views

Could you set LD_LIBRARY_PATH=$LIBRARY_PATH:$LD_LIBRARY_PATH?
It looks like default libtbb.so.2 was taken from the system library path.

update:
there is also some infofor the same topic
http://ubuntuforums.org/archive/index.php/t-688480.html

--Vladimir
0 Kudos
newbie_tbb
Beginner
771 Views

Could you set LD_LIBRARY_PATH=$LIBRARY_PATH:$LD_LIBRARY_PATH?
It looks like default libtbb.so.2 was taken from the system library path.

update:
there is also some infofor the same topic
http://ubuntuforums.org/archive/index.php/t-688480.html

--Vladimir

Thanks a lot!

I'll check it out!
0 Kudos
newbie_tbb
Beginner
771 Views
Hi again!

I donwloaded the tbb packages from Synaptics... I forgot to look there!

Now it compiles!!

However.. when I try to compile the substring example:

g++ -O2 -DNDEBUG -o sub_string_finder sub_string_finder.cpp -ltbb
g++ -O2 -DNDEBUG -o sub_string_finder_extended sub_string_finder_extended.cpp -ltbb
g++ -O2 -DNDEBUG -o sub_string_finder_pretty sub_string_finder_pretty.cpp -ltbb
./sub_string_finder_extended
Done building string.
Done with serial version.
make: *** [test] Segmentation Fault

And if I try to execute ./sub_string_finder I get a segmentation fault.

Thanks for your help!


0 Kudos
Vladimir_P_1234567890
771 Views
Quoting - newbie_tbb
Hi again!

I donwloaded the tbb packages from Synaptics... I forgot to look there!

Now it compiles!!

However.. when I try to compile the substring example:

g++ -O2 -DNDEBUG -o sub_string_finder sub_string_finder.cpp -ltbb
g++ -O2 -DNDEBUG -o sub_string_finder_extended sub_string_finder_extended.cpp -ltbb
g++ -O2 -DNDEBUG -o sub_string_finder_pretty sub_string_finder_pretty.cpp -ltbb
./sub_string_finder_extended
Done building string.
Done with serial version.
make: *** [test] Segmentation Fault

And if I try to execute ./sub_string_finder I get a segmentation fault.

Thanks for your help!



It looks like environmentissues and $CPATH points to newer headers but $LD_LIBRARY_PATH points to older libs. Could you check that CPATH and LD_LIBRARY_PATH look to the same package?

--Vladimir
0 Kudos
clhjoe
Beginner
771 Views
Hi,
I havesimilarproblem. I cross-compiled the TBB library and put the libraries into
"/opt/tbb-new/basedir/build/linux_mpcore_arm-none-linux-gnueabi-gcc_cc4.2.4_libc2.10.1_kernel2.6.31_release/" (include libtbb.so/libtbb.so.2)

I compile the source by:$ arm-none-linux-gnueabi-g++ -o test test.cpp -I /opt/tbb-new/basedir/include/ -mcpu=mpcore -L/opt/tbb-new/basedir/build/linux_mpcore_arm-none-linux-gnueabi-gcc_cc4.2.4_libc2.10.1_kernel2.6.31_release/ -ltbb

but it still shows:
/tmp/ccuPHvOb.o: In function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)':
test.cpp:(.text._ZN3tbb19task_scheduler_initC1Eij[tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)]+0x3c): undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
collect2: ld returned 1 exit status

so..what is the problem?

0 Kudos
Alexey-Kukanov
Employee
771 Views
Quoting - clhjoe
Hi,
I havesimilarproblem. I cross-compiled the TBB library and put the libraries into
"/opt/tbb-new/basedir/build/linux_mpcore_arm-none-linux-gnueabi-gcc_cc4.2.4_libc2.10.1_kernel2.6.31_release/" (include libtbb.so/libtbb.so.2)

I compile the source by:$ arm-none-linux-gnueabi-g++ -o test test.cpp -I /opt/tbb-new/basedir/include/ -mcpu=mpcore -L/opt/tbb-new/basedir/build/linux_mpcore_arm-none-linux-gnueabi-gcc_cc4.2.4_libc2.10.1_kernel2.6.31_release/ -ltbb

but it still shows:
/tmp/ccuPHvOb.o: In function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)':
test.cpp:(.text._ZN3tbb19task_scheduler_initC1Eij[tbb::task_scheduler_init::task_scheduler_init(int, unsigned int)]+0x3c): undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned int)'
collect2: ld returned 1 exit status

so..what is the problem?


I suspect that some name mangling differences prevent the function from being exported for this architecture.
Could you please use nm or objdump or otheravailable binary tool and check that the desired function is exported by the TBB shared libraries you built? Also check if the desired symbol is present in one of the object files (task.o presumably), and whether its decorated name correspond to the name listed in linXX-tbb-export.def.
0 Kudos
clhjoe
Beginner
771 Views

I suspect that some name mangling differences prevent the function from being exported for this architecture.
Could you please use nm or objdump or otheravailable binary tool and check that the desired function is exported by the TBB shared libraries you built? Also check if the desired symbol is present in one of the object files (task.o presumably), and whether its decorated name correspond to the name listed in linXX-tbb-export.def.
hi,
Sorry I'm not really understand your mentions.I use nm to get the information of libtbb.so in attachment.
And I don't know what to check between the result of $ nm task.o and lin32-tbb-export.def.
Thank you for your help.
0 Kudos
Alexey-Kukanov
Employee
771 Views
Quoting - clhjoe
hi,
Sorry I'm not really understand your mentions.I use nm to get the information of libtbb.so in attachment.
And I don't know what to check between the result of $ nm task.o and lin32-tbb-export.def.
Thank you for your help.

In your nm generated file, there are two records for task_scheduler_init::initialize() corresponding to two overloads of the method:
0001068c T _ZN3tbb19task_scheduler_init10initializeEi
0001058c t _ZN3tbb19task_scheduler_init10initializeEij
But only the first one is publicly exported (designated by the upper case T), and this is the method with a single argument. The second method with two arguments is present but not exported (as designated by the lower case t).

The exported functions and methods are controlled by DEF files in src/tbb. And the method of interest is described differently for 32- and 64-bit versions of the library (see the very last symbol):
lin32-tbb-export.def: _ZN3tbb19task_scheduler_init10initializeEij
lin64-tbb-export.def: _ZN3tbb19task_scheduler_init10initializeEim
The difference is due to different underlying type for size_t (the type of the second argument) for 32- and 64-bit code.

The method that exists in the library without a public entry point uses 32-bit decoration scheme. I guess that when the library was compiled, 64-bit DEF file was used.Hopefully this information would be enough for you to nail down the problem; but if you need further help, I will need to see the platform-specific makefiles.
0 Kudos
clhjoe
Beginner
771 Views

Sorry I still can't solve this problem. I tried to cross compile by follow the thead http://software.intel.com/en-us/forums/showthread.php?t=67133 . And the plateform-specific makefile I use are in the attachment. I'm very appreciate for your help.

0 Kudos
Alexey-Kukanov
Employee
771 Views

Thanks for the info, and for raising the issue. I see now that it's our bug in determining which DEF file should be used. We will see how to fix it.

Meanwhile in order to build the library, you may apply the following workaround:

- open build/linux.inc
- find the following line:
TBB.DEF = $(tbb_root)/src/tbb/$(def_prefix)-tbb-export.def
-change itto:
TBB.DEF = $(tbb_root)/src/tbb/lin32-tbb-export.def
- try to recompile.

If you also need to compile for x86, then select the appropriate variant for the TBB.DEF based on $(arch), e.g.

ifeq (mpcore,$(arch))
    TBB.DEF = $(tbb_root)/src/tbb/lin32-tbb-export.def
else
    TBB.DEF = $(tbb_root)/src/tbb/$(def_prefix)-tbb-export.def
endif 
0 Kudos
clhjoe
Beginner
771 Views

Hi,

I had compiled successfully. However, when I execute the binary code on ARM11MPCORE, it shows "segmentation fault". Below is my source code

[cpp]#include 
#include 
#include 
#include 
using namespace std;
struct OpFor{
    void operator()(const tbb::blocked_range &r) const
    {
        for(int i=r.begin(); i!=r.end(); ++i)
        {
            sleep(5);
            cout << i << "-";
        }
        cout << endl;
    }
};

int main()
{

tbb::task_scheduler_init init(1);
    OpFor f;

    tbb:: parallel_for(tbb::blocked_range(0,10), f);
    cout << endl;
    return 0;
}
[/cpp]
But, If I comment " tbb:: parallel_for(tbb::blocked_range(0,10), f);"int the main function, everything is OK. So, how should I fixed it ?Thanks for your help!

0 Kudos
clhjoe
Beginner
771 Views
0 Kudos
clhjoe
Beginner
771 Views
So... is there anyone can help please?
0 Kudos
Alexey-Kukanov
Employee
771 Views

For what it's worth, there is no problem in how you use TBB in your code; so it seems the port to that particular platform does not work as expected.Sorry thatI can not really help you.

0 Kudos
Reply