• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient OTClient error - otclient-master\src\framework\stdext\time.cpp:47:10: help

Diarreamental

Well-Known Member
Joined
Jul 6, 2015
Messages
453
Solutions
1
Reaction score
80
Hello to all

im having issues to compile OTCLIENT in codeblocks, its something thats comes wrong inside sources.
im using clean files

Code:
C:/local/boost_1_64_0_TFS_8.0_REALERA/boost/mpl/assert.hpp:188:21: warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]
 failed ************ (Pred::************
                     ^
C:/local/boost_1_64_0_TFS_8.0_REALERA/boost/mpl/assert.hpp:193:21: warning: unnecessary parentheses in declaration of 'assert_not_arg' [-Wparentheses]
 failed ************ (boost::mpl::not_<Pred>::************
                     ^
[  6%] Building CXX object CMakeFiles/otclient.dir/src/framework/stdext/time.cpp.obj
C:\MinGW\bin\g++.exe  -DBOOST_THREAD_USE_LIB -DBOT_PROTECTION -DCLIENT -DCRASH_HANDLER -DFW_GRAPHICS -DFW_NET -DFW_SOUND -DFW_XML -DWIN32 -D_WIN32_WINNT=0x0501 @CMakeFiles/otclient.dir/includes_CXX.rsp -std=c++11 -Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-unused-result   -pipe -mthreads -O1 -g -fno-omit-frame-pointer   -D"BUILD_TYPE=\"RelWithDebInfo\"" -D"BUILD_COMMIT=\"devel\"" -D"BUILD_REVISION=\"0\"" -D"VERSION=\"0.6.6\"" -o CMakeFiles\otclient.dir\src\framework\stdext\time.cpp.obj -c C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\src\framework\stdext\time.cpp
C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\src\framework\stdext\time.cpp: In function 'void stdext::millisleep(std::size_t)':
C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\src\framework\stdext\time.cpp:47:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::milliseconds(ms));
          ^~~~~~~~~~~
C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\src\framework\stdext\time.cpp: In function 'void stdext::microsleep(std::size_t)':
C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\src\framework\stdext\time.cpp:52:10: error: 'std::this_thread' has not been declared
     std::this_thread::sleep_for(std::chrono::microseconds(us));
          ^~~~~~~~~~~
mingw32-make.exe[2]: *** [CMakeFiles/otclient.dir/src/framework/stdext/time.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/otclient.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\otclient.dir\build.make:164: recipe for target 'CMakeFiles/otclient.dir/src/framework/stdext/time.cpp.obj' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake'
CMakeFiles\Makefile2:75: recipe for target 'CMakeFiles/otclient.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake'
C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake/Makefile:128: recipe for target 'all' failed
Process terminated with status 2 (1 minute(s), 31 second(s))
5 error(s), 20 warning(s) (1 minute(s), 31 second(s))
 
Your MinGW compiler lacks of POSIX threads (std::thread, std::this_thread, and so on).

You have bunch of options to go on with that information, e.g.:


That or perhaps a little hack here:


Change it to something like this:


C++:
/*
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef THREAD_H
#define THREAD_H

#include <boost/thread/future.hpp>

// hack to enable std::thread on mingw32 4.6
#if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__) && !defined(__clang__)

#include <boost/thread/thread.hpp>
#include <boost/chrono.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/condition_variable.hpp>

namespace std {
    using boost::thread;
    using namespace boost::this_thread;
    using namespace boost::chrono;
    using boost::mutex;
    using boost::recursive_mutex;
    using boost::lock_guard;
    using boost::unique_lock;
    using boost::condition_variable;
}

#else

#include <thread>
#include <condition_variable>
#include <mutex>

#endif

#endif

I honestly don't know whether this hack will work because I did not test it.
 
Last edited:
Your MinGW compiler lacks of POSIX threads (std::thread, std::this_thread, and so on).

You have bunch of options to go on with that information, e.g.:


That or perhaps a little hack here:


Change it to something like this:


C++:
/*
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#ifndef THREAD_H
#define THREAD_H

#include <boost/thread/future.hpp>

// hack to enable std::thread on mingw32 4.6
#if !defined(_GLIBCXX_HAS_GTHREADS) && defined(__GNUG__) && !defined(__clang__)

#include <boost/thread/thread.hpp>
#include <boost/chrono.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/condition_variable.hpp>

namespace std {
    using boost::thread;
    using boost::this_thread;
    using boost::chrono;
    using boost::mutex;
    using boost::recursive_mutex;
    using boost::lock_guard;
    using boost::unique_lock;
    using boost::condition_variable;
}

#else

#include <thread>
#include <condition_variable>
#include <mutex>

#endif

#endif

I honestly don't know whether this hack will work because I did not test it.
tested and now i get new erros
Code:
C:/local/boost_1_64_0_TFS_8.0_REALERA/boost/thread/win32/shared_mutex.hpp:53:52: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
             return *reinterpret_cast<T const*>(&res);
                                                    ^
mingw32-make.exe[2]: *** [CMakeFiles/otclient.dir/src/framework/luafunctions.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/otclient.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2
CMakeFiles\otclient.dir\build.make:66: recipe for target 'CMakeFiles/otclient.dir/src/framework/luafunctions.cpp.obj' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake'
CMakeFiles\Makefile2:75: recipe for target 'CMakeFiles/otclient.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake'
C:/Users/diarreamental/OneDrive/Escritorio/otclient-master/CMake/Makefile:128: recipe for target 'all' failed
Process terminated with status 2 (0 minute(s), 22 second(s))
5 error(s), 11 warning(s) (0 minute(s), 22 second(s))
 
I don't see any error descriptions there, but considering the fact it's failing in creating luafunctions.cpp.obj I assume the obj file gets too big (as it usually does with that file). For that you need to pass the following flags to the compiler itself:

Code:
-Wa,-mbig-obj

AFAIR it is required only during compilation and not during linking stage.
 
i changed the thread.h file to your code and enabled the flag
Code:
-Wa,-mbig-obj
into codeblocks settings, compiler, linker settings, other linker options. i still get errors in codeblock
Code:
||=== Build: all in otclient (compiler: GNU GCC Compiler) ===|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\thread_primitives.hpp||In function 'boost::detail::win32::ticks_type (__attribute__((stdcall)) * boost::detail::win32::GetTickCount64_())()':|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\thread_primitives.hpp|315|warning: cast between incompatible function types from 'boost::detail::win32::farproc_t' {aka 'int (__attribute__((stdcall)) *)()'} to 'boost::detail::win32::detail::gettickcount64_t' {aka 'long long unsigned int (__attribute__((stdcall)) *)()'} [-Wcast-function-type]|
c:\users\diarreamental\onedrive\escritorio\otclient-master\src\framework\stdext\thread.h|40|error: namespace 'boost::this_thread' not allowed in using-declaration|
c:\users\diarreamental\onedrive\escritorio\otclient-master\src\framework\stdext\thread.h|41|error: namespace 'boost::chrono' not allowed in using-declaration|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\mpl\assert.hpp|188|warning: unnecessary parentheses in declaration of 'assert_arg' [-Wparentheses]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\mpl\assert.hpp|193|warning: unnecessary parentheses in declaration of 'assert_not_arg' [-Wparentheses]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\asio\detail\impl\win_iocp_socket_service_base.ipp||In member function 'boost::system::error_code boost::asio::detail::win_iocp_socket_service_base::cancel(boost::asio::detail::win_iocp_socket_service_base::base_implementation_type&, boost::system::error_code&)':|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\asio\detail\impl\win_iocp_socket_service_base.ipp|211|warning: cast between incompatible function types from 'FARPROC' {aka 'int (__attribute__((stdcall)) *)()'} to 'cancel_io_ex_t' {aka 'int (__attribute__((stdcall)) *)(void*, _OVERLAPPED*)'} [-Wcast-function-type]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\asio\detail\impl\win_iocp_handle_service.ipp||In member function 'boost::system::error_code boost::asio::detail::win_iocp_handle_service::cancel(boost::asio::detail::win_iocp_handle_service::implementation_type&, boost::system::error_code&)':|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\asio\detail\impl\win_iocp_handle_service.ipp|244|warning: cast between incompatible function types from 'FARPROC' {aka 'int (__attribute__((stdcall)) *)()'} to 'cancel_io_ex_t' {aka 'int (__attribute__((stdcall)) *)(void*, _OVERLAPPED*)'} [-Wcast-function-type]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp||In instantiation of 'T boost::shared_mutex::interlocked_compare_exchange(T*, T, T) [with T = boost::shared_mutex::state_data]':|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp|130|required from here|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp|51|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp|52|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp|53|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
C:\local\boost_1_64_0_TFS_8.0_REALERA\boost\thread\win32\shared_mutex.hpp|53|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
CMakeFiles\otclient.dir\build.make|66|recipe for target 'CMakeFiles/otclient.dir/src/framework/luafunctions.cpp.obj' failed|
CMakeFiles\Makefile2|75|recipe for target 'CMakeFiles/otclient.dir/all' failed|
C:\Users\diarreamental\OneDrive\Escritorio\otclient-master\CMake\Makefile|128|recipe for target 'all' failed|
||=== Build failed: 5 error(s), 11 warning(s) (0 minute(s), 19 second(s)) ===|

2.png
 
Then the issue is still in thread.h, so lets change the following:

C++:
namespace std {
    using boost::thread;
    using boost::this_thread;
    using boost::chrono;
    using boost::mutex;
    using boost::recursive_mutex;
    using boost::lock_guard;
    using boost::unique_lock;
    using boost::condition_variable;
}

to:

C++:
namespace std {
    using boost::thread;
    using namespace boost::this_thread;
    using namespace boost::chrono;
    using boost::mutex;
    using boost::recursive_mutex;
    using boost::lock_guard;
    using boost::unique_lock;
    using boost::condition_variable;
}

Hopefully it should do the trick.

Keep in mind it's an ugly hack altogether. The best idea would be to get rid of MinGW and use something newer or install std::thread within it to make it work properly. You can also rewrite some stuff in time.cpp to use e.g. usleep like it was using in some older commit:

 
Last edited:
i need to use codeblocks because msvc doesnt support long strings that cotains more than 63555 bytes or something like that, i got new errors man.
Code:
C:/local/boost_1_64_0_TFS_8.0_REALERA/boost/thread/win32/shared_mutex.hpp:53:52: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
             return *reinterpret_cast<T const*>(&res);
                                                    ^
mingw32-make.exe[2]: *** [CMakeFiles/otclient.dir/src/framework/luafunctions.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/otclient.dir/all] Error 2
CMakeFiles\otclient.dir\build.make:66: recipe for target 'CMakeFiles/otclient.dir/src/framework/luafunctions.cpp.obj' failed
mingw32-make.exe: *** [all] Error 2
mingw32-make.exe[2]: Leaving directory 'C:/Users/felip/OneDrive/Escritorio/otclient-master/CMake'
CMakeFiles\Makefile2:75: recipe for target 'CMakeFiles/otclient.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/felip/OneDrive/Escritorio/otclient-master/CMake'
C:/Users/felip/OneDrive/Escritorio/otclient-master/CMake/Makefile:128: recipe for target 'all' failed
Process terminated with status 2 (0 minute(s), 14 second(s))
5 error(s), 11 warning(s) (0 minute(s), 14 second(s))
 

Attachments

If using namespace is prohibited then just go back to thread.h from the following link:


And edit the following:


Replace it to use boost directly (you are using boost::thread anyway because of thread.h file which creates hack around MinGW):


C++:
/*
* Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include "time.h"

#include <chrono>
#include <ctime>
#include <thread>

#include <boost/thread/thread.hpp>
#include <boost/chrono.hpp>

namespace stdext {

const static auto startup_time = std::chrono::high_resolution_clock::now();

ticks_t time() {
    return std::time(nullptr);
}

ticks_t millis()
{
    return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
}
ticks_t micros() {
    return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - startup_time).count();
}

void millisleep(size_t ms)
{
    boost::this_thread::sleep_for(boost::chrono::milliseconds(ms));
};

void microsleep(size_t us)
{
    boost::this_thread::sleep_for(boost::chrono::microseconds(us));
};

}

Just poke around with it yourself, the idea is there.
 
Back
Top Bottom