Change compiler to clang-omp++ in xcode - clang

I'm trying to follow the instructions on OpenMP®/Clang to enable openmp in Xcode. But Add a new user-defined setting CC with the value /usr/local/bin/clang-omp confuses me. I tried to change the Build Settings->Build Options-> Compilers for C/C++/Objective-C to /usr/local/bin/clang-omp++, but I got Unsupported Compiler error.
Please help, thanks ahead.

You should be able to set some user build settings to choose your compiler. You can set special build settings from the command line using the following syntax.
xcodebuild build FOO=bla
Disclaimer: some of those build settings are undocumented (afaik). Use
at your own risk.
Here are a few build settings that I found useful to inject C flags:
OTHER_CFLAGS
OTHER_CPLUSPLUSFLAGS
or to replace the compiler(s) and linker(s):
CC
CPLUSPLUS
LD
LDPLUSPLUS
LIBTOOL
The same approach works to control the "analyze" action:
CLANG_ANALYZER_EXEC
CLANG_ANALYZER_OTHER_FLAGS
Sourced from cfe-dev mailing list

Related

clang: error: no such file or directory when trying to run app

I have added flags in compile sources for janrain integration in my app.
When i m trying to run app or archiving build on that time i faced this error.
I already added that file to correct build path and its already contain within project.
Here i attached snaps of that error :
Can anyone please help me to solved this? Thanks in Advance.. :)
Go in your target compile sources and check its may be that you used the filename as compiler flag in ARC or you may used wrong compiler flags.
i hope its worked.
just check your compile sources its may that you give wrong flag for ARC or your file is not available with testtareget.
Just check your flags which u set in compile sources. Either its repeated or either its wrongly used.
This problem raised because of i am passing this class name to set in compile sources flag instead of -fno-objc-arc.
Check with your existing flags in your compile sources its may be that you used the filename as compiler flag.
Check once NPSAuthenticatedUser+Model is existing or not in your project. Whether it is in red color or what.
If it is red color remove and re add it if needed.
Please check this answer.
clang: error: no such file or directory: ASIAuthenticationDialog.m
Clean and Build your Project and then try again.
make sure you in the Other Linker Flags in case you use '$(inherited)', add only $(inherited) without the 2 ''
None of the possible solutions above worked in my scenario.
For a Swift project with Objective-C file(s) included make sure they are not added to the Build Phases -> Compile Sources section of your project's target.
I had a Swift project where after I dragged Objective-C files into the project the implementation files were added to the Build Phases -> Compile Sources section. Once I removed the Objective-C implementation files from the Compile Sources section my project worked happily once again.
This was using Xcode version 8.3 (8E162).

Building Cocoa touch framework with c++11 code

I am trying to make an iOS framework. My code includes c++11 features.
When I build the framework target I get errors such as:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:56:9: No member named 'clock_t' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:58:9: No member named 'time_t' in the global namespace; did you mean 'size_t'?
How can I resolve this? Thanks.
UPDATE:
Here is my Apple LLVM 6.0 - Language-c++ settings:
Regular iOS project with that c++11 code compiles without errors.
you need to explicitly add libc++ as a linked library under general tab.
I don't know how far it will work fine in your scenario. I got similar kind of error when I tried to compile and build so. I will share what I did :
1.Goto your project Build Settings.
2.Click Build Settings.
3.Search for Apple LLVM 6.0 - Language-c++ .
4.set c++ standard library as libstdc++ .
Then try compile the project.
This might not the exact solution.
I just shared what worked for me when I am facing the similar kind of errors as yours.
Thank you!
Have you tried setting the C++ Language Dialect to C++11? It's in the same place as the C++ standard library setting:
Go to Build Settings
Select your Target, and click Build Settings.
Search for Apple LLVM 6.0 - Language-C++
Set C++ Language Dialect to C++11.
You might also have to set the C++ Standard Library to libc++.
Xcode adds all headers to the "Headers" build phase by default. So, I solved my issue by removing all unnecessary C++ headers from the build phase.

Apple LLVM 6.0 Error: clang failed with exit code -1

I created my app on my MacBook Air and kept working with it there which was fine. Then I started working with a colleague who used another Mac (of course). Anyway, we share our Xcode project via Dropbox (we are just switching to BitBucket, don't worry ;) ), when he tried to open the project on his Mac there was a Apple LLVM 6.0 Error with the following error while on my computer the same project runs perfectly:
clang: error: no such file or directory: '/Users/linus/Dropbox/Apps/My App/Projekt/My App/SlideMenu/SlideMenu-Prefix.pch'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
The last lines of the error seem most important to me which is why I listed them here.
I do know this question was asked several times now but there was never a useful answer which worked for me. I tried to disable the Foundation Assertions as it said in another answer on this topic but that did not work. Also I restarted & even reinstalled Xcode and all files are existing, none should be missing.
I am running Xcode 6.0.1 and Mac OS X 10.10. I hope someone can answer this, I'm kind of desperate now...
Hey I just ran into the same problem. Basically I deleted my tests target. I found this:
Errors When Compiling iOS 8, Xcode 6.0.1
Which basically says that:
Click on the name of your project on the list of files/folders on the
left in Xcode (at the very top of the list). Look at the "Targets"
section on the left-hand side of the window to the right. Likely,
there's two listed with the second being a "test" item. Right-click on
that item and select "delete". Then try to run the project again. See
screenshot below for a visual cue.
And a picture to help you out:
Hope this helps!
EDIT: Also in the tests target, I actually found that I didn't necessarily need to delete it, there was a broken path, just fixing it makes it all work again.
Make new file: ⌘cmd+N
iOS/Mac > Other > PCH File > YourProject-Prefix.pch.
Project > Build Settings > Search: "Prefix Header".
Under "Apple LLVM 6.0" you will get the Prefix Header key
Type in: "YourProjectName/YourProject-Prefix.pch"
Clean project: ⌘cmd+⇧shift+K
Build project: ⌘cmd+B
Solved this by going to my project settings and changing the deployment target. The deployment target was originally at 7.0. When i changed it from iOS 8.0 -> 9.1 it works fine and there is no error.
Hope that helps :)
You do not need to delete the overall build settings. Just change the Library Search Paths, here are the steps:
Click on your project name (very top of the navigator)
Click on your project target
Click the tab Build Settings
Search for LIBRARY_SEARCH_PATHS
Change its value to $(inherited) flag.
Here you go!
Or else you can always remove the build setting at all! Cheers!
One of the simple things I did I went into "Build Options" and changed the property for Enable Bitcode from yes to no
This fixed my issue.
Screenshot of Settings
clang can't locate your precompiled header file. Have you checked whether there is a file named SlideMenu-Prefix.pch in /Users/linus/Dropbox/Apps/My App/Projekt/My App/ ? The path to the precompiled header file is specified by the "Prefix Header" build setting for your target.
Try,
In Xcode project settings,
Targets-> Tests section-> Build Settings->Linking remove all linkig
OR Remove Tests Section as a whole.
Build again and Its done!!

CMake override libraries from find_package

I'm running find_package(OpenCV, REQUIRED) to locate a library. It's installed on the build system and the target system, however the target is slightly different in that one part of the library is not available.
So when building, I get back linker flags like -lfoo -lbar. However, bar isn't available on the target machine and I'm not using it anywhere in the application. Of cource, since it was linked in, the runtime linker complains that it cannot be found.
Is there anyway to override the libraries linked in with find_package? I'll probably just do a string replace type of solution, though I'd be thankful for any help there too since I'm a CMake novice.
Thanks
I suppose you can remove undesired libraries from OpenCV_LIBRARIES variable:
list(REMOVE_ITEM OpenCV_LIBRARIES bar)
Alternatively, you can read FindOpenCV.cmake source to check if it supports COMPONENTS keyword.

Xcode Archive debug strip errors

I am trying to integrate a large legacy C++ library with an iOS app. We are able to build and run on device but we are not able to archive the app. Archiving fails with the following error.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip failed with exit code 1
I did a -v on the strip and get a series of warnings similar to
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: symbols referenced by relocation entries that can't be stripped in: /MyApp/DerivedData/SmartMusic_iPad/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/UninstalledProducts/libMyLib-iOS.a(MyWhatever.o)
It is not clear if this message is a warning or the reason for the failure. There are no other indications of problems in the strip output. Any clues?
Under build settings for the static library target, select NO for 'deployment postprocessing' and 'strip debug symbols during copy'. It is compiled code so it doesn't need symbols stripped.
I was experiencing the same error ('usr/bin/strip failed with exit code 1') and this fixed it for me.
In my case I added the following to my library Target build settings and started working fine:
Dead Code Stripping: NO
Strip Debug Symbols During Copy: NO for all configurations
Strip Style: Non-Global Symbols
The default Strip Style in Xcode is All Symbols, which is okay for an executable but for a library you need to set this to Non-Global Symbols as global symbols must be be preserved.
Since stripping is only done as part of the deployment post processing, debug builds are usually not affected by this option as for them the setting DEPLOYMENT_POSTPROCESSING is usually set to NO. But when archiving, you create a release build and here DEPLOYMENT_POSTPROCESSING is set to YES by default and thus you need to have the correct strip style set.
There are different options to strip (see manpage) and I think you'll want to use the -r option. You can set the type of stripping to perform from within the Xcode project settings. See if you can relate the options in Xcode with the options in the manpage.
I have same your problem, but I edit DEPLOYMENT POSTPROCESSING to NO but it doesn't work.
I just went to Build Phases tab in my target, and in Copy Bundle Resources I removed Foundation.framework, and then I add Foundation.framework into Link Binary With Libraries, it works for me!
Hope that will be solve your problem!
What worked for me was when I decided to fix another issue in Xcode 10.1, my simulator hadn't been booting up and I ignored until I really needed it, running the command below helped fix this issue
sudo chmod 1777 /private/tmp
I fixed this error by freeing up more space
On Xcode 11.5, I solved this by setting Strip Linked Product to No in Build Settings of the Framework target.
In our project we have used InjectHotReload library to enable hot reload mechanism. This library caused for strip error. We removed from pod and also removed other linker flags which needed when setup InjectHotReload.
May someone see this and fix problem.
Good luck.
Try setting
STRIP_INSTALLED_PRODUCT to No for your target(one for which you are getting error) build setting.
if this does not work then try below along with above option
Dead Code Stripping: NO
Strip Debug Symbols During Copy: NO for all configurations
Strip Style: Non-Global Symbols
Hope this will solved your problem.

Resources