Issue compiling a piece of open source software written in C++ on MacOS Sierra - c++

I am trying to install a piece of open source software (AB3P) on MacOS Sierra. When I issue the command make I get this error: ld: library not found for -lops. The make command issued before the error is thrown is: g++ -g -o make_wordSet make_wordSet.o -L./Library -lops -D_POSIX_C_SOURCE=199506L -lpthread
I have the latest version of MacOS Sierra and Xcode + the Xcode command line developer tools (as of this writing). In addition gcc is installed, the command gcc --version returns:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I am not sure how to approach the problem, any suggestions?

Get into Library folder, and make it first.
cd Library
make
There it will find the libops.a
On the updated version of the Ab3P as #ridoro1 mentioned, you need to make first NCBITextLib and edit the both Makefiles under Ab3P and also under Library.
First get into Library and make it. Then make Ab3P.

You need to download this library and compile it, then edit Makefile in the folder of this library and the Makefile in the lib folder inside it to point to NCBITextLib-master folder on your disk, after that You can compile the ABP3 library.

Related

How to use MinGW with thread model posix on Anaconda

I am on Win10. I installed MinGW in Anaconda through
$ conda install -c anaconda mingw
But when I check with $ g++ -v
I see Thread model: win32, which does not support C++11 Thread class. As results when I run $ g++ myprogram.cpp -std=c++11 I got error
error: 'thread' is not a member of 'std'
Outside of Anaconda, I installed MinGW with installer from https://sourceforge.net/projects/mingw-w64/
When installing, choose "posix", and I got what I need.
So my question is, how to make this happen in Anaconda? I want to either
Set Anaconda's C++ compiler to the one outside (the one I installed with installer)
or, install a MinGW with posix in Anaconda.
I tried to find solutions online, the following helped me sorted out my questions. But I couldn't find a solution yet.
Troubles with POSIX program using threads with gcc
https://coderwall.com/p/rzkw6q/compile-c-code-with-c-11-threads
https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html
The full output is as below. I appreciate for your help!
$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\ProgramData\Anaconda3\Scripts\g++.bat\..\..\MinGW\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/programdata/anaconda3/mingw/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../build/gcc/src/configure --target=x86_64-w64-mingw32 --prefix=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root --with-sysroot=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root --enable-languages=all,obj-c++ --enable-fully-dynamic-string --disable-multilib
Thread model: win32
gcc version 4.7.0 20111220 (experimental) (GCC)

clang++ installed via homebrew (macOS): compilation errors

After installing clang++ (tried v. 6.0.1 and 7.0) with:
brew install --with-toolchain llvm
very trivial programs result to the following error:
In file included from test.cpp:1:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iostream:38:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/ios:215:
In file included from /usr/local/Cellar/llvm/7.0.0/include/c++/v1/iosfwd:90:
/usr/local/Cellar/llvm/7.0.0/include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
Command used to compile:
clang++7() {
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
CPPFLAGS="-I/usr/local/opt/llvm/include"
/usr/local/opt/llvm/bin/clang++ -std=c++11 $CPPFLAGS $LDFLAGS $1
}
Is it possible to use the official clang instead of Apple's version?
With Apple's version, we do not even know which version of LLVM it really is...
It appears that as of Mojave (10.14), Xcode doesn't install system headers in /usr/include anymore. There is a compatibility package that does, but it's not recommended.
Instead, the official solution is for tools to search for headers in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk. That path can be obtained from
xcrun --show-sdk-path
The release notes say
The Command Line Tools package installs the macOS system headers inside the macOS SDK. Software that compiles with the installed tools will search for headers within the macOS SDK provided by either Xcode at:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
or the Command Line Tools at:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
depending on which is selected using xcode-select.
If you built clang yourself, this can be achieved by passing the -isysroot option to clang:
clang++ -isysroot "$(xcrun --show-sdk-path)" …
See also: https://github.com/Homebrew/homebrew-core/issues/32765
It works for me to add a -I (minus eye) option to the clang++ command line, pointing to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include

gfortran doesn't work after upgrading to El Capitan

I tried upgrading to El-Capitan and Xcode 7.0 and now gfortran doesn't work. Everytime I run gfortran, I get errors which google search doesn't seem to resolve so I'm asking stack overflow:
I'm trying to compile a minimal example program:
program hello
print *, "Hello World"
end program hello
When I run gfortran test.f
gfortran: warning: couldn’t understand kern.osversion ‘15.0.0
ld: library not found for -lgcc_s.10.4
collect2: error: ld returned 1 exit status
I'm not worried about the warning but the error of the ld is what's really bothering me. There's libgcc_s.10.4.tbd in the /usr/lib folder but it seems not be used by gfortran.
Can anyone help me resolve this as I would like to use gfortran for compiling some libraries?
MORE info: running gfortran -v outputs
gfortran: warning: couldn’t understand kern.osversion ‘15.0.0
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin12.2.0/4.8.0/lto-wrapper
Target: x86_64-apple-darwin12.2.0
Configured with: ../gcc-4.8-20120930/configure --enable languages=c++,fortran
Thread model: posix
gcc version 4.8.0 20120930 (experimental) (GCC)
The version of gfortran you have (4.8 installed into /usr/local) is not a version of GCC that apple would have distributed with Xcode (afaik they never made it to a version of GCC that new before switching to llvm, which has no Fortran front-end. The version of gcc distributed with Xcode 7 on el capitan identifies itself as:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.0.72)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
Your version came from somewhere else and is old enough to not know the x86_64-apple-darwin15.0.0 target. You'll need to update that compiler to get a working gfortran. Both macports and homebrew provide easy installations of various versions of gcc/gfortran on OS X el capitan, and I'd recommend using one of those to install gcc. Alternatively you can track down whatever you used to install gcc 4.8 before and see if they provide an update for el capitan.

Eclipse /bin/sh: g++: command not found

I had to upgrade my gcc version to utilize the new C++11 standards. After following the instructions at http://ask.xmodulo.com/upgrade-gcc-centos.html . I started getting the error "/bin/sh: g++: command not found" when I try to build my project. How can I fix this? It looks like gcc installed fine by looking at the below output.
gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
G++ appears to be not installed. Find how to install gcc in your OS. After this, you have to make Eclipse find g++. I recommend to you, to install CDT plugins. They have many ready tools for C/C++ programming and it is fully compatible with gcc toolset.

"-std=gnu++0x"option for MacOS

I'm trying to compile a CMake project which uses
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wall -std=gnu++0x")
in the CMakeLists.txt file under MacOS X Lion. I have installed XCode 4.2.1. but the compiler fails with this:
cd something/src/lib && /usr/bin/c++ -Dlib_ginacra_EXPORTS -Wall -std=gnu++0x -fPIC -o CMakeFiles/lib_ginacra.dir/utilities.cpp.o -c something/src/lib/utilities.cpp
cc1plus: error: unrecognized command line option "-std=gnu++0x"
The compiler's verion is:
c++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
GCC 4.2 is ancient, but Apple don't ship a newer version.
You can either install a modern GCC from somewhere like Mac Ports (which is probably simpler and quicker) or build it yourself following the instructions at http://gcc.gnu.org/wiki/InstallingGCC
For Lion users facing this issue:
Download and Install the MacPorts-2.2.1-10.7-Lion.pkg MacPorts
installer package from here
in a terminal, search for newer GCC versions:
$ port search --name --glob 'gcc*'
install a newer version (I went with gcc5)
$ sudo port install gcc5
get the name of your new version, and set it as default
$ port select --list gcc
Available versions for gcc:
llvm-gcc42
mp-gcc5
none (active)
$ sudo port select --set gcc mp-gcc5
open a new terminal and validate you're updated:
$ c++ --version
c++ (MacPorts gcc5 5.2.0_0) 5.2.0
Most of you getting that error "cc1plus: error: unrecognized command line option -std=gnu++0x" while installing nodejs extension which requires C++ compilation with node-gyp.
So how to solve this error so here is the solution. Basically you get these errors because of Nodejs different version as many node libraries requires C or C++ compilation while installing. So Nodejs older version uses python 2.7 with gcc compiler less than version 4.2 but Nodejs newer version uses gcc44 compiler that's why you get above error while installing any nodejs library.
So you need to degrade your nodejs and node-gyp version and specify the python version if you have multiple python versions installed on your system and then you will not get above error anymore.
Click here to see full tutorial