0

I am trying to use the xlc compiler for my cpp code on AIX. I want the cc compiler for my C code

output:

user@AIX> cmake -DCMAKE_CXX_COMPILER=/usr/vac/bin/xlc ..
-- The C compiler identification is XL 11.1.0
-- The CXX compiler identification is XL 11.1.0
-- Check for working C compiler: /usr/vac/bin/cc
-- Check for working C compiler: /usr/vac/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/vac/bin/xlc
-- Check for working CXX compiler: /usr/vac/bin/xlc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done

but when I run make ( right after the above output), it seems to be using the gcc compiler.

user@AIX> make
[  0%] Building CXX object ../libs/shrxml/CMakeFiles/shrxml.dir/XML.cpp.o
gcc: unrecognized option '-+'
gcc: unrecognized option '-qthreaded'
gcc: unrecognized option '-qhalt=e'
gcc: unrecognized option '-qnamemangling=v6'
gcc: unrecognized option '-qmaxmem=9216'
gcc: unrecognized option '-qnamemangling=v6'
gcc: unrecognized option '-qmaxmem=9216'
gcc: unrecognized option '-qpic'
In file included from /opt/freeware/lib/gcc/powerpc-ibm-
aix6.1.0.0/4.4.5/include/c++/backward/strstream:47,
                 from 
/home/user/workspace/bitbucket/ark/src/libs/shrxml/XML.cpp:105:
/opt/freeware/lib/gcc/powerpc-ibm-
aix6.1.0.0/4.4.5/include/c++/backward/backward_warning.h:28:2: warning: 
#warning This file includes at least one deprecated or antiquated header 
which may be removed without further notice at a future date. Please use a 
non-deprecated interface with equivalent functionality instead. For a 
listing of replacement headers and interfaces, consult the file 
backward_warning.h. To disable this warning use -Wno-deprecated.

I have tried adding the set inside my CMakeLists.txt file

 set(CMAKE_CXX_COMPILER /usr/vac/bin/xlc CACHE PATH "" FORCE)
 set(CMAKE_CC_COMPILER  /usr/vac/bin/cc  CACHE PATH "" FORCE)

I have also exported the environment variable:

user@AIX> echo $CMAKE_CXX_COMPILER
/usr/vac/bin/xlc
user@AIX> 

Any thoughts?

There are no links for cc or xlc in the /usr/vac/bin directory.

When I grep for gcc and xlc in the shrxlm directory all I can find is gcc. Why isn't cmake honoring my request for the xlc compiler?

Tim Edwards
  • 97
  • 1
  • 2
  • 13

2 Answers2

1

Check the cc symlink on your system to make sure it points to XL and not gcc. Do a which cc and then ls -l that.

Rafik Zurob
  • 361
  • 2
  • 6
  • Line `The C compiler identification is XL 11.1.0` in the configuration log suggests that XL compiler is actually detected by CMake. `gcc` compiler would produce other identification message. – Tsyvarev Oct 04 '17 at 21:45
1

According to the CMake FAQ "How do I use a different compiler?" section, there are 3 methods. It looks like you have tried to use all 3, including Method 3 (set()), which is marked "avoid".

Could you try Method 1: use environment variables again, but this time with the environment variables listed there, CC (for C) and CXX (for C++) environment variables?

Nicole Trudeau
  • 678
  • 3
  • 8