stop compilation switching to clang - clang

No matter what I try, any compilation I attempt always calls clang. For example, in CMake, setting CC=/usr/bin/gcc has no effect and clang is still called. In terminal entering any compiler results in clang being called:
~/tinyos-main/tools$ nescc
clang: error: no input files
~/tinyos-main/tools$ gcc
clang: error: no input files
Can I stop this? Running on OS X Yosemite and using home-brew.
~$ /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

No, gcc is not installed as /usr/bin/gcc. Clang is installed as /usr/bin/gcc, because Apple doesn't ship gcc anymore. If you want gcc, you need to install it (presumably by saying brew install gcc) and then setting CC=/usr/local/bin/gcc.

Related

-lomp not found for openmp apple m1

I am currently trying to compile a cpp program with openmp. From what I have read online this is the command that I need to use for indeed using openmp on apple silicon:
g++ -Xpreprocessor -fopenmp -I/opt/homebrew/Cellar/libomp/14.0.6/include -L/usr/local/lib -lomp heat2D.cpp
I have installed everything required for openmp (libomp,llvm,etc...) but it gives me this error:
ld: library not found for -lomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In addition if try to remove the lomp flag:
g++ -Xpreprocessor -fopenmp -I/opt/homebrew/Cellar/libomp/14.0.6/include heat2D.cpp
this is the error i get:
Undefined symbols for architecture arm64:
"_omp_set_num_threads", referenced from:
_main in heat2D-0b5aaa.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Since you mention that you installed GCC (and LLVM) via Homebrew, the problem is probably (as Jim Cownie suggested) that when you type "g++", you are running the default link to Apple's LLVM installation (which, alas, does not support OpenMP).
The problem is that Homebrew installs its versions of the compiler binary commands using versioned names -- e.g., "g++-12" if you installed the latest version of GCC. So you have to use those names if you want to run the Homebrew versions. (They are probably installed in /opt/homebrew/bin/ in your case, since you have an Apple Silicon Mac.)
(I haven't installed Homebrew's version of LLVM, but it's probably a similar situation for that as well, since you wouldn't want it to overwrite Apple's LLVM commands.)

Not able to build openh264 for ios because of libstdc++

I am trying to build openh264 for ios. I have downloaded the source code from the latest release. then changed the PREFIX in makefile to ios_local. After that I did make OS=ios ARCH=arm64 which completed with lot of warning.
After that when I did sudo make OS=ios ARCH=arm64 install It exited with error like below
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libopenh264.2.0.0.dylib] Error 1
After researching it seems like Apple does not support libstdc++ now, so mac os compatible version is libc++ which is supposed to be installed when you install XCode. My XCode version is Version 10.2.1 (10E1001) which is more than enough to get this libc++ I think.I am using macOS Mojave. What's going wrong here?

Build iOS native code without -gmodules flag

I intentionally downgraded the clang version I'm compiling with in xcode to a special 3.6 version.
Now I've an error on a flag that was added on a later version of clang
clang-3.6: error: unknown argument: '-gmodules'
Which switch I should disable on Xcode to not add this flag on build ?

Revert Apple Clang Version For NVCC

I am trying to run NVCC to compile a CUDA program on my Mac.
When I try to run NVCC, I am receiving the following error: "nvcc fatal : The version ('70300') of the host compiler ('Apple clang') is not supported".
I recently updated my XCode version to 7.3, and my Mac to 10.11.4.
Is there any way to revert my Clang Version?
Go to https://developer.apple.com/downloads/, log in and then download http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2.dmg, and install, as was suggested by fabregaszy.
Run the following command to switch to the old version:
sudo xcode-select --switch /Library/Developer/CommandLineTools
Run the following command to quickly check clang version:
clang --version
The accepted answer says to download the next-to-latest command line tools and install them, then select them by typing in the console
sudo xcode-select --switch /Library/Developer/CommandLineTools
Its been asked how to revert to the original version of the tools. This is achieved by
sudo xcode-select --switch /Applications/Xcode.app
I just had the same issue after upgrading to XCode 7.3 on 10.11. Reinstalling the previous (7.2) command line tools didn't downgrade the default clang compiler. To fix this I used a previous XCode.app package to rename and copy the XcodeDefault.xctoolchain directory into the Toolchains director in the current /Applications/Xcode.app. You have to right click on Xcode.app to "Show package contents" then browse to the Toolchains dir.
Then (re)start Xcode, hit command-, for preferences, then go to locations. You will see the dropdown for Command Line Tools. Change this to the version of the toolchain you copied over.
You can check the default version of clang in Terminal:
clang -v OR llvm-gcc -v
Now nvcc should work
I came into the same issue.
I think the old command-line tools which can be downloaded from
https://developer.apple.com/downloads/
may solve this issue.
Updated:
I downloaded from the link below and installed, the clang version was successfully reverted to Apple LLVM version 7.0.2 clang-700. But please keep an eye on your OS X version.
http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2/Command_Line_Tools_OS_X_10.11_for_Xcode_7.2.dmg
I would try homebrew's version of llvm, it works for me.
brew install llvm37
Then, set your compiler to homebrew's clang:
/usr/local/bin/clang++-3.7 or whatever respondes to
which clang++-3.7
That way you can leave your OS X dev environment defaults as they are.
Unfortunately, installing Command Line Tools from X-code version 7.2. currently is not solving this.
Trying to compile results in:
nvcc fatal : GNU C/C++ compiler is no longer supported as a host compiler on Mac OS X.
What did the trick for me, was to uninstall Xcode 7.3 and install Xcode 6.2 from the Apple developer site.
Rename Xcode exists in your mac as Xcode-7.app in /Applications folder.
Then download Xcode6.4 from https://developer.apple.com/download/more/ and install it.
80100 can work with some nvcc programs
I used "80100" and nvcc work for some of my other programs.
... but not sample
`
...
nvcc fatal : The version ('80100') of the host compiler ('Apple clang') is not supported
...
`
install CLT 8.2 (Command line tool from Apple) it is sort of ok with message about "command line tools instance"
I google and see a discussion about this (https://github.com/arrayfire/arrayfire/issues/1384) about array fire nvcc issue and thanks to the hint to switch to CLT 8.2, the last version not current one. It is sort of ok with warning message about "command line tools instance"
Need to use "sudo make" to compile sample code:
`
...
$ sudo make
Password:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
expr: syntax error
/Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin g++ -I../../common/inc -m64 -Xcompiler -arch -Xcompiler x86_64 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery.o -c deviceQuery.cpp
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/Developer/NVIDIA/CUDA-8.0/bin/nvcc -ccbin g++ -m64 -Xcompiler -arch -Xcompiler x86_64 -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-8.0/lib -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_60,code=compute_60 -o deviceQuery deviceQuery.o
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mkdir -p ../../bin/x86_64/darwin/release
cp deviceQuery ../../bin/x86_64/darwin/release
$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
...
`
I had the same problem!
Looked in my Time Machine Backups and copied Xcode.app (7.2.1) in my /Application folder. You could also download it from the Apple Developer Page and move it into your /Application folder.
After it's done, you can change the Xcode Command Line Version in your Preferences of Xcode to 7.2.1
Then nvcc will work again (even with pycuda-2016.1).
clang --version
gives me:
Apple LLVM version 7.0.2 (clang-700.1.81)

Compiling error of VLC project in iOS

I am trying to compile the VLC project for iOS, following the instruction step by step.
git clone git://git.videolan.org/vlc-ports/ios.git
sh buildAspenProject.sh -s -k 7.0
And I get this compiling error:
cd builds/unix; /bin/sh ./configure '--without-png' '--prefix=/Users/change/Desktop/VLC_Library/ios/ImportedSources/vlc/contrib/i686-apple-darwin11-i386' '--build=i686-apple-darwin10' '--host=i686-apple-darwin11' '--target=i686-apple-darwin11' '--program-prefix=' '--enable-static' '--disable-shared' '--disable-dependency-tracking' '--with-pic'
configure: WARNING: unrecognized options: --disable-dependency-tracking
checking build system type... i686-apple-darwin10
checking host system type... i686-apple-darwin11
checking for i686-apple-darwin11-gcc... xcrun clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether xcrun clang accepts -g... yes
checking for xcrun clang option to accept ISO C89... none needed
checking how to run the C preprocessor... xcrun cc -E
checking for i686-apple-darwin10-gcc... no
checking for gcc... gcc
checking for gcc... (cached) gcc
checking for suffix of native executables... rm: conftest.dSYM: is a directory
ld: building for MacOSX, but linking against dylib built for iOS Simulator file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libSystem.dylib' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure: error: native C compiler is not working
make[1]: *** [setup] Error 1
make: *** [.freetype2] Error 2
The environment:
XCode 5.0
MountainLion 10.8.4
iPhoneSimulator SDK 7.0
The invocation
$ ld -v
#(#)PROGRAM:ld PROJECT:ld64-224.1
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em
LTO support using: LLVM version 3.3svn, from Apple Clang 5.0 (build 500.2.75)
How do I fix this problem?
Appreciate if any suggestion or idea.
That got me further but got stumped by missing download URL for modplug-xmms.
VLC is insisting on downloading a copy of the source from
MODPLUG_GIT_HASH := 9b08cc646c3dc94dd446ab0671e3427dae8a83fc
MODPLUG_URL := http://sourceforge.net/code-snapshots/git/m/mo/modplug-xmms/git.git/modplug-xmms-git-$(MODPLUG_GIT_HASH).zip
which does not exist as of this time. (Server down?)
I did find of the copy of the source under
http://sourceforge.net/projects/modplug-xmms/files/latest/download/libmodplug-0.8.8.4.tar.gz
I downloaded it and installed it manually:
../ios/ImportedSources/vlc/contrib/iPhoneSimulator-i386/libmodplug
This is a known problem with Xcode 5 for which I don't have a fix yet.
To workaround, go to ImportedSources/vlc/contrib/iPhoneSimulator-i386 and run "make .freetype2". Afterwards, go back to the top directory and run the buildAspen script again.
Note that you'll need to do the same thing (with "iPhoneOS-armv7" and "iPhoneOS-armv7s" respectively) if you decide to compile for iOS devices at a later point.
I hope to fix this shortly. Enjoy hacking VLC for iOS!

Resources