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

Compilation error while using tbb library

Ajay_S_
Beginner
1,722 Views

Hello ,
Warm greetings!

I am stuck at following compilation issue :

In file included from /usr/include/tbb/concurrent_hash_map.h:32:0,

                 from ../../../src/linkedlists/lockfree-list/BTO.h:10,
                 from ../../../src/linkedlists/lockfree-list/BTO.cpp:9,
                 from ../../../src/linkedlists/lockfree-list/intset.c:13:
/usr/include/tbb/tbb_stddef.h:121:56: fatal error: cstddef: No such file or directory
 #include <cstddef>      /* Need size_t and ptrdiff_t */

can someone please share how i can fix this.

PS : on the other hand the same tbb library works fine if i write another simple application using tbb.

 

0 Kudos
6 Replies
Alexandr_K_Intel1
1,722 Views
Ajay, Which compiler and OS are you using?
0 Kudos
Ajay_S_
Beginner
1,722 Views

I am Using Ubuntu 14.04 , and GCC.

0 Kudos
Vladimir_P_1234567890
1,722 Views

hello

do you use gcc or g++ to compile your code?

from the log I see that you are compiling intset.c "C" file where you include C++ file (BTO.cpp). so the error looks that C compiler does not see C++ headers because it shouldn't.

try to rename intset.c to intset.cpp

--Vladimir

0 Kudos
Ajay_S_
Beginner
1,722 Views

Hi Vladimir

I was using g++ to compile intset.c, changing the name to intset.cpp solved the problem for me :).
may i request you , if you can elaborate why C++ header were not seen , eventhough i was using g++?

many thanks  Alexandr and Vladimir for your kind help.

0 Kudos
Vladimir_P_1234567890
1,722 Views

Ajay S. wrote:

may i request you , if you can elaborate why C++ header were not seen , eventhough i was using g++?

This is a question for StackOverflow, not for tbb forum:)

I think by this behaviour compilers are trying to guard developers from stupid errors related to mixing C and C++ code.

--Vladimir

0 Kudos
RafSchietekat
Valued Contributor III
1,722 Views

https://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html:

"g++ is a program that calls GCC and automatically specifies linking against the C++ library. It treats ‘.c’, ‘.h’ and ‘.i’ files as C++ source files instead of C source files unless -x is used."

Hmm...

0 Kudos
Reply