How do I change the compiler in Xcode - c

I'm compiling a C code in Xcode 4.6.3, however I don't know which compiler I'm using. I need to use gcc 4.2.
Thanks in advance.

If you really need to change to gcc, you can do so in the build settings:

Related

Clang using anaconda installation instead of using default in MacOS

I am very new to using C on MacOS. I have been trying to compile C code on MacOS using clang, using the make command.
However, I want to use the default clang that comes with MacOS. When I type which clang on my Mac, it gives the result,
/Users/prateek/opt/anaconda3/bin/clang
instead of the standard clang that comes with MacOS, /usr/bin/clang.
Any ideas on how to change this back to the /usr/bin/clang ?
I am new to asking questions on StackOverflow as well, so please excuse my mistakes, if I have made any. Help would be really appreciated, thanks in advance!
Just add a line in your .bash_profile after the block added by conda installation.
export PATH="/usr/bin:$PATH"
Then it uses the clang in /usr/bin as you want. But I would recommend you use CommandLineTools clang instead because, otherwise, it can give you SDK version conflicts sometimes. You can just replace that with:
export PATH="/Library/Developer/CommandLineTools/usr/bin:$PATH"

Set Up Compiler for C for Sublime Text 3

I just started to learn C programming at University. Unfortunately I need a specific compiler in order to meet their requirements.
My C Compiler needs to compile with following settings:
gcc -Wall -o2
Can anyone help me by programming a compiler for me, or tell my what to do?
Thank you for you help
Greetings
Alex
You can install gcc in cygwin:
http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/
Edit your code in Sublime Text 3 and compile it with gcc
Well I don't know what OS or hardware you are using but gcc can be installed on all Linux systems, and OSX has clang which is compatible with gcc, and calling gcc on OSX simply invokes clang because it's hard linked. If you are on Windows install cygwin.
Please see this answer on how to compile and link C programs in sublime rather than using a shell.

Compile a C program gives "can't find compiler executable in your search path (GNU GCC compiler)" in Codeblocks

I have installed codeblocks in windows 7 first time and try to run a simple C program but I get this error?
can't find compiler executable in your search path (GNU GCC compiler)
I tried many things to solve it but unable to compile.
Have you installed the Mingw compiler or any other simiar compiler? If not install that first. After you have done so, you need to set codeblocks to use that compiler. You can do that by going to the settings>compiler settings and set the necessary options there. You may need to refer the place where you have installed Mingw or other compiler. Note the compiler executable is gcc for C and g++ for C++ and the linker is ld i guess. Debugger is gdb. You need to tell codeblocks where are these located.
I also received that error. I fixed it using Settings -> Compiler -> Global compiler settings -> Toolchain executables -> Auto detect.

after the installation via MacPorts of gcc45, how can I use it to build C language on my Mac?

The following html link contains all the relevant bash command line records of the installation process. Thank you for help!
That was a bad question
I didn't use XCode through I know Xcode will make it easier! I use an Air, memory of 4GB currently.
If this won't work easily I probably will quit learning C or run and compile C on Windows. :(
And XCode stuff, whatever.
You command-line output indicates rather clearly that you aren't telling gcc what to compile, so it's throwing its hands up in exasperation:
$ gcc
i686-apple-darwin10-gcc-4.2.1: no input files
You'll need to specify the file you're compiling. Better yet, use an IDE, like Xcode.
<Shrug> What do you want us to say?
Obviousy Macports is trying to build/install gcc but it can't without a compiler. Yes gcc can be built without a preexisting compiler, but good luck and why? Especially when XCode is a free download, click click let it start and a little while later it's done. At that point as pointed out elsewhere, gcc, g++ will work, but it's not actually gcc but clang in disguise.
If you want, you can use macports or brew or whatever later if you really want to, but again why? For programs that only work using gcc extensions? Doubt it. You just want a c/c++ compiler. If you ever want to do programs for the Mac or IPhone, you need XCode anyway, gcc won't do.

Linking gfortran libraries to c++ program in CodeBlocks under Ubuntu

I have an Ubuntu under Vmware, and use Code::Blocks, as I am not a very powerful command line user
and prefer IDE to Vim+console.
I am trying to compile a program which uses a c++ wrapper to fortran library.
However compiling gives me the following errors:
undefined reference to `_gfortran_compare_string'
There are a lot of errors of this type and a bunch of other similar to this one.
I have gfortran 4.6.3. I found searching that it is probably a linking problem, and people say to
use -lgfortran option for linker. When I add this to linker options in the Code::Blocks it does not change anything, errors continue. So, here are some question:
Is this a correct option for linker?
May be I have to give linker a direct path to the fortran library?
How do I find where are the fortran libraries installed? (I don't know a lot about linux ((( )
What am I doing wrong and how to fix it.
Have you added gfortran as a library to linked to your project or lgfortran? The l is just an option for the g++ for linking the library gfortran to your code. I am not familar with Code::Blocks but you should look for a place where you can enter libraries you want to use and add the gfortran directly.
My guess is that the Code::Blocks side can help you to find this place.
Kim Kulling
My guess is something like /bin/lib /usr/lib or /usr/local/lib. Just take a look into your filesystem. Unfortunately I do not have a Linuix at work. Maybe someone else?
Kim Kulling

Resources