Installing GCC on Oracle Solaris 11 - oracle

i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compilers, i needed GCC, any idea where can i get GCC or how to install it?
thanks

The original answer applied to Solaris 11 Express/non-official release - if you're doing this today with a full release of Solaris 11.x, use the pkg install command like you see in xavier's response.
Run this command from your terminal to install GCC.
For GCC 3.4.x
pkg install gcc-3
For GCC 4.5.x
pkg install gcc-45
For GCC 4.7.x
pkg install gcc-47
For GCC 4.8.x
pkg install gcc-48
The gcc command should then already be placed in your path /usr/bin/gcc, which is a symlink).
Old Answer
Solaris 11 should already have gcc installed in /usr/sfw/bin/, but it's probably not in your PATH. Try this at the prompt: /usr/sfw/bin/gcc

Two steps:
pkg install gcc-45
pkg install system/header
that is all
if you see more info
http://blog.csdn.net/zjg555543/article/details/8217769

Just download gcc from its homepage, follow one of the mirror links to fetch the latest binary package (in .tar.gz or tar.bz2 format), and use traditional steps to build:
./configure --<> // give your options
make
make install
The good news is you can customize what you need and always stay with the latest, while bad part is you may lose the power to debug with mdb/adb - we are facing such problems with latest GCC 4.6.x

Solaris 10 and prior version :
/usr/sfw/bin/gcc works.
Solaris 11 :
pkg install gcc-3

pkg install gcc
worked for me
This will install entire gcc collection on your machine. Which anyways will be required

My Solaris 2.11 does NOT have internet access :/
What work for me:
(1) I use this link as guideline
(2) From my windows machine, download gcc at one of their mirror sites, i used here, normally the closer the better
(3) Upload gcc-9.2.0.tar.gz to target /tmp directory using WinSCP
(4) tar -xvf gcc-9.2.0.tar.gz
(5) cd gcc-9.2.0
(6) mkdir /usr/local/gcc
(7) cd /usr/local/gcc
(8) /tmp/gcc-9.2.0/configure -v --program-suffix=9.2
At this point, you might get this error:
Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
(9) Manually download the required files here.
Note: To know what files are required, check contrib/download_prerequisites
(10)Copy over the files in (9) to /tmp/gcc-9.2.0
(11)Extract, then create shortcuts: ln -s gmp-6.1.0 gmp, ln -s mpc-1.0.3 mpc, ln -s mpfr-3.1.4 mpfr, ln -s isl-0.18 isl
(12)/tmp/gcc-9.2.0/configure -v --program-suffix=9.2 --enable-languages=c,c++ -v
(13) nohup gmake & (At this point it's going to take some time...mine took ~6 hours. Use -j option if you can, to gmake it faster )
(14) gmake install
(15) /usr/local/bin# ./gcc9.2 --version
gcc9.2 (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
Voila! :-)

You can install gcc 4.3 from OpenCSW:
pkg-get -i gcc4code gcc4g++
I also had to run mkheaders manually after the install.

I had the same problem and 'pkg install gcc-3' worked for me.

I'll quote the answer from unix.stackexchange.com.
On Solaris 11 gcc is not installed by default. Normally you'll want more than just the compiler itself so my answer will include all the usual suspects for building open source software on Solaris that you've downloaded from somewhere in source code format.
By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):
pkg install pkg://solaris/developer/build/gnu-make \
pkg://solaris/developer/build/make \
pkg://solaris/developer/gcc \
pkg://solaris/system/header \
pkg://solaris/developer/build/autoconf \
pkg://solaris/developer/build/automake
(I use fully qualified package names here, that is not really necessary)
Note that some of the packages are available in the official repo in various versions. If you just reference developer/gcc then you'll at the time of writing this get GNU C v4.8.2, but you may explicitly ask for a prior version, e.g. by using package name such as developer/gcc-45.

Related

Custom Compiling Tesseract-ocr (4.0) on Windows

I'm desperately trying to compile Tesseract-ocr (4.0) on a Windows Machine with some restrictions.
We are doing multi-platforms : an automated compilation must be possible (command-line)
We are using specific 3rd party libraries : the compilation must accept custom path / libraries for most of its dependencies
We are already using most of the 3rd party libraries for other part of the code : the compilation must not recompile them (thus, no cppan)
Leptonica has been built with our special 3rdparty (ZLib, LibPng ..)
Our project must "include" tesseract alongside theses specific 3rdparty
Problem :
I have strong issue specifying custom paths for Tesseract.
Under Unix (CentOS, Ubuntu 16/18, Debian 8/9 ..), I was able to achieve my goal with the tools autogen autoconf autoheaders pkg-config.
Under Windows, autoconf-archive and pkg-config are unavailable (from what I tried) ; rendering autoconf unusable.
I was neither able to compile using CMake and specifying a custom path for Leptonica (even after writing a new pkgconfig for leptonica).
Things I tried :
Using MinGW and autoconf
Manually installing pkg-config
Cheating with autoconf-archive .m4 into aclocal
Creating a VisualStudio project with cppan and modify it
Various ways of telling CMake to search elsewhere for 3rdparty
Things that work on Linux :
Autoconf with modified PKGConfig for custom compiled Leptonica (--with-extra-libraries PKG_CONFIG_PATH CPPFLAGS LDFLAGS)
Things I have not tried :
Installing Leptonica on the machine (Not the point here)
Rewriting CMakeFiles
Unknown solutions ?
Possible Solutions
MinGW (Windows) with pkg-config autoconf-archive
Unknown way to tell CMake Leptonica custom path
VisualStudio project without cppan
Yours ?
Thank your for your interest.
EDIT 1
By trying various ways of manually installing pkg-config, Autoconf seemed to be unaware of its presence. This error was about pkg-config missing package (How to install pkg config in windows?).
CPPAN was deeply part of the visual studio project and I couldn't see how I could separate them.
I usually tell configure to look for leptonica package with the arguments --with-extra-libraries and PKG_CONFIG_PATH.
CMake however, uses the "macro" find_package(Leptonica $PATH CONFIG REQUIRED). By looking at it a little bit, I was (maybe) able to specify its path with CMAKE_PREFIX_PATH, CMAKE_MODULE_PATH, Leptonica_DIR. The compilation was still unsuccessfull due to missing config files (LeptonicaConfig.cmake or leptonica-config.cmake).
I pointed theses variables to various folders of the leptonica folder after building it.
For information, I built Leptonica with its configure as such :
bash configure --enable-shared=false --without-giflib --without-libwebp --without-libopenjpeg LDFLAGS="-LPATH/TO/ZLIB -LPATH/TO/LIBPNG .." CPPFLAGS="-IPATH/TO/ZLIB/INCLUDE ..."
I, however, was unable to locate theses files (while seeing a LeptonicaConfig.cmake.in under LeptonicaDir/cmake/template)
I hope I answered your questions. Please tell me if you need further details.
To compile tesseract-4.0.0 on Windows with MSYS and MinGW:
Prerequisites:
Download Tesseract OCR 4.0: https://github.com/tesseract-ocr/tesseract
Install MSYS2 (msys2-x86_64): https://www.msys2.org/
Extract tesseract-4.0.0.zip to C:/msys64/home/tesseract/tesseract-4.0.0
Open Start Menu > MSYS2 64bit > MSYS2 MSYS and run the following commands:
$ pacman -Syu
#### Close terminal window and open it again (MSYS2 MSYS) ###
$ pacman -Su
$ pacman -S base-devel
$ pacman -S mingw-w64-i686-toolchain
$ pacman -S mingw-w64-x86_64-toolchain
$ pacman -S mingw-w64-i686-cmake
$ pacman -S mingw-w64-x86_64-cmake
32-bit Compilation:
Open Start Menu > MSYS2 64bit > MSYS2 MinGW 32-bit and run the following commands:
$ cd /home/tesseract/tesseract-4.0.0
$ pacman -S mingw-w64-i686-leptonica
$ ./autogen.sh
$ ./configure --prefix=/home/tesseract/install/windows-i686
$ make -j4
$ make install
64-bit Compilation:
Open Start Menu > MSYS2 64bit > MSYS2 MinGW 64-bit and run the following commands:
$ cd /home/tesseract/tesseract-4.0.0
$ pacman -S mingw-w64-x86_64-leptonica
$ ./autogen.sh
$ ./configure --prefix=/home/tesseract/install/windows-x86_64
$ make -j4
$ make install
The compiled tesseract will be installed on: C:/msys64/home/tesseract/install

What is the best way to install pkg-config on Mingw in 2014?

What is a good way at this moment (October 2014) to install pkg-config on Windows in a (no HTTPS) MinGW / MinGW-w64 environment? (See also this question from 2009.)
If there is a binary package that does not pull in GTK+, that would be great, but I haven't found one. Building from source is fine if that's the way to go.
On the Mingw FAQ it says: (This is from 2009 the latest, judging from a comment at the bottom of the page.)
How do I get pkg-config installed?
The difficulty in getting pkg-config installed is due its circular depency on glib. To install pkg-config, you should first install the GTK-runtime, the installer is found at (dead link) https://sourceforge.net/project/showfiles.php?group_id=121075. The pkg-config binary can be obtained from (new link, but does not mention pkg-config) https://www.gtk.org/download/windows.php. Place pkg-config.exe in your MinGW bin directory.
There are other pkg-config projects that don't have the circular dependency issue. They include:
(dead link) pkgconf
pkg-config-lite
I've quickly looked at pkg-config-lite, but it looks like it was last updated in 2012. Also, I think pkg-config now includes its own version of Glib to break the circular dependency, so it should be possible to build without Glib.
I've done searches for "mingw pkg-config". Any suggestions welcome.
The way to go seems to be MSYS2 and MinGW-w64. Download MSYS2, on 32-bit Windows run msys32\autorebase.bat (this should not be needed much longer), then:
pacman -Syu # to update the system packages
(these errors are not fatal), then
pacman -Ssq pkg-config # to list pkg-config packages
# for 64 bit: ------
pacman -S mingw-w64-x86_64-pkg-config
# for 32 bit: ----
pacman -S mingw-w64-i686-pkg-config
On https://sourceforge.net/p/mingw/mailman/message/31908633/ there are some instructions from earlier this year:
The FAQ pkg-config information did not work for me:
these did:
https://github.com/texane/stlink/issues/169
Download these three glib, pkg-config, pkg-config-dev archives and
extract contents to C:\MinGW
(These are all dead links – see also another SO question regarding win32builder.gnome.org:)
http://win32builder.gnome.org/packages/3.6/glib_2.34.3-1_win32.zip
http://win32builder.gnome.org/packages/3.6/pkg-config_0.28-1_win32.zip
http://win32builder.gnome.org/packages/3.6/pkg-config-dev_0.28-1_win32.zip
I keep this unaccepted in case someone has a better answer.
There is also pkg-config-lite:
Install mingw-w64
Install pkg-config-lite
Set PKG_CONFIG_PATH to the directory containing your *.pc files (i.e. c:\mingw64\mingw64\lib\pkgconfig)

Error during RNNLib configuration: netcdfcpp.h cannot be found

When attempting to compile RNNLib, I got an error in NetcdfDataset.hpp:26:24 saying that Netcdfcpp.h could not be found. I looked around and found a bug report from 2011 that suggested that this was a bug, but it claimed to have been fixed. I have tried everything I can think of, including rebuilding NetCDF (a dependency of RNNLib) with various different flags, and have been unable to fix this bug. Can anyone give me a hand?
I had some trouble on a virtual machine building rnnlib.
I had to install the C and C++ version of NetCDF to get it to work.
The C version can be installed via sudo apt-get install libnetcdf-dev
I had to install the C++ version by building it.
Hope it will help. It's quite a difficult lib to install.
Maybe this helps someone: you can avoid some of the pain by installing packages from APT, and access the correct version mentioned by user3620756, which contains the netcdfcpp.h header file
. This happens through a legacy package, available on Ubuntun 16.04 (Xenial universe, see APT repository).
First install libnetcdf for C, then install libnetcdf-cxx-legacy-dev which should depend on libnetcdf-c++4 and install required C++ libraries on the go:
sudo apt install libnetcdf-dev libnetcdf-cxx-legacy-dev
The newest version doesn't have this netcdfcpp.h file anymore.
I had to use ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz to get it working.
I have also followed the same process and it worked for me
"The newest version doesn't have this netcdfcpp.h file anymore. I had to use ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-cxx-4.2.tar.gz to get it working."
After downloading the folder, I had to build it by entering into the netcdf folder. I used simple command for the task :
.\configure
make
sudo make install
But in the file named as "NetcdfDataset.hpp", I have to give the complete path of the netcdfcpp.h file. For my case the path of the include file is :
#include "/Volumes/Macintosh_HD_2/WordSpottingProj/trunk/CODE C++/rnnlib_source_forge_version/netcdf-cxx-4.2/cxx/netcdfcpp.h"
I had this problem in the context of trying to use a makefile that called for netcdfcpp.h:
$ make -f makefile_MAC
c++ -O2 -o burn7.x burn7.cpp -I/opt/local/include -L/opt/local/lib -lm -lnetcdf_c++
burn7.cpp:31:10: fatal error: 'netcdfcpp.h' file not found
#include <netcdfcpp.h>
^
1 error generated.
make: *** [burn7.x] Error 1
I'm on a Mac, so I used Homewbrew to install the NetCDF package, but version 4.3.3.1 didn't appear to have netcdfcpp.h:
brew install homebrew/science/netcdf
However, I found that installing it with an additional flag resulted in this version being included:
brew install homebrew/science/netcdf --with-cxx-compat
I assume that the same is true of other installation/compilation methods, and not that this file has been taken out of versions since 4.2 as others answers state. Maybe it was a default option before and now it isn't?

Does installing gfortran with homebrew and with an installer create a conflict?

I was following an online tutorial to install some Python modules using homebrew and one step was to install gfortran with brew install gfortran. Later on, I tried using another third-party installation script to install some Python modules and after the fact I realized that part of what the script did was download and run http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg. I don't know that much about gfortran, but looking at the brew formula for gfortran it appears that brew uses a different version from the att.com one. Will that lead to problems in the future? I did brew uninstall gfortran and brew install gfortran again, and so far it seems like things are the same (I tried recompiling the old code that I had compiled before), but I am not sure what all the att.com pkg did. (I have OS X 10.8.2 and XCode 4.2 if that matters).
It depends on where the other gfortran installer goes to. In general, no, it won't conflict. * Homebrew is designed to be compatible with third-party gfortran installs - it defines dependencies on a generic "fortran" compiler, and not on the specific gfortran Homebrew formula. Homebrew stays under /usr/local, sticking the main install in /usr/local/Cellar, and symlinking judiciously in to /usr/local/lib. Other installers that install to /usr/local will just prevent Homebrew from linking its own compiler in, but will work with other formulas that use a fortran compiler. (Assuming the gfortran build options are compatible.)
That particular gcc-42 installer you linked to installs to /usr, not to /usr/local.** And its binaries are suffixed with "-4.2"; that is, it installs cpp-4.2, g++-4.2, gfortran-4.2, and so on. So a) there's no direct conflict with the Homebrew gfortran, and b) it won't directly shadow the /usr/local/bin/gfortran installed by Homebrew.
Which compiler will get picked up by things you build with both these gfortrans installed will depend on how the build works, but most will be looking for plain gfortran and so will find the Homebrew one, unless you explicitly direct them to the AT&T-provided one. You don't specify how you're building things, but since you're using brew, I'm assuming it's via brew or command line tools, in which case I think they're all probably seeing the Homebrew gfortran and ignoring this one. Look at the verbose output from their build processes to find out for sure.
*Depending, of course on what you mean by "conflict".
**Side note: AFAIK there's no easy way to figure this out by looking at the package or an installation manager. I just did a find /usr before and after running that installer, and did a diff on the output:
$ diff usr_before_any_installs.txt usr_after_att_install.txt | grep '^[<>]'
> /usr/bin/c++-4.2
> /usr/bin/cpp-4.2
> /usr/bin/g++-4.2
> /usr/bin/gcc-4.2
> /usr/bin/gfortran-4.2
> /usr/bin/i686-apple-darwin11-cpp-4.2.1
> /usr/bin/i686-apple-darwin11-g++-4.2.1
> /usr/bin/i686-apple-darwin11-gcc-4.2.1
> /usr/bin/i686-apple-darwin11-gfortran-4.2.1
> /usr/include/gcc
> /usr/include/gcc/darwin
> /usr/include/gcc/darwin/4.2
...

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