I ran brew install tbb on my mac os sierra device. After running this i should be able to include #include into my c++ projects right? For some reason when I compile these files are not found. Help would be appreciated
-
Hi. Thanks for responding. I wrote a concurrent queue implementation for my own application and want to test it against intel tbb's concurrent queue. I use OS X sierra. I simply installed homebrew and then ran 'brew install tbb' in terminal. I assume this sets all the environment variables and what not? Then when i try to access the concurrent_queue.h header through the include statement i get the error: /Users/irtazasafi/ClionProjects/as2/main.cpp:7:9: fatal error: 'concurrent_queue.h' file not found – Muhammad Safi Oct 05 '16 at 06:41
-
I tried both. When i try
it still cannot find the file. Brew says it's already installed (tbb-4.4-20160916 already installed). – Muhammad Safi Oct 05 '16 at 06:52
1 Answers
A few things...
Check the options on packages
Before you install any homebrew
packages, get in the habit of checking the available options rather than just accepting the default ones. It often gives you insights into features that are available which you are unaware of. So, for tbb
:
brew options tbb
Output
--c++11
Build using C++11 mode
So, it is probably worth using:
brew install tbb --c++11
or
brew reinstall tbb --c++11
Find the include files and libraries yourself first
If you are trying to include a header file, try looking for it yourself first, using find
:
find /usr /opt concurrent_queue.h
Output
/usr/local/Cellar/tbb/4.4-20160916/include/tbb/concurrent_queue.h
So there is only one concurrent_queue.h
on my system. Now we need to tell the compiler how to find it. If you look in /usr/local/include
, which is where homebrew
puts headers, you will see this:
ls -l /usr/local/include | grep tbb
lrwxr-xr-x 1 mark admin 38 5 Oct 09:10 tbb -> ../Cellar/tbb/4.4-20160916/include/tbb
So, the tbb
headers are in /usr/local/include/tbb
(which is a symlink to homebrew
's Cellar), so you need to make sure your compiler is looking in /usr/local/include
.
g++-6 -I/usr/local/include ...
Remember you can check where your compiler is looking by using -v
, like this:
g++-6 -v ...
Once you helped the compiler find the header files (#includes), you will then need to help the linker find the libraries, so your command will become:
g++-6 -I/usr/local/include program.cpp -o program -L /usr/local/lib -ltbb

- 191,897
- 31
- 273
- 432
-
find /usr /opt concurrent_queue.h says I have no concurrent_queue.h on my disk. – Muhammad Safi Oct 09 '16 at 17:28
-
Irtazas-MacBook-Pro:~ irtazasafi$ brew install tbb --c++11 Warning: tbb-4.4-20160916 already installed – Muhammad Safi Oct 09 '16 at 17:30
-
-
g++ std=c++11 main.cpp When I try and do g++-6 -I/usr/local/include ... i get the error : -bash: g++-6: command not found – Muhammad Safi Oct 09 '16 at 18:11
-
-
No. I have the developer tools that come with Xcode. The find command does return the exact same location as you mentioned in the comment. – Muhammad Safi Oct 09 '16 at 18:31
-
1So, if you are using `g++`, try `g++ -std=c++11 main.cpp -I /usr/local/include -o main -ltbb` – Mark Setchell Oct 09 '16 at 18:34
-
-
1
-
thank you. Haven't used c++ for ages so come across as a dumbass :p – Muhammad Safi Oct 09 '16 at 19:11
-
No problems - I'm glad it worked for you. Good luck with your project and come back and ask more questions if you get stuck - answers are free – Mark Setchell Oct 09 '16 at 22:00