Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ajay_S_
Beginner
347 Views

Compilation error while using tbb library

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
347 Views

Ajay, Which compiler and OS are you using?
Ajay_S_
Beginner
347 Views

I am Using Ubuntu 14.04 , and GCC.

347 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

Ajay_S_
Beginner
347 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.

347 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

RafSchietekat
Black Belt
347 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...

Reply