I install gcc5.3.0 on my mac, and I broke it. What should I do to reuse apple-gcc42? - macos

I used rm -rf to delete the gcc5.3.0, but mac continues to use gcc5.3.0.
The wrong message:
g++: error trying to exec 'cc1plus': execvp: No such file or directory
What should I do to reuse apple-gcc42?

Editing comments and responses into an answer.
Where was GCC 5.3.0 installed? Where did it come from? Did you create it or is it from Apple, or one of the auxilliary packagers? Did your recursive remove actually remove anything? Does running xcode-select help? (Use man xcode-select to see what it does; maybe xcode-select --install is useful, but I'm not sure since I've never destroyed my compilation system like that.) Which version of XCode do you have installed? Which version of Mac OS X are you running?
GCC5.3.0 is installed at /usr/local/libexec/gcc/x86_64-apple-darwin15.0.0/5.3.0. I removed the folder gcc. My Mac OS X is 10.11.6 and my Xcode is 7.3.1.
Removing /usr/local/lib/libexec/gcc didn't remove the executables from /usr/local/bin, so when you run g++, the shell is still finding the executable /usr/local/bin/g++, but that is not finding its auxilliary programs because you did manage to remove them. You also haven't cleaned up the headers that were installed under /usr/local/include, etc. Don't use rm -fr; it is crude and only partially effective when you have to uninstall complex suites of software like GCC. You could also use /usr/bin/g++ instead of g++.
So what should I do now?
You need to finish the removal job — remove gcc and g++ from /usr/local/bin at minimum. That should leave you with /usr/bin/gcc and /usr/bin/g++ as the compilers. You might have to run hash -r or start a new terminal window to avoid Bash's caching of the location of the compiler (but you'd get bash: /usr/local/bin/g++ not found or something similar as an error message).
Thank you. This works for me!

Related

how to use and install SystemC in terminal mac OS X?

how to use and install SystemC in terminal mac OS X?
I tried the Logic poet application, But i use os x 10.10 so it doesn't work.
so i want to know how can i compile and execute SystemC in terminal.
I could't find the detail of SystemC in terminal.
Thank you
The other answer is correct and perfectly fine, however, I thought I'd also answer and provide a little more detail.
Install Apple's "Command Line Tools"
You have two options: install Xcode (a big download), or just the command line tools (a much smaller download). If your goal is simply building SystemC applications at the command line, then I recommend the latter.
Install Apple's "Command Line Tools" by launching Terminal, entering
$ xcode-select --install
then clicking Install. After that, you'll have make, clang and more available at the command line.
Build and install Accellera's SystemC implementation
Download the latest release from the Accellera Downloads page (annoyingly, you'll have to provide a few personal details) and extract the contents of the .zip file.
I like to keep a copy of the SystemC source code available, because it can be useful for debugging or understanding how something works. Therefore, I move the extracted folder (systemc-2.3.1) into ~/Work/Other. That's where I keep source code for third party libraries. However, you can put it wherever you like.
Open Terminal, change into the extracted folder (systemc-2.3.1), and execute:
$ mkdir build
$ cd build
$ export CXX=clang++
$ ../configure --with-arch-suffix=
$ make install
The --with-arch-suffix= option prevents a -macosx64 suffix being add to the lib folder name, allowing your build scripts to be simpler.
After that process, the salient include and lib folders should be available within the systemc-2.3.1 folder.
Configure your build environment
There are many ways you can do this; I have a simple approach that I believe is close to what the SystemC maintainers envisioned. I define two environment variables in my .bash_profile (which is executed for every new Terminal session on OS X):
export CXX="clang++ -fcolor-diagnostics"
export SYSTEMC_HOME=~/Work/Other/systemc-2.3.1
Build a SystemC application
You could use Make, the quintessential build tool, which you get with Apple's "Command Line Tools", or any one of the plethora of other options. I use SCons with SConstruct files that look something like this:
import os
env = Environment(CXX=os.environ["CXX"],
SYSTEMC_HOME=os.environ["SYSTEMC_HOME"],
CPPPATH="$SYSTEMC_HOME/include",
LIBPATH="$SYSTEMC_HOME/lib")
env.Program("main.cpp", LIBS="systemc")
View trace (VCD) files
Scansion is a nice tool for this. GTKWave is another option, but it's a bit clunky.
Ensure you have xcode command line tools installed.
Follow instructions provided in the official repository.
From personal experience.
Compiling SystemC library with clang results in segmentation fault: 11
error every time I include systemc library into my code. To avoid this use gcc instead.
Note that I use gcc-8, installed with homebrew.
$ cd path/to/systemc-2.3.3
$ mkdir objdir
$ cd objdir
$ export CXX=g++-8
$ ../configure
$ make
$ make install
Use $ make check to launch examples compilation and unit tests.
To compile and run hello world example:
$ export SYSTEMC_HOME=path/to/systemc-2.3.3
$ g++-8 hello.cpp -o hello.o -L $SYSTEMC_HOME/lib-macosx64 -I $SYSTEMC_HOME/include/ -l systemc
$ ./hello.o
Tested on macOS 10.13.6; gcc version 8.2.0; systemc-2.3.3
Install
Go here click the first link and fill in your information to get the source code
http://www.accellera.org/downloads/standards/systemc
Then cd to the folder
Then run the following commands
./configure --with-unix-layout
gmake
sudo gmake install
gmake clean
After you do that it should all be saved in your use/local/(lib&include) directories
To Use
In code do this
#include "systemc.h"
I use a single makefile normally. But you could write the following to link the library. Given your cpp file is called main.
g++ -o main main.cpp -I/usr/local/include -L/usr/local/lib -lsystemc

Homebrew doctor is foreshadowing some sinister problems

I'm trying get Homebrew working with Xcode Command Line Tools, and they seem to be having it out with each other... In the words of Rodney King, "Can't we all just get along?"
For some background, when I first got my Mac about a year ago, I had no idea what I was doing. I was also using macports, which was, as the Homebrew website seems to be cognizant, driving me to become a raging alcoholic. As a result, my /usr/local directory got wayyy f-ed up. Eventually, gcc and g++ stopped working, and a lot of other things were breaking. So I did a clean install of OS X, and I want my shiny new installation to stay a little more organized.
Now, I've installed Apple's Command Line Tools, and all the binaries/libraries/etc have ended up in /usr/local. That's fine, but then I try to install homebrew, and it's also putting everything in the /usr/local/ directory. When I run the command
brew doctor
I get the following output (actually, this is just a snippet, but it captures the general spirit of what Homebrew is telling me):
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected static libraries:
/usr/local/lib/libatomic.a
/usr/local/lib/libgfortran.a
/usr/local/lib/libgmp.a
/usr/local/lib/libgomp.a
/usr/local/lib/libitm.a
/usr/local/lib/libmpc.a
/usr/local/lib/libmpfr.a
/usr/local/lib/libquadmath.a
/usr/local/lib/libssp.a
/usr/local/lib/libssp_nonshared.a
/usr/local/lib/libstdc++.a
/usr/local/lib/libsupc++.a
I thought I might place Homebrew in a different directory; however, the Homebrew documentation specifically warned against this. They say:
"Do yourself a favor and install to /usr/local. Some things may not build when installed elsewhere. One of the reasons Homebrew just works relative to the competition is because we recommend installing to /usr/local. Pick another prefix at your peril!"
The whole point is that I don't want to bother with micro-managing every package I install, and I don't want my filesystem to become an ungodly mess either. Anyone have any suggestions? Do I move command line tools to a different directory and add this to my $PATH? Any tips would be much appreciated.
It's a warning, and the message says why. If you later want to install a Homebrew formula that installs one of those files, it will fail, because it will decline to overwrite those files, and then you will have to delete those files, as the message says.
Specifically, those files appear to belong to an installation of gcc. You might want to research or try to remember why that was installed there. It's probably OK to just delete them and install gcc from Homebrew if you need it.

Errors when installing a Perl module using make - Mac OSX 10.7

The problem:
I can't seem to install perl modules correctly, JSON-2.53 in particular.
I have done the following:
Searched for a similar problem and tried its solution - did not work.
perl ".../config.h, needed by `Makefile'" not working after OSX Lion upgrade
Installed XCode command line developer utilities (c compiler, make, etc)
Read version compatibility documentation on this particular perl module: http://metacpan.org/pod/JSON
Ran the following commands to make and install the desired perl module:
$perl Makefile.PL
Welcome to JSON (v.2.53)
If you install JSON::XS v.2.27, it makes JSON faster.
************************** CAUTION **************************
This is 'JSON version 2' and there are many differences *
to version 1.xx *
Please check your applications useing old version. *
See to 'INCOMPATIBLE CHANGES TO OLD VERSION' and 'TIPS' *
Writing Makefile for JSON
(verified that the Makefile has been written)
$make
make: *** No rule to make target `/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h', needed by `Makefile'. Stop.
What does that error even mean? What can I do to successfully make install this module?
Here are some additional items that may help you assist me in debugging this issue:
$which make
/Applications/Xcode.app/Contents/Developer/usr/bin/make
$which perl
/usr/bin/perl
$perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-thread-multi-2level
I think you need to download and reinstall XCode. If I recall correctly for 10.7, after downloading Xcode from the app store it drops an installer into your Applications folder. You need to run it and try installing the command line tools again (from Xcode's prefernces pane). I know you mentioned you did this already, but a bit more background might explain why it's worth another try.
Here are the relevant lines in the Makefile from my Mac:
PERL_INC = /System/Library/Perl/5.12/darwin-thread-multi-2level/CORE
# Where is the Config information that we are using/depend on
CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
Later on in the Makefile CONFIGDEP is used as a dependency in a target. I believe in your case make is looking for /System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h and can't find it. The error you're seeing is make's obtuse way of saying file not found.
config.h contains specific information about the OS but is not needed for running scripts. It's only referenced when you want to compile a module. With stock OSX you get enough perl to execute scripts. Install XCode and you get the bits (like config.h) to do perl "development". I use quotes because you can write and run perl scripts without Xcode. But as you discovered, compiling a module requires the additional files Xcode provides. (Incidentally, RedHat does the same thing. You have to install the perl-devel package to get config.h. The perl runtime is in a separate package.)
Here are some things you can try:
Verify /System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h exists. If not, Xcode command line utilities were not installed properly. Try it again.
If config.h exists, check its content and make sure it looks sane. It's a C header file and consists of comments and #define statements.
If you don't have access to view config.h, you have a permission issue. Try using sudo make as a bypass. Disk Utility (found in Applications -> Utilities) might be able to permanently fix this.
You could risk changing the Makefile by removing "$(PERL_INC)$(DFSEP)config.h" from CONFIGDEP. I did this on my 10.8 Mac and it worked without issue (it passed all tests as well). However, if you don't find the root cause of your config.h issue, the next time you want to install a perl module you may find yourself right back where you started.
I had this exact same error, whilst this may not be a solution for you.... after reinstalling an updated xcode compatible with the OSX version (+rebooting after the install) I still had the error - to cut a long story short I noticed there was no config.h in /CORE/ after the error.....the solution that worked was to touch config.h and create the file first and then re-run the make. Hope this helps someone.

Xlib.h not found when building graphviz on Mac OS X 10.8 (Mountain Lion)

When using homebrew to install graphviz, the script gets to the point of "Making install in tkstubs" and then throws the following fatal error:
In file included from tkStubLib.c:15:
/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
I have installed XQuartz as X11 has been dropped in Mountain Lion, but I'm unsure if it is installed correctly. The location of Xlib.h is:
/opt/X11/include/X11/Xlib.h
There are also two symlinks to /opt/X11, they are:
/usr/X11
/usr/X11R6
Does this look like the correct setup to you? I've never dealt with X11 or XQuartz until yesterday.
Cheers.
After installing XQuartz you may add a symlink to your X11 installation folder by just entering
ln -s /opt/X11/include/X11 /usr/local/include/X11
in terminal. That will fix the problem as well without changing any ruby script.
You need to tell the tkstubs build (and possibly other bits in the package as well) to look for headers in /opt/X11/include; this is not on the standard include path.
Usually this is achieved by passing -I/opt/X11/include as an additional compiler flag, the method to do so is however dependent on the build system.
For reasonably modern configure scripts, the best approach is to pass it in the environment variable CPPFLAGS; if the package uses another build system or this doesn't work for another reason, then you need to look at the Makefile in the build directory.
You can enter in your shell before the compile/link (or brew) command:
export CPPFLAGS=-I/opt/X11/include
The export line will tell the compile/linker to look in /opt/X11/include for the X11 include files
Had the same issue and running this command on terminal
xcode-select --install
worked for me. Run this command after installing xQuartz.
If you need this to work in your CMake builds:
if(APPLE)
include_directories(AFTER "/opt/X11/include")
endif()
That worked well for me.
I got it to install by copying the x11 header file directory to the /opt/local/include directory. Probably not the best way to work around it but quick and easy.
I found this thread while trying to compile ffmpeg from source on OS X. I needed --enable-x11grab and the homebrew build does not support this option.
I had XQuartz installed already but I kept getting errors from ./configure: ERROR: Xlib not found. I thought the answers here would solve my problem, but they did not!
So, if anyone is ever in the same boat, my solution was this:
I opened up the generated config.log and found lots of errors referring to various includes and header files, including X11/Xlib.h - this is misleading. At the very bottom of the logfile was the key, pkg-config was complaining about looking for xbc.pc, and requested that it be put on the path. However, the error message that is displayed on the terminal says nothing about pkg-config or xbc!
The solution is to add to your PKG_CONFIG_PATH environment variable. Mine was nonexistent, so I just did export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig/ (the folder where I found xbc.pc).
I reran configure and everything worked like a charm!
TL;DR: check config.log - don't trust the terminal output!
Since the make file is looking for X11/xlib.h i.e., it is looking for X11 folder in the current directory, one way to solve this problem is to simply copy the /opt/X11/include/X11 directory to the directory that contains make file.

How to fix linker error "cannot find crt1.o"?

I have a virtual Debian system which I use to develop. Today I wanted to try llvm/clang. After installing clang I can't compile my old c-projects (with gcc).
This is the error:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: ld returned 1 exit status
I uninstalled clang and it still did not work. Does anyone have any idea how I can fix this?
Debian / Ubuntu
The problem is you likely only have the gcc for your current architecture and that's 64bit. You need the 32bit support files. For that, you need to install them
sudo apt install gcc-multilib
What helped me is to create a symbolic link:
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
It seems that while you were playing with llvm/clang you(or the package manager) removed previously existing standard C library development package(eglibc on Debian) or maybe you didn't have it installed in the first place, thus you need to reinstall it, now that you reverted back to gcc.
You can do so like this on Debian:
aptitude show libc-dev
Ubuntu:
apt-get install libc-dev
On Ubuntu, if you don't have libc-dev, since I cannot find it on packages.ubuntu.com, you can try installing libc6-dev directly.
Or on Redhat like systems:
yum install glibc-devel
NB: Although you were briefly answered in the comments, here is an answer just so there is one on record in case someone encounters this one and might be looking for an answer, but not in the comments or the comment is not explicit enough for them.
This is a BUG reported in launchpad, but there is a workaround :
Run this to see where these files are located
$ find /usr/ -name crti*
/usr/lib/x86_64-linux-gnu/crti.o
then add this path to LIBRARY_PATH variable
$ export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
After reading the http://wiki.debian.org/Multiarch/LibraryPathOverview that jeremiah posted, i found the gcc flag that works without the symlink:
gcc -B/usr/lib/x86_64-linux-gnu hello.c
So, you can just add -B/usr/lib/x86_64-linux-gnu to the CFLAGS variable in your Makefile.
If you're using Debian's Testing version, called 'wheezy', then you may have been bitten by the move to multiarch. More about Debian's multiarch here: http://wiki.debian.org/Multiarch
Basically, what is happening is various architecture specific libraries are being moved from traditional places in the file system to new architecture specific places. This is why /usr/bin/ld is confused.
You will find crt1.o in both /usr/lib64/ and /usr/lib/i386-linux-gnu/ now and you'll need to tell your toolchain about that. Here is some documentation on how to do that; http://wiki.debian.org/Multiarch/LibraryPathOverview
Note that merely creating a symlink will only give you one architecture and you'd be essentially disabling multiarch. While this may be what you want it might not be the optimal solution.
To get RHEL 7 64-bit to compile gcc 4.8 32-bit programs, you'll need to do two things.
Make sure all the 32-bit gcc 4.8 development tools are completely installed:
sudo yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686
Compile programs using the -m32 flag
gcc pgm.c -m32 -o pgm
stolen from here : How to Compile 32-bit Apps on 64-bit RHEL? - I only had to do step 1.
As explained in crti.o file missing , it's better to use "gcc -print-search-dirs" to find out all the search path. Then create a link as explain above "sudo ln -s" to point to the location of crt1.o
This worked for me with Ubuntu 16.04
$ export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
./configure --disable-multilib
works for it
On Alpine Linux that would mean that you need musl-dev:
apk add musl-dev
Although in my case the messages were:
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared: No such file or directory
collect2: error: ld returned 1 exit status
Which are also caused by missing musl-dev.
Ran into this on CentOs 5.4. Noticed that lib64 contained the crt*.o files, but lib did not. Installed glibc-devel through yum which installed the i386 bits and this resolved my issue.
Even I got the same compilation error when I was cross compiling i686-cm-linux-gcc.
The below compilation option solved my problem
$ i686-cm-linux-gcc a.c --sysroot=/opt/toolchain/i686-cm-linux-gcc
Note: The sysroot should point to compiler directory where usr/include available
In my case the toolchain is installed at /opt/toolchain/i686-cm-linux-gcc directory and usr/include is also available in the same directory
I solved it as follows:
1) try to locate ctr1.o and ctri.o files by using find -name ctr1.o
I got the following in my computer: $/usr/lib/i386-linux/gnu
2) Add that path to PATH (also LIBRARY_PATH) environment variable (in order to see which is the name: type env command in the Terminal):
$PATH=/usr/lib/i386-linux/gnu:$PATH
$export PATH
I had the same problem today, I solved it by installing recommended packages:
libc6-dev-mipsel-cross libc6-dev-mipsel-cross, libc-dev-mipsel-cross
This worked:
sudo apt-get install libc6-dev-mipsel-cross
One magic command:
sudo apt install build-essential
Fixed everything for me even on Raspberry Pi.
In my case, the crti.o error was entailed by the execution path configuration from Matlab.
For instance, you cannot perform a file if you have not set the path of your execution directory earlier.
To do this: File > setPath, add your directory and save.
use gcc -B lib_path_containing_crt?.o
In my case Ubuntu 16.04 I have no crti.o at all:
$ find /usr/ -name crti*
So I install developer libc6-dev package:
sudo apt-get install libc6-dev

Resources