Using Msys2 and MinGW to compile HDF5 but get errors - c++

I tried to compile hdf5 with Msys2 and MinGW64.The compile directive is below:
./configure --enable-cxx --prefix=/d/xxx/xxx
It seems configure does not have any problems.But the make have these problems:
H5PL.c:106:43: error: 'RTLD_LAZY' undeclared (first use in this function)
106 | #define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY | RTLD_LOCAL)
H5PL.c:106:55: error: 'RTLD_LOCAL' undeclared (first use in this function)
106 | #define H5PL_OPEN_DLIB(S) dlopen(S, RTLD_LAZY | RTLD_LOCAL)
I found that the main problems are in the H5PL.c.So I checek the source code.And I found the line 106:
I think the main reason is just like the error message.RTLD_LAZY and RTLD_LOCAL are not decleared.But I do not how to solve this problem.Can anybody help me?

Related

Is there a way to use boost asio library with cygwin 64 bits?

I use Windows 11 64 bits and Cygwin 64 bits.
I need to build a project using boost asio without POSIX libraries. The project is built using Eclipse CDT toolset.
I can't use the POSIX libraries here because of the constraints of the project but in another context, I use this project built with Cygwin using POSIX libraries installed from the Cygwin installer and it works well.
The following defined symbols are used in the command line :
__USE_W32_SOCKETS
_WIN32_WINNT=0x0A00
BOOST_WINDOWS
But it result in many errors :
In file included from /usr/include/boost/asio/detail/win_static_mutex.hpp:71,
from /usr/include/boost/asio/detail/static_mutex.hpp:23,
from /usr/include/boost/asio/detail/win_global.hpp:19,
from /usr/include/boost/asio/detail/global.hpp:23,
from /usr/include/boost/asio/impl/system_executor.hpp:19,
from /usr/include/boost/asio/system_executor.hpp:129,
from /usr/include/boost/asio/associated_executor.hpp:21,
from /usr/include/boost/asio.hpp:21,
from ../src/AsioExample.cpp:10:
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp: In member function 'int boost::asio::detail::win_static_mutex::do_init()':
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:48:3: error: '_snwprintf' was not declared in this scope; did you mean 'vsniprintf'?
48 | _snwprintf(
| ^~~~~~~~~~
| vsniprintf
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected 'catch' before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected '(' before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
| (
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:3: error: expected type-specifier before '__except'
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ^~~~~~~~
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:11: error: expected ')' before '(' token
115 | __except(GetExceptionCode() == STATUS_NO_MEMORY
| ~~~~~~~~^
| )
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:115:11: error: expected '{' before '(' token
/usr/include/boost/asio/detail/impl/win_static_mutex.ipp:116:63: error: expected ';' before '{' token
116 | ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
| ^
| ;
117 | {
| ~
I visited this thread :
how-to-use-boost-asio-library-with-cygwin-64-bit
But the given solution is not what I want to get here.
As the boost asio documentation indicates that we need to add the flag __USE_W32_SOCKETS to build it, I suppose it is possible but I can't find the proper solution. Can someone give some hints to achieve this?
As MSYS2 is a based on modified version of Cygwin, I achieved the build by installing MSYS2 and boost in this context. It works well and seems to be the best way to do that.
Thanks #HolyBlackCat for the reminder that MSYS2 exists.

using libraries with the same defines in one file

I have a project in which I want to use both grpc and ncurses and I stumbled across a strange error
I have a function
grpc::Status test(){
...
return grpc::Status::OK;
}
which works fine without ncurses, however if I add
#include <ncurses.h>
The whole thing breaks with this error
src/main.cc:32:26: error: expected unqualified-id before ‘(’ token
32 | return grpc::Status::OK;
| ^~
make: *** [makefile:34: obj/main.o] Error 1
As it turn out, ncurses also has
#undef OK
#define OK (0)
Is there a way to tackle this problem? Here are my ideas of what could work, but I don't know how to implement them.
namespace mangling
ifndefs
different compilation method
I am compiling my program with:
g++ -lncurses -lprotobuf -lgrpc++ -lgrpc++_reflection
Seems like you can just #undef it.

Boost::process on Windows - with MinGW?

I have a C++17 application using nothing but STL and boost 1.71.0. The application needs to run on Windows, Linux and BSD. On Windows I use GCC 9.2 provided by MinGW-w64. I use the distribution that comes with MSYS2.
I need to have the ability to create a system process (launching an external application from within my C++ application).
In the past I used QProcess of the Qt libraries for this. However, this application doesn't have any Qt dependencies and I'd like to prevent adding Qt dependencies just for this one feature.
Looking for solutions I came across boost::process. On first glance this seems like a very suitable alternative to QProcess.
I started by creating a minimal application using C++17, cmake and boost:
#include <iostream>
#include <boost/process.hpp>
int main() {
int result = boost::process::system("g++ main.cpp");
return 0;
}
Unfortunately, I ran into compilation errors straight away:
====================[ Build | boost_process_test | Debug ]======================
C:\Users\joel\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\193.5233.103\bin\cmake\win\bin\cmake.exe --build C:\Users\joel\Documents\projects\boost_process_test\cmake-build-debug --target boost_process_test -- -j 6
Scanning dependencies of target boost_process_test
[ 50%] Building CXX object CMakeFiles/boost_process_test.dir/main.cpp.obj
In file included from C:/msys64/mingw64/include/boost/process/detail/windows/handles.hpp:11,
from C:/msys64/mingw64/include/boost/process/detail/used_handles.hpp:17,
from C:/msys64/mingw64/include/boost/process/detail/windows/async_in.hpp:20,
from C:/msys64/mingw64/include/boost/process/async.hpp:49,
from C:/msys64/mingw64/include/boost/process.hpp:23,
from C:\Users\joel\Documents\projects\boost_process_test\main.cpp:2:
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:208:51: error: expected ')' before '*' token
208 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_system_query_information_p )(
| ~ ^~
| )
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:223:51: error: expected ')' before '*' token
223 | typedef ::boost::winapi::NTSTATUS_ (__kernel_entry *nt_query_object_p )(
| ~ ^~
| )
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp: In function 'boost::winapi::NTSTATUS_ boost::process::detail::windows::workaround::nt_system_query_information(boost::process::detail::windows::workaround::SYSTEM_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)':
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:239:12: error: 'nt_system_query_information_p' does not name a type; did you mean 'nt_system_query_information'?
239 | static nt_system_query_information_p f = reinterpret_cast<nt_system_query_information_p>(::boost::winapi::get_proc_address(h, "NtQuerySystemInformation"));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| nt_system_query_information
In file included from C:/msys64/mingw64/include/boost/process/detail/windows/handles.hpp:11,
from C:/msys64/mingw64/include/boost/process/detail/used_handles.hpp:17,
from C:/msys64/mingw64/include/boost/process/detail/windows/async_in.hpp:20,
from C:/msys64/mingw64/include/boost/process/async.hpp:49,
from C:/msys64/mingw64/include/boost/process.hpp:23,
from C:\Users\joel\Documents\projects\boost_process_test\main.cpp:2:
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:241:14: error: 'f' was not declared in this scope
241 | return (*f)(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength);
| ^
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp: In function 'boost::winapi::BOOL_ boost::process::detail::windows::workaround::nt_query_object(boost::winapi::HANDLE_, boost::process::detail::windows::workaround::OBJECT_INFORMATION_CLASS_, void*, boost::winapi::ULONG_, boost::winapi::PULONG_)':
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:253:12: error: 'nt_query_object_p' does not name a type; did you mean 'nt_query_object'?
253 | static nt_query_object_p f = reinterpret_cast<nt_query_object_p>(::boost::winapi::get_proc_address(h, "NtQueryObject"));
| ^~~~~~~~~~~~~~~~~
| nt_query_object
C:/msys64/mingw64/include/boost/process/detail/windows/handle_workaround.hpp:255:14: error: 'f' was not declared in this scope
255 | return (*f)(Handle, ObjectInformationClass, ObjectInformation, ObjectInformationLength, ReturnLength);
| ^
mingw32-make.exe[3]: *** [CMakeFiles\boost_process_test.dir\build.make:62: CMakeFiles/boost_process_test.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/boost_process_test.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/boost_process_test.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: boost_process_test] Error 2
Here is my corresponding CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(boost_process_test)
set(CMAKE_CXX_STANDARD 17)
find_package(Boost 1.71.0 REQUIRED)
add_executable(boost_process_test main.cpp)
I consulted the boost.process documentation to figure out what kind of dependencies & compatibilities there are. Unfortunately, I couldn't find much info on this.
Before I start getting too deep into actually debugging this - Does somebody know whether boost.process as of version 1.71.0 actually runs on Windows and if so - whether it works with GCC / MinGW and not just MSVC? And if MinGW/GCC is supported - does it rely on posix or win32api?
Solution
I've come across this github issue on the boost::process repository where the OP mentions the same issue. It appears to be a MinGW issue. A workaround was presented in the issue which involves defining the __kernel_entry pre-processor symbol before including the boost/process.hpp header.
Applying this to my code looks like this:
// Workaround for a boost/mingw bug.
// This must occur before the inclusion of the boost/process.hpp header.
// Taken from https://github.com/boostorg/process/issues/96
#ifndef __kernel_entry
#define __kernel_entry
#endif
#include <boost/process.hpp>
int main() {
int result = boost::process::system("g++ main.cpp");
return 0;
}
This made the compilation error(s) go away and resulted in correctly working program binary.
Further steps
After applying the fix the initial compiler error shown in the question didn't appear anymore. However, the program still didn't compile & link properly as I didn't include the boost libraries correctly.
My CMakeLists.txt for the working example looks like this:
cmake_minimum_required(VERSION 3.15)
project(boost_process_test)
set(CMAKE_CXX_STANDARD 17)
find_package(Boost 1.71.0 REQUIRED
COMPONENTS
filesystem
system
)
add_executable(boost_process_test main.cpp)
target_link_libraries(boost_process_test
PRIVATE
$<$<BOOL:${WIN32}>:ws2_32>
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
)
Note the linking towards the ws2_32 library on Windows platforms.
Credits
Thank you # mrjj from the Qt community for pointing me towards the github issue that helped me solving this compilation issue.

build boost for gcc using cygwin on Windows 7 - bootstrap error

I downloaded boost and am doing this
admin#US01WKS03044 /cygdrive/c/Users/admin/Downloads/boost_1_49_0
$ ./bootstrap.bat gcc
Building Boost.Build engine
filent.c:35:21: fatal error: direct.h: No such file or directory
# include <direct.h>
^
compilation terminated.
jam.c: In function ‘main’:
jam.c:181:25: error: ‘environ’ undeclared (first use in this function)
#define use_environ environ
^
jam.c:417:22: note: in expansion of macro ‘use_environ’
var_defines( use_environ, 1 );
^
jam.c:181:25: note: each undeclared identifier is reported only once for each function it appears in
#define use_environ environ
^
jam.c:417:22: note: in expansion of macro ‘use_environ’
var_defines( use_environ, 1 );
^
jam.c: In function ‘executable_path’:
jam.c:628:18: warning: comparison between pointer and integer
if (argv0[0] == "/")
^
pathunix.c:276:19: fatal error: tchar.h: No such file or directory
#include <tchar.h>
^
compilation terminated.
builtins.c:39:0: warning: "WIFEXITED" redefined
# define WIFEXITED(w) (((w) & 0XFFFFFF00) == 0)
^
In file included from /usr/include/cygwin/stdlib.h:14:0,
from /usr/include/stdlib.h:25,
from jam.h:89,
from builtins.c:7:
/usr/include/cygwin/wait.h:34:0: note: this is the location of the previous definition
#define WIFEXITED(w) ((__wait_status_to_int(w) & 0xff) == 0)
^
builtins.c:40:0: warning: "WEXITSTATUS" redefined
# define WEXITSTATUS(w)(w)
^
In file included from /usr/include/cygwin/stdlib.h:14:0,
from /usr/include/stdlib.h:25,
from jam.h:89,
from builtins.c:7:
/usr/include/cygwin/wait.h:39:0: note: this is the location of the previous definition
#define WEXITSTATUS(w) ((__wait_status_to_int(w) >> 8) & 0xff)
^
Failed to build Boost.Build engine.
Please consult bootstrap.log for furter diagnostics.
You can try to obtain a prebuilt binary from
http://sf.net/project/showfiles.php?group_id=7586&package_id=72941
Also, you can file an issue at http://svn.boost.org
Please attach bootstrap.log in that case.
Any suggestions on why I might be getting this error ?
The file bootstrap.bat is for building Boost from the Windows command prompt in order to create a native Windows version of Boost. If you want to build a Cygwin version of Boost from the Cygwin shell you should follow the instructions for building Boost on Unix-type systems.
Or as this message at the top of Boost's Getting Started on Windows page says:
A note to Cygwin and MinGW users
If you plan to use your tools from the Windows command prompt, you're in the
right place. If you plan to build from the Cygwin bash shell, you're actually
running on a POSIX platform and should follow the instructions for
getting started on Unix variants.

Apportable build errors when trying to convert a project created by SpriteBuilder

I created a New Project in SpriteBuilder and am trying to convert it to Android using Apportable.
When I run $ apportable build I am now getting many error: use of undeclared identifier errors related to CCLabelTTF.m. Here are three of them as examples:
/Users/name/Documents/TestApp/Source/libs/cocos2d-iphone/cocos2d/CCLabelTTF.m:350:50: error: use of undeclared
identifier 'NSForegroundColorAttributeName'; did you mean 'kCTForegroundColorAttributeName'?
if (![formattedAttributedString hasAttribute:NSForegroundColorAttributeName])
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kCTForegroundColorAttributeName
/Users/name/Documents/TestApp/Source/libs/cocos2d-iphone/cocos2d/CCLabelTTF.m:372:50: error: use of undeclared
identifier 'NSFontAttributeName'; did you mean 'kCTFontAttributeName'?
if (![formattedAttributedString hasAttribute:NSFontAttributeName])
^~~~~~~~~~~~~~~~~~~
kCTFontAttributeName
Compiling /Users/name/Documents/TestApp/Source/libs/cocos2d-iphone/cocos2d/CCParticleSystem.m
/Users/name/Documents/TestApp/Source/libs/cocos2d-iphone/cocos2d/CCLabelTTF.m:380:49: error: use of undeclared
identifier 'NSShadowAttributeName'
if ([formattedAttributedString hasAttribute:NSShadowAttributeName])
^
Any suggestions how to proceed?
I'm using
Xcode 5.0.2
Apportable release_1.0.30
SpriteBuilder 0.9.alpha.
The current version of Apportable does not have full support for NSAttributedString. That will be available in our new UIKit implementation, which we will release as soon as it is sufficiently complete.