clang error compiling mongodb from source

56 views
Skip to first unread message

debas...@endurance.com

unread,
Jul 5, 2016, 8:52:38 AM7/5/16
to mongodb-dev

I took a git checkout of mongodb source files and am trying to compile it. I have gcc installed as part of xcode-7.3.1 command-line tools

Now when I am trying to build the mongodb binaries using:


scons all

I am getting the below error:


scons
: Reading SConscript files ...

scons version
: 2.5.0

python version
: 2 7 10 'final' 0

Checking whether the C compiler works... yes

Checking whether the C++ compiler works... yes

Checking that the C++ compiler can link a C++ program... yes

Checking if C++ compiler "g++" is GCC... no

Checking if C++ compiler "g++" is clang... yes

Checking if C compiler "gcc" is clang... no

C compiler does
not match identified C++ compiler

See /Users/debashish.g/mongo-code/mongo/build/scons/config.log for details


In the config log it shows:


scons: Configure: Checking if C compiler "gcc" is clang...

build
/scons/sconf_temp/conftest_5.c <-
|
|#if defined(__clang__)
|/* we are using toolchain defined(__clang__) */
|#else
|#error
|#endif
|
gcc
-o build/scons/sconf_temp/conftest_5.o -c     build/scons/sconf_temp/conftest_5.c
build
/scons/sconf_temp/conftest_5.c:5:2: error: #error
#error
^~~~~
scons
: Configure: no


My gcc --version shows :


Configured with: -- prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-   dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.0.0
Thread model: posix
InstalledDir:   /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


As it seems , the gcc is using clang indeed. Where am I doing wrong? Please help. I am stuck on this for a long time now.

Andrew Morrow

unread,
Jul 11, 2016, 10:13:10 AM7/11/16
to mongodb-dev

Hi -

I'd say that there is something is pretty strange happening in your environment. What does 'gcc --version' say? What does 'g++ --version' say? How about 'clang --version' and 'clang++ --version'? Or 'cc --version' and 'c++ --version'?

Please note as well that you can explicitly override the C and C++ compilers by passing them as Variables on your SCons invocation:

scons CC=/path/to/c/compiler CXX=/path/to/c++/compiler

If it is the case that the 'gcc' and 'g++' tools really do refer to different  toolchains on your system, you can probably override them to point to a consistent toolchain with these Variables.

Thanks,
Andrew


--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages