error: expected initializer before `extern` on GCC libraries - c++

I'm trying to build code on another system. Machine A builds the code Machine B does not. Machine B needed updated to GCC 6.1.0 in order to compile said code. The update was handled exactly the same as Machine A's upgrade to GCC 6.1.0. I need to build several applications and they all output a similar error when building on Machine B:
In file included from /usr/include/features.h:375:0,
from /usr/include/string.h:25,
from app.h:12,
from app.c:28:
/usr/include/sys/types.h:27:1: error: expected initializer before 'extern'
__BEGIN_DECLS
^
In file included from /usr/local/include/c++/6.1.0/new:40:0,
from /usr/local/include/c++/6.1.0/ext/new_allocator.h:33,
from /usr/local/include/c++/6.1.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /usr/local/include/c++/6.1.0/bits/allocator.h:46,
from /usr/local/include/c++/6.1.0/string:41,
from ./Lib/Inc/AppCommon.h:11,
from ./Lib/Inc/header0.h:10,
from ./Lib/Inc/header1.h:4,
from ./Lib/Inc/header2.h:10,
from app.c:30:
/usr/local/include/c++/6.1.0/exception:35:37: error: expected declaration before end of line
#pragma GCC visibility push(default)
^
This error is not present on Machine A when building the applications. Is this a problem with GCC libraries? What differences between the environments, that I might not be accounting for, cause such an error? Could this have to do with the order files that need to be included in the build command; would this be different on different machines of the same environment?

Related

Why am I getting this error with MinGW and Cmake?

So I am trying to compile this flip fluids addon with blender, so I followed this tutorial, https://www.youtube.com/watch?v=TVKM1egDoGs , So I first ran cmake.exe -G "MinGW Makefiles" .. and it was telling me that it was missing a CMakeLists File... So I added one... then I ran cmake.exe --build . and it got to 3 percent than showed me errors like ...
In file included from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/threadutils.h:29,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/meshlevelset.h:65,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/meshobject.h:30,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/fluidsimulation.h:38,
from C:\Users\N\Downloads\Blender-FLIP-Fluids-master\src\engine\c_bindings\fluidsimulation_c.cpp:25:
C:/PROGRA~2/MINGW-~1/I686-8~1.0-P/mingw32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/mutex:93:9: note: previous definition of 'class std::recursive_mutex'
class recursive_mutex : private __recursive_mutex_base
^~~~~~~~~~~~~~~
In file included from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/mingw32_threads/mingw.condition_variable.h:25,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/threadutils.h:31,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/meshlevelset.h:65,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/meshobject.h:30,
from C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/fluidsimulation.h:38,
from C:\Users\N\Downloads\Blender-FLIP-Fluids-master\src\engine\c_bindings\fluidsimulation_c.cpp:25:
C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/mingw32_threads/mingw.mutex.h:142:44: error: conflicting declaration 'typedef class std::_NonRecursive<std::recursive_mutex> std::mutex'
This is the full error https://pastebin.com/KTnALG1E, where is this coming from?? is it a mingw error or what? Can someone help please?
Your full error message includes a more interesting bit:
C:/Users/N/Downloads/Blender-FLIP-Fluids-master/src/engine/mingw32_threads/mingw.thread.h:32:2:
error: #error This version of MinGW seems to include a win32 port of
pthreads, and probably already has C++11 std threading classes
implemented, based on pthreads. It is likely that you will get class
redefinition errors below, and unfortunately this implementation can
not be used standalone and independent of the system header,
since it relies on it for std::unique_lock and other utility classes.
If you would still like to use this implementation (as it is more
lightweight), you have to edit the c++-config.h system header of your
MinGW to not define _GLIBCXX_HAS_GTHREADS. This will prevent system
headers from defining actual threading classes while still defining
the necessary utility classes.
So either install a different version of mingw or edit your mingw files according to the instructions above.

Mingw32 errors when building OpenCV 3.2.0 on Windows 7

I'm trying to build OpenCV 3.2.0 vc14 from its sources with MinGW 5.3.0 32 bit in order to use its functionality from Qt 5.8. My platform is Windows 7 64 bit.
The main instruction I follow is here, on Qt's wiki. On several steps, I encounter errors for which I haven't found solutions yet. As I am a newbie, I apologize for my helplessness and will appriciate any suggestions.
Error 1. On the stage of generating build files.
In cmake-gui (cmake-3.2.1-win32-x86), I precisely follow the steps specified in the Qt wiki article mentioned above. However, during the final generation, the following CMake error occurs at the end:
CMake Error in modules/highgui/CMakeLists.txt:
No known features for CXX compiler
"GNU"
version 5.3.0.
Generating done
I wonder how it affects the project files and if it causes the next errors.
Error 2. When trying to build OpenCV
The build process is interrupted midway, logging the following:
In file included from C:/Qt/Tools/mingw530_32/i686-w64-
mingw32/include/c++/type_
traits:35:0,
from C:/Qt/5.8/mingw53_32/include/QtCore/qglobal.h:45,
from C:/Qt/5.8/mingw53_32/include/QtCore/QtCore:4,
from C:/Qt/5.8/mingw53_32/include/QtOpenGL/QtOpenGLDepends:3,
from C:/Qt/5.8/mingw53_32/include/QtOpenGL/QtOpenGL:3,
from C:/opencv/sources/modules/highgui/src/window_QT.h:46,
from C:\opencv\sources\modules\highgui\src\window_QT.cpp:47:
C:/Qt/Tools/mingw530_32/i686-w64-
mingw32/include/c++/bits/c++0x_warning.h:32:2:
error: #error This file requires compiler and library support for the ISO
C++ 2011 standard. This support is currently experimental, and must be
enabled with the -std=c++11 or -std=gnu++11 compiler options.
(...)
C:/Qt/5.8/mingw53_32/include/QtCore/qcompilerdetection.h:562:6: error:
#error Qt requires a C++11 compiler and yours does not seem to be that.
(...)
^
C:/Qt/5.8/mingw53_32/include/QtCore/qtypeinfo.h:62:40: error: expected
primary-expression before '>' token isIntegral = std::is_integral<T>::value,
^
C:/Qt/5.8/mingw53_32/include/QtCore/qtypeinfo.h:62:41: error: '::value' has
not been declared isIntegral = std::is_integral<T>::value,
NOTE: I also had sprintf() family security error. So I followed Alex's suggestion to add add_definitions(-DSTRSAFE_NO_DEPRECATE) to the beginning of CMakeLists.txt to suppress the error.
Thank you for your time.

Error compiling Boost.Log

I am trying to compile the boost log library and I keep getting this error from the dump_avx2.cpp file
error: always_inline function '_mm256_set1_epi32' requires target feature 'sse4.2', but would be inlined into function 'dump_data_avx2' that is compiled without support for 'sse4.2'
boost/boost/libs/log/src/dump_avx2.cpp:71:31: note: expanded from macro 'BOOST_LOG_AUX_MM_CONSTANTS'
const __m256i mm_char_0 = _mm256_set1_epi32(0x30303030);\
^
I get a lot of errors that are very similar to the one above, all of them have the same error message but different locations in the file where they occur, for reference I am on the commit hash 68701167a1020b0b4c47b76e31d3a3da9e2faf3f for the Boost.Log submodule as fetched from the github repo (https://github.com/boostorg/boost)
Does anyone know how I can go about resolving this issue? I am building with a C++14 compiler and this is what I get when I type g++ --version
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Thanks!
Note I should clarify that in this context it is required that I compile this library separately.
Note There seem to be two related source files dump_ssse3.cpp and the mentioned dump_avx2.cpp file, do I have to compile only one of them? I cannot make out what to do from the Jamfile in the build folder :(
That looks like a bug in clang (LLVM). First, the intrinsic belongs to AVX2, not SSE4.2. Second, the whole dump_avx2.cpp file is compiled with -mavx2, so the required extensions are enabled. You can see the compiler switches in the error message from b2. And no, both dump_ssse3.cpp and dump_avx2.cpp should be compiled. The library does runtime detection of the available instructions in the CPU and selects the proper implementation.

Error: incomplete type when using HMAC_CTX in C++ project

I am trying to compile this library ndn-cxx
in my laptop. I already tried in another computer and it compiled successfully but now i am getting this error and i think its related somhow to openssl. I verify that i have openssl in my laptop using sudo apt-cache search libssl | grep SSL and the result is :
libssl-ocaml - OCaml bindings for OpenSSL (runtime)
libssl-ocaml-dev - OCaml bindings for OpenSSL
libssl0.9.8 - SSL shared libraries
libsslcommon2 - enterprise messaging system - common SSL libraries
libsslcommon2-dev - enterprise messaging system - common SSL development files
The error I am getting when trying to compile the library is :
../src/security/transform/hmac-filter.cpp:49:12: error: field ‘m_context’ has incomplete type
HMAC_CTX m_context;
^
../src/security/transform/hmac-filter.cpp: In constructor
‘ndn::security::transform::HmacFilter::Impl::Impl()’:
../src/security/transform/hmac-filter.cpp:35:20: error: ‘m_context’ was not declared in this scope
HMAC_CTX_init(&m_context);
^
../src/security/transform/hmac-filter.cpp:35:29: error: ‘HMAC_CTX_init’ was not declared in this scope
HMAC_CTX_init(&m_context);
^
../src/security/transform/hmac-filter.cpp: In destructor ‘ndn::security::transform::HmacFilter::Impl::~Impl()’:
../src/security/transform/hmac-filter.cpp:40:23: error: ‘m_context’ was not declared in this scope
HMAC_CTX_cleanup(&m_context);
^
../src/security/transform/hmac-filter.cpp:40:32: error: ‘HMAC_CTX_cleanup’ was not declared in this scope
HMAC_CTX_cleanup(&m_context);
^
../src/security/transform/hmac-filter.cpp: In member function ‘ndn::security::transform::HmacFilter::Impl::operator HMAC_CTX*()’:
../src/security/transform/hmac-filter.cpp:45:13: error: ‘m_context’ was not declared in this scope
return &m_context;
^
../src/security/transform/hmac-filter.cpp:46:3: warning: control reaches end of non-void function [-Wreturn-type]
}
^
The file that causes the compilation error contains the line #if OPENSSL_VERSION_NUMBER < 0x1010000fL and uses the struct HMAC_CTX in that case. For newer versions of OpenSSL (>1.1.0), it uses HMAX_CTX *. My conclusion is that the waf build tool includes the wrong file to get the OPENSSL_VERSION_NUMBER and consequently compiles as if you are using an older version of OpenSSL, with the struct HMAC_CTX, which is no longer available as such in the newer versions.
You could do grep OPENSSL .waf-tools/openssl.py and analyse the printed lines to see where the different OpenSSL includes come from.

PIN tool unknown ABI error

I installed the latest version of PIN from here. And I modified the created a file to trace calls to gets() using a copy of malloctrace.cpp. However, while compiling, I get an error:
In file included from ./include/pin/pin.H:41:0, from
tools/ManualExamples/inputtrace.cpp:32:
./include/pin/compiler_version_check2.H:83:3: error: #error "Unknown
target architecture" # error "Unknown target architecture" ^
./include/pin/compiler_version_check2.H:98:2: error: #error "internal
error pin compiler configuration not available " #error "internal
error pin compiler configuration not available " ^
./include/pin/compiler_version_check2.H:102:2: error: #error The C++
ABI of your compiler does not match the ABI of the pin kit. #error
The C++ ABI of your compiler does not match the ABI of the pin kit.
^ ./include/pin/compiler_version_check2.H:122:2: error: #error Kit has
unknown compiler ABI #error Kit has unknown compiler ABI ^ In file
included from ./include/pin/level_base.PLH:66:0,
from ./include/pin/pin.H:43,
from tools/ManualExamples/inputtrace.cpp:32:
./include/pin/foundation.PLH:25:28: fatal error: types_marker.TLH: No
such file or directory #include "types_marker.TLH"
^
compilation terminated.
I did make sure that the version of PIN I installed was the latest. But the problem persists.
Can someone help me in this regard?
Update: I am using a linux machine x86-64 and the compiler is gcc version 4.8.4
Adding this as an answer since, I do not have the required reputation to make a comment.
Unless you tell us the exact parameters you used for running make, I am afraid a clear and direct answer to your question will not be possible.
This might be a total stab in the dark. But, I ran into a similar problem recently, like you have specified above. I am using an x86_64 Linux system and I was trying to cross-compile my PinTool for ia-32 architecture.
If you do not have 32-bit shared libraries in your system, or if you get the TARGET parameter in make wrong, it would result in
Unknown target architecture
For me running the below command, made it build successfully. Use the following to build for ia32 architecture.
make TARGET=ia32