MinGW windows compile:'lock_guard' is not a member of 'std'

MinGW windows compile:'lock_guard' is not a member of 'std'

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

MinGW windows compile:'lock_guard' is not a member of 'std'

Post by Beherith »

Code: Select all

D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp: In static member function 'static void CLuaGaia::LoadHandler()':
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:45:3: error: 'lock_guard' is not a member of 'std'
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:45:31: error: expected primary-expression before '>' token
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:45:47: error: 'lk' was not declared in this scope
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp: In static member function 'static void CLuaGaia::FreeHandler()':
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:59:2: error: 'lock_guard' is not a member of 'std'
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:59:30: error: expected primary-expression before '>' token
D:\spring\source\develop\spring\rts\Lua\LuaGaia.cpp:59:46: error: 'lk' was not declared in this scope
rts\builds\legacy\CMakeFiles\engine-legacy.dir\build.make:2097: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Lua/LuaGaia.cpp.obj' failed
mingw32-make[3]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Lua/LuaGaia.cpp.obj] Error 1
Any tips?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by jK »

try wingw64
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

With 64 bit mingw, I get the following error:

Code: Select all

[ 40%] Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Lua/LuaOpenGL.cpp.obj
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp: In static member function 'static int LuaOpenGL::DeleteQuery(lua_State*)':
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp:4277:50: error: cast from'const void*' to 'long unsigned int' loses precision [-fpermissive]
  GLuint q = (unsigned long int)lua_topointer(L, 1);
                                                  ^
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp: In static member function 'static int LuaOpenGL::RunQuery(lua_State*)':
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp:4296:50: error: cast from'const void*' to 'long unsigned int' loses precision [-fpermissive]
  GLuint q = (unsigned long int)lua_topointer(L, 1);
                                                  ^
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp: In static member function 'static int LuaOpenGL::GetQuery(lua_State*)':
D:\spring\source\develop\spring\rts\Lua\LuaOpenGL.cpp:4326:50: error: cast from'const void*' to 'long unsigned int' loses precision [-fpermissive]
  GLuint q = (unsigned long int)lua_topointer(L, 1);
                                                  ^
rts\builds\legacy\CMakeFiles\engine-legacy.dir\build.make:2337: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Lua/LuaOpenGL.cpp.obj' failed
mingw32-make[3]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Lua/LuaOpenGL.cpp.obj] Error 1
CMakeFiles\Makefile2:2270: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/all' failed
mingw32-make[2]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/all] Error2
CMakeFiles\Makefile2:2282: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule' failed
mingw32-make[1]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule] Error 2Makefile:640: recipe for target 'engine-legacy' failed
mingw32-make: *** [engine-legacy] Error 2
cleanrock
Former Engine Dev
Posts: 115
Joined: 21 Feb 2009, 07:42

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by cleanrock »

Your gcc seem to be very strict by default.
Add -fpermissive:
CUSTOM_FLAGS=ON
CMAKE_CXX_FLAGS=-fpermissive

This is the "bad" commit:
https://github.com/spring/spring/commit/cbb8d8e
I dont think changing it to lua_tointeger will help since i think it returns a ptrdiff_t.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

Thanks cleanrock! Added -fpermissive

Code: Select all

[ 55%] Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Map/SMF/SMFGroundTextures.cpp.obj
In file included from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_primitives.hpp:17:0,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/basic_recursive_mutex.hpp:13,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/recursive_mutex.hpp:13,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/recursive_mutex.hpp:14,
                 from S:/spring_develop_2014/spring/rts/Game/LoadScreen.h:7,
                 from S:\spring_develop_2014\spring\rts\Map\ReadMap.cpp:12:
S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_data.hpp: In function 'void boost::detail::intrusive_ptr_add_ref(boost::detail::t
hread_data_base*)':
S:/spring_develop_2014/spring/mingwlibs/include/boost/detail/interlocked.hpp:158:38: error: '_InterlockedIncrement' is not a member of 'boost::detail'
 # define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
                                      ^
S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_data.hpp:130:17: note: in expansion of macro 'BOOST_INTERLOCKED_INCREMENT'
                 BOOST_INTERLOCKED_INCREMENT(&p->count);
                 ^
S:/spring_develop_2014/spring/mingwlibs/include/boost/detail/interlocked.hpp:158:38: note: suggested alternative:
 # define BOOST_INTERLOCKED_INCREMENT ::boost::detail::InterlockedIncrement
                                      ^
S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_data.hpp:130:17: note: in expansion of macro 'BOOST_INTERLOCKED_INCREMENT'
                 BOOST_INTERLOCKED_INCREMENT(&p->count);
                 ^
In file included from c:\tdm-gcc-64\x86_64-w64-mingw32\include\winnt.h:26:0,
                 from c:\tdm-gcc-64\x86_64-w64-mingw32\include\minwindef.h:146,
                 from c:\tdm-gcc-64\x86_64-w64-mingw32\include\windef.h:8,
                 from c:\tdm-gcc-64\x86_64-w64-mingw32\include\windows.h:69,
                 from S:/spring_develop_2014/spring/rts/System/Platform/Win/win32.h:23,
                 from S:/spring_develop_2014/spring/rts/System/OffscreenGLContext.h:11,
                 from S:/spring_develop_2014/spring/rts/Game/LoadScreen.h:11,
                 from S:\spring_develop_2014\spring\rts\Map\ReadMap.cpp:12:
c:\tdm-gcc-64\x86_64-w64-mingw32\include\psdk_inc\intrin-impl.h:978:10: note:   '_InterlockedIncrement'
 __LONG32 _InterlockedIncrement(__LONG32 volatile *Addend) {
          ^
In file included from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_primitives.hpp:17:0,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/basic_recursive_mutex.hpp:13,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/recursive_mutex.hpp:13,
                 from S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/recursive_mutex.hpp:14,
                 from S:/spring_develop_2014/spring/rts/Game/LoadScreen.h:7,
                 from S:\spring_develop_2014\spring\rts\Map\ReadMap.cpp:12:
S:/spring_develop_2014/spring/mingwlibs/include/boost/thread/win32/thread_data.hpp: In function 'void boost::detail::intrusive_ptr_release(boost::detail::t
hread_data_base*)':
S:/spring_develop_2014/spring/mingwlibs/include/boost/detail/interlocked.hpp:159:38: error: '_InterlockedDecrement' is not a member of 'boost::detail'
 # define BOOST_INTERLOCKED_DECREMENT ::boost::detail::InterlockedDecrement
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by PicassoCT »

http://paste.springfiles.com/view/973fdea3

How to resolve packages dependancy problems?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

My previous error can be fixed with this patch:

The next error is the following:

Code: Select all

[ 39%] [ 39%] [ 39%] Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp.obj

Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Units/BuildInfo.cpp.obj
Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Units/CommandAI/AirCAI.cpp.obj
[ 39%] Building CXX object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Units/CommandAI/BuilderCAI.cpp.obj
In file included from S:/spring_develop_2014/spring/rts/System/creg/creg.h:336:0,
                 from S:/spring_develop_2014/spring/rts/System/creg/creg_cond.h:16,
                 from S:/spring_develop_2014/spring/rts/System/Object.h:10,
                 from S:/spring_develop_2014/spring/rts/Sim/Objects/WorldObject.h:6,
                 from S:/spring_develop_2014/spring/rts/Sim/Projectiles/ExplosionGenerator.h:11,
                 from S:/spring_develop_2014/spring/rts/Sim/Projectiles/Projectile.h:12,
                 from S:\spring_develop_2014\spring\rts\Sim\Projectiles\WeaponProjectiles\WeaponProjectile.h:6,
                 from S:\spring_develop_2014\spring\rts\Sim\Projectiles\WeaponProjectiles\StarburstProjectile.h:6,
                 from S:\spring_develop_2014\spring\rts\Sim\Projectiles\WeaponProjectiles\StarburstProjectile.cpp:4:
S:/spring_develop_2014/spring/rts/System/creg/TypeDeduction.h: In instantiation of 'boost::shared_ptr<creg::IType> creg::DeduceType<T>::Get() [with T = lon
g long unsigned int]':
S:/spring_develop_2014/spring/rts/System/creg/TypeDeduction.h:126:20:   required from 'boost::shared_ptr<creg::IType> creg::GetType(T&) [with T = long long
 unsigned int]'
S:\spring_develop_2014\spring\rts\Sim\Projectiles\WeaponProjectiles\StarburstProjectile.cpp:30:1:   required from here
S:/spring_develop_2014/spring/rts/System/creg/TypeDeduction.h:20:111: error: 'StaticClass' is not a member of 'long long unsigned int'
  boost::shared_ptr<IType> Get() { return boost::shared_ptr<IType>(IType::CreateObjInstanceType(T::StaticClass())); }
                                                                                                               ^
rts\builds\legacy\CMakeFiles\engine-legacy.dir\build.make:7857: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Projectiles/Wea
ponProjectiles/StarburstProjectile.cpp.obj' failed
mingw32-make[3]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp.obj] Error 1
mingw32-make[3]: *** Waiting for unfinished jobs....
CMakeFiles\Makefile2:2742: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/all' failed
mingw32-make[2]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/all] Error 2
CMakeFiles\Makefile2:2754: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule' failed
mingw32-make[1]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule] Error 2
Makefile:822: recipe for target 'engine-legacy' failed
mingw32-make: *** [engine-legacy] Error 2
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

Got it to compile all the way, with the -m32 for C and CXX flags to force 32 bit mode. But the linker is screwing up. How can I pass -m32 or -F pe-i386 to the linker from the CMakeLists.txt?

Code: Select all

[100%] Building RC object rts/builds/legacy/CMakeFiles/engine-legacy.dir/__/__/icon.rc.obj
Linking CXX executable ..\..\..\spring.exe
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: i386:x86-64 architecture of input file `CMakeFiles\engine-legacy.dir/objects.a(icon.rc.obj)' is incompatible with i386 output
collect2.exe: error: ld returned 1 exit status
rts\builds\legacy\CMakeFiles\engine-legacy.dir\build.make:12933: recipe for target 'spring.exe' failed
mingw32-make[3]: *** [spring.exe] Error 1
Error with ming32-make engine-legacy VERBOSE=1:
http://pastebin.com/gzAdBkNw
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by abma »

http://stackoverflow.com/questions/6077 ... elists-txt

but it looks like the icon.rc file is wrong, maybe just comment it out in rts/CMakeLists.txt. not sure if ldflags are wrong, possible windres flags are.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

Thanks for all the help abma and jK!
I got spring to compile with TDM-GCC-64 4.8.1 installed with the default options from the TDM GCC web dowloader (http://tdm-gcc.tdragon.net/download)

But there are some configuration issues:
It requires CUSTOM_CFLAGS, and for some reason, I cant set CMAKE_CXX_FLAGS or CMAKE_C_FLAGS from the cmake-gui (I add the entries in the GUI but they get deleted on 'configure'.

I have edited the CMakelists.txt to set them to:

Code: Select all

set(CMAKE_CXX_FLAGS " -fpermissive -m32")
set(CMAKE_C_FLAGS " -m32")
Also, the reference to icons.rc has to be commented out from spring\rts\builds\CMakeLists.txt:#83

Code: Select all

#SET(ENGINE_ICON "${ENGINE_SRC_ROOT_DIR}/icon.rc")
Could you please update these in the GIT repo?

silentwings also got it compile with these settings. We are both on windows 7 x64.

The make command remains mingw32-make engine-legacy

I also got the visual studio 2012 project file creation from cmake working (useful for editing, does not compile) by adding SDL2 2.0.2 from http://libsdl.org/release/SDL2-devel-2.0.2-VC.zip to vclibs/SDL2 and by setting the CMAKE variable SDL2_LIBRARY to "[mypath]\spring\vclibs\SDL2\lib\x86"
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by jK »

Seems you missed what I told you in chat.
2014-03-10 16:22:19: [teh]Beherith[PiRO]: Thanks for all your help so far! Compiled 100% with 64bit TDM-GCC forced to 32-bit with -m32, but I cant get the linker to work as 32bit: http$
2014-03-10 17:35:06: [teh]Beherith[PiRO] joined The BlackHoleHost - Revenge
2014-03-10 17:51:43: you are still using a wrong compile path it seems
2014-03-10 17:51:45: http://xcodelovers.wordpress.com/2011/0 ... c-windows/
2014-03-10 17:52:03: tells me you can use tdm32 installer to install mingw64
2014-03-10 17:52:22: which likely differs from tdm64 mingw64
2014-03-10 17:52:38: so you likely used wrong tdm installer
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Beherith »

I am using that installer you linked, with the second option ticked:
http://xcodelovers.files.wordpress.com/ ... dition.jpg
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by PicassoCT »

Has this been resolved?

Im thinking about trying to compile spring on windows and then copy my dev-folder from the ubuntu-partition (which i allmost never use to be honest).
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: MinGW windows compile:'lock_guard' is not a member of 's

Post by Silentwings »

Yes - pm either myself or Behe in chat, building Spring on windows is actually not that hard anymore. It just needs a couple of manual changes to the cmake lists. You can even use cmake to generate code::blocks project files and then codeblocks can load up spring and build for you.
Post Reply

Return to “Engine”