Change GCC version used by bjam - macos

I am trying to build a library (luabind) with bjam. I came across an error and it seems like the problem is that I need to compile with gcc 4.2, but the default on this computer (Mac OSX) is 4.0. I would prefer not to go around changing links in system directories, is there a way to specify to bjam to use gcc4.2 rather than just gcc?

I think it's described in the documentation. You should have:
using gcc : 4.2 : g++-42 ;
in your user-config.jam and "bjam toolset=gcc-4.2" on the command line

Try running bjam with these options:
--toolset=gcc --toolset-root=/path/to/gcc/4.2

Related

How to set custom gcc when using gdb

I have a program that is build with a different version of the GCC than the one on the system. When I try to debug the program using GDB, I am getting errors like
libstdc++.so.6: version `GLIBCXX_3.4.20' not found
libstdc++.so.6: version `CXXABI_1.3.8' not found
libstdc++.so.6: version `GLIBCXX_3.4.21' not found
But when I build and run the executable, I get no errors.
It seems that GDB is using a different libstdc++ than the one used when building. Is there a possibility to tell GDB what libs to use ?
At build, using Makefile, there are some variables set that say what g++ to use, so it will be not the one on the system

Mac OSX: Get 'make' to use 'gcc' instead of 'arm-gcc'

I had installed arm toolchain to build some projects. The issue is, that during my installation I had modified the 'make' from the command line tools to use the arm-gcc compiler instead of gcc.
I now want it to use gcc again. Does anyone know how I can accomplish this? Where exactly is the place where make is defined on Mac OSX?
You can always overwrite it in the Makefile of the project you are building:
CC=gcc
you may need the fully qualified name.

gcc compiling error on Solaris 10

I want to compile a source code, but there are some compiling errors about __sync_xxx functions (__sync_bool_compare_and_swap etc.)
GCC version on machine is 3.4.3 (it must be gcc 4.1 or over for supporting atomic builtins), so I have downloaded GCC v4.6, copied it to another directory (I didn't remove v3.4.3) then change the $PATH path for GCC but it doesn't work (the same error occurs).
I want to ask that is only changing gcc path with export PATH=... enough for compiling with new GCC?
Use the following configure option when compiling gcc:
--program-prefix=foo --program-suffix=bar
and it will produce bin programs of the form "foo-gcc-bar", so that you may differentiate different builds of gcc.
Replace foo and/or bar with an appropriate "tag" for your build (eg "-4.6" for example).
This way if it doesn't find your toolchain correctly it will fail fast rather than using the 3.4 version.
It also means that different toolchain builds can coexist in the standard installation prefix directories.
We have to use -march=686 switch to get it to work on intel.
Try checking and updating LD_LIBRARY_PATH, to use the lib path for the new gcc installed.

Installing GCC in mac

I've recently installed gcc 4.6.3 on my MAC (with OSX Lion, XCode 4.3, gcc 4.2.1). I've made a folder named my_gcc463, which contains all files after compiling gcc with make command, etc.
I've also installed MacPorts to select between all versions of gcc that I have. The problem is when I run this command:
port select --list gcc
I can't see the new gcc 4.6.3 in the list so that I can select that. Also when I run this command:
sudo ln -s -f ~/my_gcc463/gcc-4.6.3 /usr/bin/gcc
to link gcc to the one I want, It's not working. For example after creating that symlink, when I run:
gcc -v
It doesn't give me the version. What should I do to make my new gcc appear in the gcc list? Did I do anything wrong? Should I install it in other way?
Thank you in advance for helping me. :)
port select is a tool to maintain the gcc installations from MacPorts and, if available, the versions provided by Apple. Although you could hack it up by dropping your own descriptions into /opt/local/etc/select/gcc, I would recommend a different approach for this.
To achieve what you want you should modify your PATH environment variable to include the new path to your gcc version at the front, such that gcc resolved to the correct absolute path.
Assuming your new gcc binary is at ~/my_gcc463/gcc, you should add the following to your .profile/.bash_profile or .bashrc:
export PATH=~/my_gcc463:$PATH
After setting this up, run gcc -v in a new terminal window to check if it is working as expected.

Using non-apple g++ on Mac OSX Lion

Is it possible to use the stock (non-apple) version of g++ on Mac OSX 10.7? I want to be able to use the stock g++ without running a virtual linux box on my mac. The reason I want to do this is because apple's version of g++ doesn't warn you when there are unused variables and etc. I'm doing some assessed C++ problems in my numerical methods course and I want to make sure I'm not making any mistakes.
It was suggested I make a symbolic link to a linux version of g++ for compiling the code for the assessments. How do I go about doing that?
Thanks
A linux version of the compiler will not work on what is (essentially) a bsd port.
Are you sure that the current version of g++ cannot warn on the conditions you expect?
Finally, if #2 is true, there is nothing stopping you from getting another version of g++ (compiled for MacOSX) that doesn't have this issue.
A binary for g++ for Linux won't run on MacOSX.
You could compile GCC from its source code; use the latest release i.e. 4.6.2. But that requires some work. Be sure to follow the installation instructions, in particular care about dependencies (like PPL & Cloog) and configure (appropriately) and compile in a build tree outside of the source tree.

Resources