Installing recen version of GCC - g++

I am a novice so please bear with me if I ask something that is silly in nature. I wanted to install getfem++ on my Mac for my research and had to compile it from the source as per the instructions given at:
http://download.gna.org/getfem/html/homepage/python/install.html#in-a-general-unix-linux-based-systems
However, when I give the following command:
./configure --enable-python=yes
it gives me the following error:
configure: error: g++ do not support option -std=c++11. Update g++ to at least release 4.8.1.
SO I installed g++ using Homebrew and as per the instructions given by #quine on
https://apple.stackexchange.com/questions/99077/how-to-set-gcc-4-8-as-default-gcc-compiler
I edited the bash profile and added the necessary lines to set alias.
Then I checked the g++ version using g++ -v
and it says 4.8.5 as per the last line. Now when I run the configure command as before, I get the same error. as: configure: error: g++ do not support option -std=c++11. Update g++ to at least release 4.8.1.
Can someone help me by pointing out where I am going wrong? Thank you!!

Related

CMake 3.18.0 not finding libopenjpeg2

Please forgive my ignorance when is comes to Cmake. I'm trying to install Poppler 0.86.1 on Centos 7 but I am stuck with an error that says CMake Error at CMakeLists.txt:208 (message): Install libopenjpeg2 before trying to build poppler. I have installed libopenjpeg2 including the dev package by running the following:
sudo yum install openjpeg2-devel
I am taking the following steps to install poppler:
wget https://poppler.freedesktop.org/poppler-0.86.1.tar.xz
tar xf poppler-0.86.1.tar.xz
cd poppler-0.86.1/
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
Which results in the following error
CMake Error at CMakeLists.txt:208 (message):
Install libopenjpeg2 before trying to build poppler. You can also decide
to use the internal unmaintained JPX decoder or none at all.
-- Configuring incomplete, errors occurred!
This is where the failure occurs in the CMakeLists.txt
if(ENABLE_LIBOPENJPEG STREQUAL "openjpeg2")
find_package(OpenJPEG)
set(WITH_OPENJPEG ${OpenJPEG_FOUND})
if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION VERSION_LESS 2)
message(FATAL_ERROR "Install libopenjpeg2 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all.")
endif()
...
Can anyone point me in the right direction in figuring out how to get Poppler 0.86.1 to successfully install on Centos 7?
If I remember correctly, I had the same problem when I was trying to use the latest version of the Poppler in my Docker image. I fixed it by installing libopenjp2-7-dev. Please check my answer, specifically, the second row of my Dockerfile where you can see what I installed before running cmake.
I hit this and it was due to https://github.com/uclouvain/openjpeg/issues/1174. I modified my local copy of /lib64/openjpeg-2.3/OpenJPEGConfig.cmake to work around this.

How to install and use libnet in mac os?

I want to program in C with libnet in Mac OS.
When I type in gcc *.o -o network -lnet, there's an error:
library not found for -lnet.
And when I use homebrew install linnet, is says:
Warning: libnet-1.1.6 already installed.
It is the problem of library PATH.Flow the steps to solve this problem.
First, find where you install the library. For my case, the libnet is located in /usr/local/Cellar/libnet/1.1.6.
Second, run /usr/local/Cellar/libnet/1.1.6/bin/libnet-config.
Third, use -L to add the path when you link.
gcc *.o -L/usr/local/Cellar/libnet/1.1.6/lib -lnet.

Troubles installing Apache2 from source Redhat 6

I am trying to install the most current Apache version. I ran configure:
./configure --prefix=/usr/local/apache --enable-so --with-pcre=../pcre2-10.00/pcre2-config
But I then got this error message:
util_pcre.c:49:18: error: pcre.h: No such file or directory
util_pcre.c: In Function 'ap_regfree':
util_pcre.c:104: error: 'pcre_free' undeclared (first use in this function)
util_pcre.c:104: error: (Each undeclared identifier is reported only once
util_pcre.c:104: error: for each function it appears in.)....
I read that I would need to have gcc installed. And I have verified that gcc is installed. Do I need to declare it somewhere in the ./configure command? Thanks in advance!
Try to install pcre devel
yum install pcre-devel
and then run your previous code without pcre part
./configure --prefix=/usr/local/apache --enable-so
Hope this can help you.
As at version 2.4.25 of Apache it doesn't appear that you can compile with pcre2. You can either do what Milos Miskone Sretin suggests and use yum to install the pcre development headers or if you want to potentially have multiple versions of pcre then you have to compile and install pcre 8.40 and link against it instead.
Assuming you have installed pcre 8.40 into /usr/local/apps/pcre/8.40 then
./configure --prefix=/usr/local/apache --enable-so --with-pcre=/usr/local/apps/pcre/8.40
seems you are using pcre2 instead of pcre. Download and re-compile with PCRE.
because PCRE2 is the name used for a revised API for the PCRE library.

Newbie issue? gdal install failing: Xcode and or CLT are misconfigured

I've worked out several sets of problems in installing the libraries for working with D3 and geographic data, but every time I just get to another challenge on this yellow brick road. At least it seems that way after slogging through the installs. I've been to the homebew wikis and many webpages of people who document how they do install on real machines, not 'greenroom' machines
Other people have had similar problems, but I can't see a problem that matches this:
Trying to install gdal (on Mac OS X 10,8.4) following the bost.ocks.org/mike/map guide using
brew install gdal and trying to parse all kinds of errors and solutions others have logged.
I get the following error message now when I run brew install gdal:
gcc-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/libxml2-py.o build/temp.macosx-10.6-intel-2.7/libxml.o build/temp.macosx-10.6-intel-2.7/types.o -L/usr/local/Cellar/libxml2/2.9.1/lib -lxml2 -lm -lz -o build/lib.macosx-10.6-intel-2.7/libxml2mod.so
Your Xcode and or CLT are mis-configured. Try some or all of the following:
xcodebuild -license
sudo xcode-select -switch /path/to/Xcode.app
error: command 'gcc-4.2' failed with exit status 1
I ran xcodebuild -license which completed without an error; then retried brew install gdal again and got the same error. So I ran sudo xcode-select -switch /path/to/Xcode.app and got this message, which puts me back at the proverbial square 1:
xcode-select: Error: An error occurred while trying to -switch to '/path/to/Xcode.app'. (No such file or directory).
What does that message mean? What file or directory is the error referring to? This is what I can't find anywhere on stackoverflow.
Thanks much and in advance,
Francis
If you want to install gdal then I recommend KyngChaos' installer. It will put everything in as a framework. This doesn't really answer the specific question you asked but it perhaps gives you what you were trying to achieve (I hope).

How to make GNUstep libobjc2 to work?

I downloaded and built GNUstep libobjc2 1.6.1,
svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/1.6.1/ rep
cd rep
make
and got this error when I tried to compile a Objective-C code.
hoon#ubuntu:~/work/objc2$ clang -fobjc-nonfragile-abi -fobjc-arc -fblocks *.m *.a -l pthread; ./a.out
Objective-C ABI Error: Loading modules from incompatible ABIs while loading
a.out: loader.c:38: __objc_exec_class: Assertion `objc_check_abi_version(module)' failed.
Aborted (core dumped)
It seems I need to build libobjc.a with some different configurations. What is the problem and what should I do to fix this error?
Env: Ubuntu 12.04 LTS
This is a good question because LLVM and CLang and GNUstep don't claim to be hard or complicated to use. They do ask their users to read (and reread) their documentation though. I've just discovered this combination for Ubuntu myself and it is very intriguing. And there are a lot of moving parts at the moment.
If the OP got an answer on one of the gnustep mailing lists, then it would be nice to hear here how it was resolved.
Without suggesting the normal route of starting over and only installing the latest from LLVM and GNUstep directly, here's my take.
The OP is trying to use ARC and blocks with the runtime provided by the gunstep/libobjc2 project.
libobjc2 should probably be built with clang version 3.2 - or maybe the top of tree.
clang -v will tell you what version you have on your machine. I've found even Ubuntu 12.10 doesn't provide clang-3.2. So I download it from the LLVM website. They have prebuilt binaries for Ubuntu 12.04 LTS. To get make to use clang for this build step, I've seen instructions to set and export CC=clang and CXX=clang++.
Once libobjc2 is built, care must be taken where it gets installed. If the system already has an older libobjc.so.x.y library (this provides the runtime environment for Obj-C), clang or the linker may be picking up the wrong one when you start compiling your own source. I found libobjc.so.4.6.0 built from the libobjc2 source was installed to /usr/local/lib both on Ubuntu 12.04 and 12.10 when I ran the make install step. This path was not setup by the libobjc2 install step.
To get this library picked up, I had to add /usr/local/lib to the env variable LD_LIBRARY_PATH. It wouldn't hurt to try 'locate libojbc.so' to see if there are other versions on the system.
Finally, the libobjc2 readme, https://github.com/gnustep/gnustep-libobjc2#readme, says this new version of the gnustep library supports two ABIs, and each ABI supports ARC and blocks. The advice I've seen about compiling with libobjc2 is to also provide the runtime version expected to be compiling and linking with: -fobjc-runtime=gnustep. Clang on Ubuntu still defaults to the older ABI. -fobjc-nonfragile-abi may accomplish the same thing but I've seen it mentioned that flag was or will be deprecated.
The OP error may actually come from the step where a.out is being run, rather than where clang was compiled. Perhaps the dynamic loader is picking up the legacy libobj.so. Again, I would use locate to see if the system even has more than one.
This is just a guess, but I'm gonna go out on a limb and guess that GNUstep is going to build with GCC by default. A good first step might be to reconfigure the GNUstep build to use Clang. I can't say what variety of issues that will expose, but...
Alternately, you could try building your application with GCC instead of Clang.
This is a fairly late answer, but I have found a way to get everything working (on Elementary OS specifically so I imagine it should be fine on Ubuntu and similar distros).
As mentioned, it is better/easier to build everything from source because you get to pick the prefix, build options, etc. The general method:
Install cmake (if it's not already installed) --> sudo apt-get install cmake
Download, build and install llvm and clang as per the instructions here (or see attached build script). For speed, use the --enable-optimized flag. Tests are "optional" ;-)
The default build scripts for compiler-rt do not include the Blocks runtime. You could modify the build scripts, or rejoice that someone else has already done it (particularly if, like me, your cmake isn't great). Download, build and install libBlocksRuntime from this git repo (it is essentially a clone of the latest compiler-rt Blocks runtime code with custom build scripts). FOLLOW THEIR COMPILATION AND TESTING METHOD.
Download, build and install libobjc2 from GNUStep. The instructions for correct building are actually inside the now-deprecated makefile.
Run ldconfig (if required - though there's no harm in running it even if it isn't).
As #WeakPointer you may still need to edit the LD_LIBRARY_PATH environment variable to pick up your new libraries. Another option is to make some quick and dirty symlinks so clang can find your new libraries.
Final note: I haven't done any comparisons between GNUStep's libobjc2 and GCC's libobjc, the latter of which DOES contain some Objective-C 2.0 features... Be careful with your library selection if you keep both on your system at the same time!
The following script should do it all (untested!):
#!/bin/bash
# Temporary base directories
basedir="./clangllvm_temp"
basedir2="./libBlocksRuntime_temp"
basedir3="./libObjc2_temp"
# Clang, llvm, compiler-rt
mkdir $basedir
cd $basedir
svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
cd llvm/tools
svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
cd ../..
cd llvm/tools/clang/tools
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra
cd ../../../..
cd llvm/projects
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd ../..
mkdir build
cd build
../llvm/configure --prefix=$PREFIX --enable-optimized
make
sudo make install
cd ../..
# libBlocksRuntime
git clone https://github.com/mackyle/blocksruntime.git $basedir2
cd $basedir2
sudo ./buildlib
sudo ./checktests
sudo ./installlib
# Test!
clang -o sample -fblocks sample.c -lBlocksRuntime && ./sample
cd ..
# libobjc2
https://github.com/gnustep/gnustep-libobjc2.git $basedir3
cd $basedir3
mkdir Build
cd Build
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
sudo make && sudo -E make install
cd ../..
# Cleanup
rm -rf $basedir
rm -rf $basedir2
rm -rf $basedir3
# ldconfig
sudo ldconfig
# Additional symlink/LD_LIBRARY_PATH stuff here if required.
# EOF
Key difference was using Clang for build. Take care not to use GCC which is system default compiler. I removed gobjc and g++ packages from system to avoid this issue.
export CC=clang
export CXX=clang++
svn co http://svn.gna.org/svn/gnustep/libs/libobjc2/1.6.1/
cd 1.6.1
make
This answer was hinted from this mailing list thread:
http://lists.gnu.org/archive/html/discuss-gnustep/2012-12/msg00036.html
Described script is posted here:
http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux
Now it compiles simple ARC code.
It seems GCC and Clang generated codes are incompatible.
Update
I wrote scripts to setup libobjc2 on FreeBSD and CentOS.
The scripts are mostly copied from a blog.