Why is g++ linked to clang, not clang++, by the mac developer tools? - c++

I was just trying to explain to someone the difference between compiled and interpreted code, when I was greeted with a
main.cpp:1:10: fatal error: 'iostream' file not found
when calling g++ main.cpp for a simple hello world c++ file.
I looked into this a bit and found ...
JM:Desktop user$ which g++
/usr/local/bin/g++
JM:Desktop user$ ls -al /usr/local/bin/g++
lrwxr-xr-x 1 user admin 47 4 Dez 2018 /usr/local/bin/g++ -> /Library/Developer/CommandLineTools/usr/bin/c++
JM:Desktop user$ ls -al /Library/Developer/CommandLineTools/usr/bin/c++
lrwxr-xr-x 1 root wheel 5 3 Feb 20:29 /Library/Developer/CommandLineTools/usr/bin/c++ -> clang
...that g++ is linked to clang and not clang++ and I therefore call the C-compiler.
I just deleted the Developer tools and installed them again - same thing.
Is this normal or did something mess up my system? Does it make any sense? What am I missing?
Thanks for the help!

It may actually be Homebrew's fault somehow...
JM:Desktop user$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
/usr/local/bin is added by Homebrew.
'C++' for example links correctly to clang++ but it is in /usr/bin:
JM:Desktop user$ which c++
/usr/bin/c++
...and so is /usr/bin/g++.
I solved it by just deleting /user/local/bin/g++. The links are still strange.

Related

How to link OpenSSL in windows using MSYS2?

I wrote a c++ program using OpenSSL, it works fine on linux but when I try to compile on windows I get an error that libcrypto-1_1-x64.dll, libssl-1_1-x64.dll are missing
I am compiling using
g++ main.cpp -lws2_32 -LC:\msys64\mingw64\bin -IC:\msys64\mingw64\include\openssl
Both dll files can be found in C:\msys64\mingw64\bin, but the executable does not work
I just came up with a simple openssl example and compiled/linked fine
$ g++ ssltest.cpp -lssl -lcrypto -o ssltest
$ ls -l
-rw-r--r-- 1 Fred None 1072 Aug 21 01:18 ssltest.cpp
-rwxr-xr-x 1 Fred None 77824 Aug 21 01:18 ssltest.exe
It just works out of the box.
I am using the CLANG64 environment and I have the mingw-w64-clang-x86_64-openssl package installed. The files are installed on
$ pacman -Ql mingw-w64-clang-x86_64-openssl | grep '.dll'
mingw-w64-clang-x86_64-openssl /clang64/bin/libcrypto-1_1-x64.dll
mingw-w64-clang-x86_64-openssl /clang64/bin/libssl-1_1-x64.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/engines-1_1/capi.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/engines-1_1/padlock.dll
mingw-w64-clang-x86_64-openssl /clang64/lib/libcrypto.dll.a
mingw-w64-clang-x86_64-openssl /clang64/lib/libssl.dll.a

Conda Build fails packaging C++ project

I'm trying to create a recipe for the library here: https://github.com/hyrise/sql-parser
I'm building for OSX 10.13.
My build.sh looks like this:
#!/bin/bash
make VERBOSE=1
make DESTDIR="$PREFIX" install
I've also set up my SDK as per here: https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html#macos-sdk
I can build the project fine outside of conda build, however conda build fails with the below issue:
x86_64-apple-darwin13.4.0-clang++ -std=c++1z -Wall -Werror -O3 -fPIC -c -o src/SQLParser.o src/SQLParser.cpp
In file included from src/SQLParser.cpp:2:
In file included from src/SQLParser.h:4:
In file included from src/SQLParserResult.h:4:
In file included from src/sql/SQLStatement.h:4:
In file included from /Users/j/miniconda3/envs/p37/conda-bld/sql-parser_1583094509703/_build_env/bin/../include/c++/v1/vector:265:
In file included from /Users/j/miniconda3/envs/p37/conda-bld/sql-parser_1583094509703/_build_env/bin/../include/c++/v1/iosfwd:90:
/Users/j/miniconda3/envs/p37/conda-bld/sql-parser_1583094509703/_build_env/bin/../include/c++/v1/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
^~~~~~~~~
1 error generated.
make: *** [Makefile:66: src/SQLParser.o] Error 1
I can see wchar.h is in that dir
JMBA:v1 j$ ls -l /Users/j/miniconda3/envs/p37/conda-bld/sql-parser_1583094509703/_build_env/bin/../include/c++/v1 | grep wchar
-rw-rw-r-- 41 j staff 6272 28 Oct 2018 cwchar
-rw-rw-r-- 41 j staff 8080 28 Oct 2018 wchar.h
Any help on this would be appreciated.
You need to find a way to get -I$BUILD_PREFIX/include to the invocation of g++ / gcc

Installing Moses Translation Software. Error message: "ld: library not found for -lboost_thread"

I am installing the Moses Translation Software on my Mac OS X 10.9.5 with Xcode 6.1. The instructions say that I need g++ and Boost installed. Once I do that, I git clone, "cd" into the directory, and then type ./bjam -j8. First, I verified I have the prerequisites. First, g++ (I just clicked the TAB to see what was available):
$ g++
g++ g++-4.9
Then boost:
$ brew install boost
Warning: boost-1.56.0 already installed
Then I tried installing:
$ ./bjam -j8
Tip: install tcmalloc for faster threading. See BUILD-INSTRUCTIONS.txt for more information.
mkdir: bin: File exists
...patience...
...patience...
...found 4469 targets...
...updating 155 targets...
darwin.link lm/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/query
ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
// Additional error messages...
...failed darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/util_test...
...skipped <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>util_test.passed for lack of <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>util_test...
darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test
ld: library not found for -lboost_thread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"g++" -o "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test" "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/VocabularyTest.o" "mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/libmert_lib.a" -lboost_unit_test_framework -llzma -lbz2 -ldl -lboost_system -lz -lboost_thread -lm -liconv -g -Wl,-dead_strip -no_dead_strip_inits_and_terms
...failed darwin.link mert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi/vocabulary_test...
...skipped <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>vocabulary_test.passed for lack of <pmert/bin/darwin-4.2.1/release/debug-symbols-on/link-static/threading-multi>vocabulary_test...
...failed updating 72 targets...
...skipped 83 targets...
The build failed. If you need support, run:
./jam-files/bjam -j8 --debug-configuration -d2 |gzip >build.log.gz
then attach build.log.gz to your e-mail.
You MUST do 3 things before sending to the mailing list:
1. Subscribe to the mailing list at http://mailman.mit.edu/mailman/listinfo/moses-support
2. Attach build.log.gz to your e-mail
3. Say what is the EXACT command you executed when you got the error
ERROR
There's a ton of error messages not shown (condensed into "// Additional error messages"), and they are all of the form "ld: library not found for -lboost_thread". So it's clear that something can't find a boost-related library, but I don't know how to fix this. Does anyone have suggestions? I literally just copied a couple of lines from the installation instructions, and Moses is popular enough such that an obvious error in the installation instructions would have been caught long ago.
Additional comment: On the installation instructions page, they list a command where they can force an installer to find the boost library:
./bjam --with-boost=~/workspace/temp/boost_1_55_0 -j8
My boost is in
/usr/local/Cellar/boost/1.56.0/
I tried substituting the --with-boost= argument with the above file path, but that did not work either (I got the same errors).
I'm going to post this on the Moses mailing list but I'd also want to ask here because I have gotten this same error ("library not found ... clang: error: linker command failed with exit code 1") with other software and it would be helpful for me to learn a general strategy for making sure that clang can find my libraries.
This package expects a non-standard layout of boost (or maybe that's the standard liayout for installed boost on many systems, but it certainly isn't the default layout for boost in my working directories):
bjam --help says:
--with-boost=/path/to/boost
If Boost is in a non-standard location, specify it here. This directory is
expected to contain include and lib or lib64.
When my Boost build tree is in
/home/sehe/custom/boost/boost // headeers
/home/sehe/custom/boost/stage
/home/sehe/custom/boost/stage/lib // libraries
I have created a "forwarding" directory - so I'm not required to install boost:
mkdir /tmp/boost-moses
cd /tmp/boost-moses/
ln -sfv /home/sehe/custom/boost/stage/lib lib
ln -sfv /home/sehe/custom/boost include
Now I could trigger a build in the mosesdecoder directory with
./bjam --with-boost=/tmp/boost-moses
It's not said here which Moses version ComputerScientist compiled, but his last comment hit the nail. When I was about to compile version 2.1.1, I needed to rewrite Jamroot file and jam-files/boost-build/tools/mpi.jam and change all the boost_mpi mentions to boost_mpi-mt. It seems to me that boost-1.55 used different library style then boost-1.56 and Moses was in that version adapted to 1.55.
However I am not able to compile Moses 3.0 with either boost-1.55 or boost-1.56 now because of undefined reference to boost::filesystem::path::stem().
Unfortunatelly I can not post this as a comment to previous answer...

Why does b2 build with gcc4.6 when 4.8 is default?

While building a custom Boost.Python project, I encountered build errors that originated in lacking c++11 support of gcc-4.6 (the code to wrap compiled fine under VS2012). So I upgraded to 4.8 and used $ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 to redirect executions of gcc to the newer version:
$ gcc --version
gcc (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1
So far, so good. But as the error messages didn't change and on further inspection I noticed something:
link.jam: No such file or directory
...patience...
...patience...
...found 1710 targets...
...updating 2 targets...
gcc.compile.c++ bin/gcc-4.6/debug/extending.o //WHAT?
It looks like b2 still uses gcc-4.6. Yes it is still installed, but didn't I just replace it with gcc-4.8? I am very confused...
Also, can I specify the tollset-version manually? I tried toolset=gcc4.8 but that just ends in an error that gcc4.8.jam doesn't exist...
It turns out that I forgot to
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
That was kind of dumb, but this will hopefully help someone in the future. All kudos to #nos!

python installation "cc1.exe: error: unrecognized command line option '-mno-cygwin'"

Hi guys i'm trying to install rrdtool (for PYTHON 2.7) on my windows 7 system , i install it using this command line.
python setup.py install build --compiler=mingw32
it gives me the following output:
running install
running build
running build_ext
running build_configure
building 'rrdtoolmodule' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Irrdtool-1.4.7/src -IC:\Python2
7\include -IC:\Python27\PC -c rrdtool-1.4.7/bindings/python/rrdtoolmodule.c -o b
uild\temp.win32-2.7\Release\rrdtool-1.4.7\bindings\python\rrdtoolmodule.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
i have tried many solutions to solve this, but had no success.i'm using mingw version 4.6.2
can anyone pls help me .
See this answer: https://stackoverflow.com/a/6035864/1516291
you need to edit distutils\cygwinccompiler.py in your Python directory to remove all instances of -mno-cygwin
good luck