0

I'm trying to build the python module msgpack-python on Solaris with the Sun compiler and am getting this error during the python ./setup.py build:

/opt/SUNWspro/bin/cc -DNDEBUG -O -xO3 -m32 -xarch=sparc -I/opt/csw/include -xcode=pic32 -I/opt/csw/include/python2.6 -c msgpack/_msgpack.c -o build/temp.solaris-2.10-sun4v-2.6/msgpack/_msgpack.o
"/usr/include/stdbool.h", line 42: #error: "Use of <stdbool.h> is valid only in a c99 compilation environment."

I also tried compiling by adding'-std=c99' like mentioned here: Node.JS on Solaris

but end up with:

cc: Warning: illegal option -d=c99

Anyone have any ideas on what this stdbool.h error is and how to work around it.

Thanks.

Community
  • 1
  • 1
user1522264
  • 123
  • 1
  • 1
  • 5

2 Answers2

0

I don't know which version of Sun Studio you are running (which is important when it comes to whether or not it supports the Solaris 10 release you are using), but to get C99 mode, you can do one of two things:

  1. Run the command /opt/SUNWspro/bin/c99 - This is a wrapper executable which will kick off the Sun CC compiler in C99 mode.

  2. Run your command with the -xc99 flag - which will also trigger C99 mode in the compiler:

    /opt/SUNWspro/bin/cc -xc99 ...

Alternatively, you can also use the GCC compiler (usually installed in /usr/sfw/bin/gcc) to compile this C module, which is the compiler that supports the -std=c99 flag option. If I remember my Solaris work correctly, the gcc included with Solaris will use Sun's ld and link against the normal libc.so on the system just like cc will (not true at all for the C++ versions of each compiler).

wkl
  • 77,184
  • 16
  • 165
  • 176
  • Thanks for the response birryree. When I try either of those options I get this errors: /usr/include/sys/feature_tests.h", line 332: #error: "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications" Any idea on this one? :) Thanks. – user1522264 Jul 13 '12 at 00:40
  • @user1522264 - Apparently the code you're building is not compatible with C99, and it's likely because Python was not built with C99 support. There is a patch you can use for Python's source [here](http://bugs.python.org/issue1759169), or you can install a much newer version of Python (if you're using an old Solaris 10 release, you'll probably not have a very recent version at all). – wkl Jul 13 '12 at 02:14
  • Hmmm, Thanks for the expl. birryee. This is not looking good for me. I'm trying to package the python module on a buildfarm that is not in my control so I'm unlikely to be able to patch python. I'm also trying to build the package to be able to distribute it. I tried building with gnu cc and get this error: "gcc-4.7: error: language code=pic32 not recognized". If I remove the -xcode=pic32 option the module compiles fine. The problem is that the -xcode=pic32 is automatically put in via distutils and I'm not sure how to remove it for the automated build. That's another question though. Thanks. – user1522264 Jul 13 '12 at 02:48
0

Try export following:

export CFLAGS="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -features=extensions"

And then run configure script again, recompile. I think it will not require C99 compliance anymore. Most of OpenSource SW requires this defines to switch more OpenSource behavior of system headers.

More better use pkgsrc to compile OS software. It will do such tricks automatically.

nudzo
  • 17,166
  • 2
  • 19
  • 19
  • Hi Nudzo, Thanks for your suggestion. It looks like it's getting me a bit closer. I tried adding the CFLAGS you've suggested but still get the stdbool.h error. I found that if I also add -D_XPG6 with -xc99 I do not get the error, but the compile fails on some errors like: {code} "msgpack/unpack_template.h", line 205: "default" outside switch "msgpack/unpack_template.h", line 207: undefined label: _fixed_trail_again {code}. It seems like C compatibility is a little off. Do you have any suggestions on other options I might use so it behaves more like gcc? – user1522264 Jul 15 '12 at 11:11
  • Rather use mentioned `pkgsrc`. It will save you a lot of time. It uses many hacks to get things compile on Solaris... including patched autotools. I'm using it on my T1000, which is not as speedy machine for compilation. It saved me a lot of time comparing to my tries compile manually. Also you will get quarterly updates. – nudzo Jul 15 '12 at 21:13