GCC 9 header errors when installed with homebrew - macos

I've got GCC 9 installed via homebrew on macOS Catalina 10.15.1. I'm setting -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk. When compiling a file that includes stdio.h, I get compile errors:
/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin19/9.2.0/include-fixed/stdio.h: In function 'perror':
/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin19/9.2.0/include-fixed/stdio.h:183:28: error: expected declaration specifiers before '__cold'
183 | void perror(const char *) __cold;
| ^~~~~~
/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin19/9.2.0/include-fixed/stdio.h:200:1: error: expected declaration specifiers before '__attribute__'
200 | __deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.")
| ^~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin19/9.2.0/include-fixed/stdio.h:219:10: fatal error: _ctermid.h: No such file or directory
219 | #include <_ctermid.h>
| ^~~~~~~~~~~~
Is there any solution to this? Is this a GCC bug or homebrew?

Related

macOS command line tools and gcc suddenly failing on Catalina (worked on Mojave)

Command Line tools are giving a multitude of errors when trying to install MuJoCo. I suspect with high confidence that this is an issue from the command line tools on my macOS Catalina since I have installed mujoco previously on Mojave and multiple ubuntu machines. The following installations had worked on Mojave.
First I perform:
xcode-select --install
Further information:
(base) ryanr#RRMBP ~ % /usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I install using pip3 install 'mujoco-py<2.1,>=2.0'
I am greeted with errors as the following:
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:34:
> error: expected declaration specifiers before
> '__OSX_AVAILABLE_STARTING' int getiopolicy_np(int, int)
> __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
> ^~~~~~~~~~~~~~~~~~~~~~~~
and
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:144:1: error: expected declaration specifiers before 'div_t'
div_t div(int, int) __pure2;
^~~~~
and
In file included from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:34:0,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/glshim.h:4,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-4_wykvnc/mujoco-py/mujoco_py/gl/dummyshim.c:1:
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:59:19: error: storage class specified for parameter 'float_t'
typedef float float_t;
^~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:60:20: error: storage class specified for parameter 'double_t'
typedef double double_t;
^~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:126:12: error: storage class specified for parameter '__math_errhandling'
extern int __math_errhandling(void);
^~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:146:12: error: storage class specified for parameter '__fpclassifyf'
extern int __fpclassifyf(float);
^~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:147:12: error: storage class specified for parameter '__fpclassifyd'
extern int __fpclassifyd(double);
^~~~~~~~~~~~~
/usr/local/Cellar/gcc#6/6.5.0_2/lib/gcc/6/gcc/x86_64-apple-darwin18.5.0/6.5.0/include-fixed/math.h:148:12: error: storage class specified for parameter '__fpclassifyl'
extern int __fpclassifyl(long double);
^~~~~~~~~~~~~
and
^
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:0,
from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h:66,
from /Users/ryanr/.mujoco/mujoco200/include/mujoco.h:33,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/glshim.h:4,
from /private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:1:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:9: error: old-style parameter declarations in prototyped function definition
int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
^~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h:443:1: error: parameter name omitted
/private/var/folders/q7/q_59j36d5n31209r5c01mx2w0000gp/T/pip-install-jye6hn52/mujoco-py/mujoco_py/gl/dummyshim.c:37:1: error: expected '{' at end of input
}
^
error: command '/usr/local/bin/gcc-6' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for mujoco-py
Any suggestions as to why my command-line tools are failing on macOS Catalina? What steps should one take to ensure that the command-line tools and gcc on Catalina are working as expected?
Pass the previous version’s OS X sdk as sysroot, instead of the unversioned sdk.
Command-line tools are failing on macOS Catalina due to incorrect SDK directory.
What steps should one take to ensure that the command-line tools and gcc on Catalina are working as expected? Reference the versioned SDK:
./configure --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
and/or
./configure --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

Installing gosu on FreeBSD

I'm trying to install this Ruby gem on FreeBSD, and it's failing with the following error:
# gem install gosu
Building native extensions. This could take a while...
ERROR: Error installing gosu:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.4/gems/gosu-0.14.5/ext/gosu
/usr/local/bin/ruby24 -I /usr/local/lib/ruby/site_ruby/2.4 -r ./siteconf20190322-6847-x8s25j.rb extconf.rb
The Gosu gem requires some libraries to be installed system-wide.
See the following site for a list:
https://github.com/gosu/gosu/wiki/Getting-Started-on-Linux
cat: /proc/cpuinfo: No such file or directory
checking for -lopenal... yes
checking for AL/al.h... yes
creating Makefile
current directory: /usr/local/lib/ruby/gems/2.4/gems/gosu-0.14.5/ext/gosu
make "DESTDIR=" clean
current directory: /usr/local/lib/ruby/gems/2.4/gems/gosu-0.14.5/ext/gosu
make "DESTDIR="
compiling ../../src/Audio.cpp
In file included from ../../src/Audio.cpp:17:
../../src/SndFile.hpp:111:33: warning: field 'buffer' is uninitialized when used here [-Wuninitialized]
: file(nullptr), reader(buffer.front_reader())
^
../../src/SndFile.hpp:123:33: warning: field 'buffer' is uninitialized when used here [-Wuninitialized]
: file(nullptr), reader(buffer.front_reader())
^
2 warnings generated.
compiling ../../src/AudioImpl.cpp
compiling ../../src/Bitmap.cpp
compiling ../../src/BitmapIO.cpp
compiling ../../src/BlockAllocator.cpp
compiling ../../src/Channel.cpp
compiling ../../src/Color.cpp
compiling ../../src/DirectoriesApple.cpp
compiling ../../src/DirectoriesUnix.cpp
compiling ../../src/DirectoriesWin.cpp
compiling ../../src/FileUnix.cpp
../../src/FileUnix.cpp:53:47: error: use of undeclared identifier 'S_IRUSR'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
../../src/FileUnix.cpp:53:55: error: use of undeclared identifier 'S_IWUSR'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
../../src/FileUnix.cpp:53:63: error: use of undeclared identifier 'S_IRGRP'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
../../src/FileUnix.cpp:53:71: error: use of undeclared identifier 'S_IWGRP'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
../../src/FileUnix.cpp:53:79: error: use of undeclared identifier 'S_IROTH'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
../../src/FileUnix.cpp:53:87: error: use of undeclared identifier 'S_IWOTH'
pimpl->fd = open(filename.c_str(), flags, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
^
6 errors generated.
*** Error code 1
Stop.
make: stopped in /usr/local/lib/ruby/gems/2.4/gems/gosu-0.14.5/ext/gosu
Other things I tried:
Switching compilers - from clang and c++ to g++ and gcc.
Cloning the repository and building "manually" - got the same errors.
Is it even possible to install it on FreeBSD? Searches didn't return anything useful.
On FreeBSD system headers are organized slightly differently than in Linux.
Quick man lookup reveals, that you need to
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
to make these definitions visible.

error: ‘deprecated’ was not declared in this scope

I updated my program to --std=c++11 and now I get:
g++ --std=c++11 -c eqc.cpp
In file included from eqc.cpp:16:0:
eqc.h:372:80: error: ‘deprecated’ was not declared in this scope
eqc.h:372:92: error: expected ‘)’ before ‘;’ token
eqc.h:372:92: error: expected ‘)’ before ‘;’ token
In file included from eqc.cpp:16:0:
eqc.h:372:74: error: expected unqualified-id before ‘)’ token
equation &operator[](const std::string &label) __attribute__((deprecated));
If I use the new way of specifying attributes, it's the same:
In file included from eqc.cpp:16:0:
eqc.h:371:67: error: ‘deprecated’ was not declared in this scope
eqc.h:371:79: error: expected ‘]’ before ‘;’ token
In file included from eqc.cpp:16:0:
eqc.h:371:61: error: expected unqualified-id before ‘]’ token
equation &operator[](const std::string &label) [[deprecated]];
Since I can't find anything on the web about this error, I must be making some silly mistake. But which?
The system is Ubuntu 16.04 and the compiler:
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
The problem was a library (libginac6 1.7.0) that said
#define deprecated attribute ((deprecated));
After updating the library (to version >= 1.7.1) the error disappeared since the library now says
#define attribute_deprecated attribute ((deprecated));

CppuTest to build with C++11 versions

Installed g++ 4.9.0 (experimental) version under Ubuntu (I am using certain features provided by this version)
When building my code, I use cmake from a script, and it builds correctly. gcc below contains the path where g++ is installed (/mnt...)
$_cmake_ $_dir_ -DCMAKE_CXX_COMPILER=${_gpp_} -DCMAKE_C_COMPILER=${_gcc_} -DCMAKE_BUILD_TYPE=${_build_} -DCMAKE_INSTALL_PREFIX=${_install_} -DBUILD_TESTING:BOOL=1
Now, when I make the CppuTest to build the Unit Tests for my code, I get the following error.
make all
compiling UncrosserTest.cpp
In file included from /home/miguel/Desktop/Ugur/scmProject/scm/dist/dev/mfx_prod/scm/20160207/include/scm/services/primitives.hpp:4:0,
from /home/miguel/Desktop/Ugur/scmProject/log/lidya/src/cpp/scm/services/examples/dummy_strategy/Inside.hpp:6,
from AllTests/Uncrosser/UncrosserTest.cpp:7:
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, _ShouldProvideDestructor>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:294:18: error: expected type-specifier
::new (std::__addressof(this->_M_payload))
^
/usr/include/c++/4.9/experimental/optional:294:18: error: expected ‘)’
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, false>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:424:18: error: expected type-specifier
::new (std::__addressof(this->_M_payload))
^
/usr/include/c++/4.9/experimental/optional:424:18: error: expected ‘)’
make: *** [objs/AllTests/Uncrosser/UncrosserTest.o] Error 1
In the CppuTest makefile have included CPPUTEST_CPPFLAGS += -std=c++1y. I guess that am missing some flags in this makefile because as I said the C++ experimental library is building correctly in my "regular" code. What am I missing ?
Possible it's an include problem, see CppUTest Manual - section Conflicts with operator new macros (STL!) and Conflicts with my own overload!
TL;DR
In UncrosserTest add includes for CppUTest after your's.
Instead of
#include <CppUTest/TestHarnes.h>
#include "whatever.h"
do
#include "whatever.h"
#include <CppUTest/TestHarnes.h>

How to make librtmp compile on Mac OS X

I am trying to build rtmpdump and librtmp on mac, however I cannot for the life of me work out why it isn't working. I am using my own built openssl:
$ openssl version
OpenSSL 1.1.0-pre3 (alpha) 15 Feb 2016
I have set the flags correctly (I think), but yet when I try and compile I get this:
$ make INC=-I/usr/local/include
gcc -Wall -I/usr/local/include -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o rtmp.o rtmp.c
In file included from rtmp.c:152:
./handshake.h:120:12: error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
HMAC_CTX ctx;
^
/usr/local/include/openssl/ossl_typ.h:145:16: note: forward declaration of 'struct hmac_ctx_st'
typedef struct hmac_ctx_st HMAC_CTX;
^
In file included from rtmp.c:152:
./handshake.h:125:3: warning: implicit declaration of function 'HMAC_CTX_init' is invalid in C99 [-Wimplicit-function-declaration]
HMAC_setup(ctx, secretKey, 128);
^
./handshake.h:72:35: note: expanded from macro 'HMAC_setup'
#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
^
./handshake.h:127:3: warning: implicit declaration of function 'HMAC_CTX_cleanup' is invalid in C99 [-Wimplicit-function-declaration]
HMAC_finish(ctx, digest, digestLen);
^
./handshake.h:74:67: note: expanded from macro 'HMAC_finish'
#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
^
./handshake.h:269:12: error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
HMAC_CTX ctx;
^
/usr/local/include/openssl/ossl_typ.h:145:16: note: forward declaration of 'struct hmac_ctx_st'
typedef struct hmac_ctx_st HMAC_CTX;
^
rtmp.c:192:13: warning: comparison of constant 18446744073709551597 with expression of type 'uint32_t' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
if (nSize > SIZE_MAX - RTMP_MAX_HEADER_SIZE)
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings and 2 errors generated.
make[1]: *** [rtmp.o] Error 1
make: *** [librtmp/librtmp.a] Error 2
It looks like it might be a compatibility issue with the version of OpenSSL I'm using. Does anyone know how to fix this kind of issue, or any changes to OpenSSL that might be responsible?
OpenSSL 1.1.0-pre3 (alpha) 15 Feb 2016...
Does anyone know how to fix this kind of issue, or any changes to OpenSSL that might be responsible?
Broadly speaking, there appears to be two high level changes in OpenSSL 1.1.x that caused most of the problems. First was the changes to the build system. Second was the firmer posture with respect to private APIs. I think you're seeing an artifact of the second, the private APIs.
Generally speaking, 1.1.0-pre3 and 1.1.0-pre4 have a number of problems and mostly can't achieve a successful make test. The issues include configuration and build issues for 32-bit OS X PowerMac, 64-bit OS X PowerMac, 32-bit OS X, 64-bit OS X, 32-bit ARM, 64-bit ARM, OpenBSD 5.7, NetBSD 7.0, Cygwin, CentOS 5, CentOS 7 and i686. So many so that I've filed about 25 bugs in preparation for the upcoming Beta-1 scheduled to arrive Monday, 14 MAR 2016.
You should probably avoid 1.1.0-pre-N at the moment because its so unstable. You should be OK under x86_64 Linux, but anything else is a crap shoot at the moment. You should be able to pick it up again around Beta-2.
You will probably have better luck with the tip of Master after commits from Friday, 11 MAR 2016. That would be roughly commits 0d4d5ab and 4c1cf7e. You can get the latest with:
git clone git://git.openssl.org/openssl.git
Or, use 1.0.2 stable releases.

Resources