Xcode C++ omp.h file not found - c++

I’m trying to include openmp to my Xcode C++ project. I have changed my compiler in Xcode to LLVM GCC 4.2, added ”-fopenmp” as a CFlag and enabled OpenMP support in xcode as well. But it still says ”‘omp.h’ file not found” and i am unable to build the project. Does anyone know what could be wrong and how to fix this?

I have had the same problem. Try going to the project navigator using the panel at the left side. Select your project (the one with the blue icon), and a different main window appears. Here, click the relevant file under "Targets" and choose the "Build settings" and "All". Here, search for OpenMP. In my system, it shows up under "LLVM GCC 4.2 - Language". Set "Enable OpenMP Support" to Yes. This should make it work. Make sure to not manually #include "omp.h".
The weird thing is that I don't know how to do this "manually" (i.e. circumventing the built-in Xcode I approach described above).

Related

CodeLite won't detect (installed) MinGW -- and will not compile even with manual configuration

I installed CodeLite and was rightfully put in the direction to install MinGW. I installed MinGW right from where CodeLite suggests/links to it and everything went well there. I then click "scan" on CodeLite to find the just installed compiler and it says it can't find any on the system -- lost already here.
I then just tried to configure the directory of the compiler to one which is provided with MinGW, such as gcc. I try to compile any basic hello world or such and get the error that, "The system cannot find the file path specified." When trying by default it would compile even before actually properly setting up the compiler, so it seems completely backwards on the face of it. Maybe it's some cross/directory issue?
The log shows CMD.exe looking to cd to some weird/incorrect directory. I've changed environment variables to only include MinGW's path and the issue persists. I've changed around global settings/include paths/build settings to point to the compiler, but it just won't get past this.
Aside from manual setup not working and CodeLite being unable to find MinGW despite it being 100% verified and installed properly, I am basically lost here.
I have prior programming experience, but usually with everything out of the box. I'm now trying to get back in but wanted to learn the process of setting up a compiler/getting more "hands on."
I'm pretty sure it's something set up wrong by me, but the problem is clearly that I have no idea what.
CodeLite does not need the compiler to be in the path. You can "tell" CodeLite where it is installed by pointing it to the right folder from Settings->Build Settings
See this wiki page, note that the build settings dialog is a bit outdated, the drop down button does not exist anymore, instead you have a toolbar with green + button, click it instead.
Once you added the compiler, right click on your project and and select Project Settings, under the General tab, choose the compiler you just configured.
I had the same issue where I had MinGW installed and working, then I downloaded CodeLite and went into the setup wizard, where it could not find MinGW.
Essentially the fix I found was closing and re-opening CodeLite.
I saw on the CodeLite site that the compiler should not be in a folder path with spaces in it, so I moved my compiler from "Program Files" to "ProgramFiles" and manually pointed to it using Settings -> Build Settings. However, CodeLite's scan still couldn't find it until I restarted it.
Then I moved my compiler back to its original folder and restarted CodeLite again, it worked.

C++ Lambda error on Mac (gcc out of date?) [duplicate]

This question was asked many times and I failed to replicate all of the solutions I could find. I am unable to find this setting under File->Project Settings (as some suggested). Please be very specific. If you know an answer for Xcode 7, chances are it will work for me too.
It's the same for 7 and 8. From the Project Navigator, select the project. In the main panel, at the top left, select the target. Now the main panel should have General, Resource Tags, Build Settings, Build Phases, & Build Rules along the top. Select Build Settings, select All. Scroll down to "Apple LLVM 8.0 Language C++" and expand it. Change "C++ Language Dialect" to "C++11 [-std=c++11]".
Build Settings -> Linking-> other linker flags -> add to "-lc++"

Cross compiler prefix and path in eclipse

I'm trying to create a C++ project on eclipse. I have installed eclipse-cdt for that.
While creating a project, a pop up window asks for cross compiler prefix and cross compiler path. Could someone please explain what are those and what do I need to add in those fields? Are those fields absolutely necessary to fill?
If you are using a Mac, you can select MacOS GCC instead of Cross GCC. If you are on Windows, you will have to install a C++ compiler. I recommend you install Cygwin, try following the directions here.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/eclipsecpp_howto.html
Once you've installed the C++ compiler, restart Eclipse and try to create the project again. Hope this helps.
In Cross compiler Prefix you need to write 'arm-none-eabi-' and in Cross compiler path you have to select the path for GCC bin folder. You need to install Cygwin GCC for this.
I have found few steps in below link.
https://www3.ntu.edu.sg/home/ehchua/programming/howto/Cygwin_HowTo.html#cygwin
Just in case anybody else is like me and needs more explicit directions as #yeremy is correct in that you have to select MacOSX GCC. It's just that at the point where the OP is, he overshot where he could have made the selection and needs to back up a few windows (about 3) to choose the MacOSX GCC as the Toolchain of choice. Attaching a link below which goes through the steps and which also shows image of window where you can make the selection (figure 11).
Getting Started with C++ for Eclipse - CodeGuru
When Eclipse doesn't detect a toolchain (to be installed separately) it only offers the option "Cross GCC". Don't choose that.
Sites like this tell you that a properly installed toolchain (Cygwin / MinGW) is automatically discovered using the PATH environment variable. This is not the case on my machine.
There's no way to configure a toolchain in Eclipse manually (as of writing) but you can fool Eclipse into finding one without changing your global PATH:
Go to Preferences/C/C++/Build/Environment,
Add a variable PATH and point it to your toolchain path(s), e.g. d:\Mingw\bin;d:\Mingw\msys\1.0\bin. Separate paths with a semicolon.
For newbies just starting out C++ projects in Eclipse:
1 - Click File --> New--> C/C++ Project
2 - In the "Templates for New C/C++ Project" window, Select C++ Managed Build --> Click Next
3 - Provide a project name --> Select "Empty Project" in Project Type section (which is under Executable) and Select "MinGW GCC" in the Toolchains section
4 - Click Finish
Note: Selecting "MinGW GCC" will eliminate the headache of inputting the Cross GCC related prefix and path. Happy C++ learning.
enter image description here

Using Eclipse CDT for Pintool development

So, I've got some stuff that I need to develop with pintools, and I'm having a hard time using eclipse with it all.
I found this, but it doesn't give very specific details. I was hoping that someone could provide very specific instructions as to how to use eclipse on Mac (or linux) to develop pintools.
I tried it a little, and found that on mac you have to install the clang build toolchain, and even then, doing a simple import of the MyPinTool was harder than it seemed because the makefile specifies a lot of extra options/variables that I don't know how best or correctly to configure in eclipse.
You can download pintools. The makefile that I'm talking about is in source/tools/MyPinTool, it sources a file located at tools/makefile.gnu.config
EDIT: by the way, I'm on Mac OS X Lion with an i7 using pin 2.12
c++ --version returns this:
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM
3.1svn) Target: x86_64-apple-darwin11.4.2 Thread model: posix
I'll guess that you are using the newest version of Eclipse (4.2) and that you start working from the template MyPinTool pintool in "source/tools". I'll take those guesses because it is much easier to configure CDT to recognize the pin environment from a compiling tool, rather than manual configuring it.
First create a makefile project from existing source:
Then go to your project properties and select under "C/C++ General" -> "Preprocessor Include..." the "CDT GCC build output parser", make sure that it is enabled and if you are using clang++ as the compiler, that you add it in the compiler pattern:
Now build your pintool from within eclipse (either click on the hammer icon in the toolbar, or right click your projet and select "Build Project"). CDT should parse the build output and resolve all the paths and required macros from it. Basically, now you are good to go... But...
I have found that CDT has some quirks, if this doesn't work, try and do the following:
Check if you are working on a "deep" path (/a/b/c/d/e/f/g/h/i/j/k/l/m), sometimes CDT takes the relative build path used by the make file, and translates it to a wrong absolute path. I've found that working in a "shallower" path resolves this issue (I should open a bug report for this...).
Sometimes the indexer doesn't kick in right away. Try refreshing the project, rebuilding the index (Right click on project then "Index" -> "Rebuild"), and even restarting eclipse then doing this again.
I know it is a bit of voodoo magic, but I got it working :)
I tested this procedure on a fresh kit with MyPinTool but if it still doesn't work, please provide the steps you did and what errors does eclipse give you.

Eclipse live error checking disabled

Few days ago I had to reinstall all my Linux system, and I also had to reinstall Eclipse CDT as I used to work with it since few weeks.
Unfortunately, since then I do not have live error checking anymore... and I miss it ;)
If I create a new Hello World C++ project (New / C++ Project / Hello World C++ project) and then add some errors like calling a method from an nonexistent class or adding any undefined or untyped variable, well Eclispe doesn't underline and report them as it was doing before I had to reinstall it all.
I searched stackoverflow, and tried to deactivate/reactive "Build automatically" without any change. I also verified that the project path is included in the project sources (Project properties / C-C++ general / Path and Symbols / Source Location) but as it already was, it didn't solved the problem.
When I "Build All" the errors are well reported in the "Problems view", and then when I fix one problem and save the file, the error disappear from the Problem view, but then if I add another problem and save, nothing is reported until I build again. Even errors turned to comments still remains underlined until the next "build all".
Do you have any idea to help me reactivate this feature ?
I was under Eclipse Linux 3.5 and I now use Eclipse Linux 3.7.
I installed the Eclipse package: Eclipse C/C++ IDE Indigo SR-1 with Eclipse Platform 3.7.1 and that fixed the problem.
So I guess, there was a problem with the 3.7.0 currently provided by the Ubuntu Software Center.
With this new version all is Ok by default.