VS2012 compiling issues

VS2012 compiling issues

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

VS2012 compiling issues

Post by Beherith »

I am trying to compile latest develop branch in visual studio 2012 with the wiki instructions, but there are a few errors thrown that I cannot solve:
In Threadpool.h:

Code: Select all

namespace ThreadPool {
	template<class F, class... Args>  //ERROR POINTS HERE!!
	static auto enqueue(F&& f, Args&&... args)
	-> std::shared_ptr<boost::unique_future<typename std::result_of<F(Args...)>::type>>;

	void PushTaskGroup(std::shared_ptr<ITaskGroup> taskgroup);
	void WaitForFinished(std::shared_ptr<ITaskGroup> taskgroup);

	template<typename T>
	inline void PushTaskGroup(std::shared_ptr<T> taskgroup) { PushTaskGroup(std::static_pointer_cast<ITaskGroup>(taskgroup)); }
	template<typename T>
	inline void WaitForFinished(std::shared_ptr<T> taskgroup) { WaitForFinished(std::static_pointer_cast<ITaskGroup>(taskgroup)); }

	void SetThreadCount(int num);
	int GetThreadNum();
	int GetMaxThreads();
	int GetNumThreads();
	void NotifyWorkerThreads();
};
Error:

Code: Select all

8>S:/spring_develop_2013_aug/spring/rts\System/ThreadPool.h(92): error C2332: 'class' : missing tag name (..\..\Map\SMF\SMFGroundTextures.cpp)
A googling of the error says that there is probably a macro defined somewhere for F. But I see no such macro.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: VS2012 compiling issues

Post by jK »

Microsoft likes to define such crap macros esp. in system headers ....
Try to #undefine them.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Unfortunately, #undef F does not help either :(

Can I provide any more information?
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: VS2012 compiling issues

Post by very_bad_soldier »

There is an option to make VS dump the source code after the preprocessor stage. So you will see what the preproc made out of it. Maybe that brings you a step forward. But beware, that output can get quite huge.
If it even is preprocessor related...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: VS2012 compiling issues

Post by jK »

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

Re: VS2012 compiling issues

Post by Beherith »

Thanks jK, you are a god!

Now there is one last issue, but it seems I might have to wait a bit on this one:


in Threadpool.cpp

Code: Select all

static __thread int threadnum(0); //FIXME __thread is gcc only, thread_local is c++11 but doesn't work in <4.8, and is also slower

Code: Select all

8>..\..\System\ThreadPool.cpp(27): error C2144: syntax error : 'int' should be preceded by ';'
But I understand if this takes more effort.
Thank you!
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: VS2012 compiling issues

Post by abma »

@Beherith:

if you just want to get it compile, fetch current develop branch and set

Code: Select all

THREADPOOL:BOOL=OFF
in CMakeCache.txt. thats just a workaround atm & disables most of threading on windows, but should work...

maybe also see http://springrts.com/mantis/view.php?id=3925 for updates on the "threadpool" / buildsetup problems.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Thanks, with threadpool ON

Code: Select all

S:\spring_develop_2013_aug\spring>cmake -G "Visual Studio 11" .
-- The C compiler identification is MSVC 17.0.50727.1
-- The CXX compiler identification is MSVC 17.0.50727.1
-- Check for working C compiler using: Visual Studio 11
-- Check for working C compiler using: Visual Studio 11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11
-- Check for working CXX compiler using: Visual Studio 11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.52.0
-- Found the following Boost libraries:
--   thread
--   regex
--   program_options
--   system
--   chrono
--   signals
--   filesystem
-- Could NOT find Boost
-- Looking for include file pthread.h
-- Looking for include file pthread.h - not found
-- Found Threads: TRUE
-- Found SDL: S:/spring_develop_2013_aug/spring/vclibs/SDL/lib/SDLmain.lib;S:/sp
ring_develop_2013_aug/spring/vclibs/SDL/lib/SDL.lib (found version "1.2.14")
-- Found DevIL: S:/spring_develop_2013_aug/spring/vclibs/DevIL/include/IL/il.h

-- Found DevIL-ILU: S:/spring_develop_2013_aug/spring/vclibs/DevIL/lib/ILU.lib -
 S:/spring_develop_2013_aug/spring/vclibs/DevIL/include/IL/ilu.h
-- Found DevIL-ILUT: S:/spring_develop_2013_aug/spring/vclibs/DevIL/lib/ILUT.lib
 - S:/spring_develop_2013_aug/spring/vclibs/DevIL/include/IL/ilut.h
-- Found win32 libraries: dbghelp;imagehlp;ws2_32;winmm
-- Building Spring for 32bit environment
-- Compiling with C++11
-- Found GIT: C:/Program Files (x86)/Git/cmd/git.cmd
-- Found GLEW: S:/spring_develop_2013_aug/spring/vclibs/glew/include (Required i
s at least version "1.5.1")
-- Found ZLIB: S:/spring_develop_2013_aug/spring/vclibs/zlib/lib/zlib.lib
-- Building Assimp with flags  /DWINDOWS /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd40
18 /wd4800 /wd4305 /DWIN32 /D_WINDOWS /W3 /EHa /GR
-- Found AWK: S:/spring_develop_2013_aug/spring/vclibs/bin/awk.exe
-- Found AI Wrapper: CUtils (sources only wrapper)
-- Found AI Interface: C-AIInterface 0.1
-- Found Java: C:/Program Files (x86)/Java/jdk1.6.0_29/bin/java.exe (found versi
on "1.6.0.29")
-- Found Java: C:/Program Files (x86)/Java/jdk1.6.0_29/bin/java.exe
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_
PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
CMake Warning at AI/Interfaces/Java/CMakeLists.txt:337 (Message):
  No Java includes found!


warning: Java AI Interface will not be built!
-- Found AI Wrapper: Cpp-AIWrapper
warning: Java OO AI Wrapper will not be built!
-- Found AI Wrapper: LegacyCpp-AIWrapper
-- Found AI Wrapper: LegacyCpp-Creg-AIWrapper
-- Found Skirmish AI: AAI 0.9
-- Found Skirmish AI: CppTestAI 0.1
-- Found Skirmish AI: NullAI 0.1
warning: NullJavaAI Skirmish AI will not be built!
warning: NullOOJavaAI Skirmish AI will not be built!
-- Found Skirmish AI: RAI 0.601
-- Found SevenZip: C:/Program Files/7-Zip/7z.exe
-- Found OpenAL: S:/spring_develop_2013_aug/spring/vclibs/OpenAL/libs/OpenAL32.l
ib
-- Looking for vorbis_bitrate_addblock in vorbis
-- Looking for vorbis_bitrate_addblock in vorbis - not found
-- Found OggVorbis: S:/spring_develop_2013_aug/spring/vclibs/ogg_vorbis/lib/ogg.
lib;S:/spring_develop_2013_aug/spring/vclibs/ogg_vorbis/lib/vorbis.lib;S:/spring
_develop_2013_aug/spring/vclibs/ogg_vorbis/lib/vorbisfile.lib
-- Found OpenGL: opengl32
-- Found Freetype: S:/spring_develop_2013_aug/spring/vclibs/freetype/lib/freetyp
e.lib (found version "2.4.11")
-- Using legacy as default engine
-- Boost version: 1.52.0
-- Found the following Boost libraries:
--   unit_test_framework
CMake Error at test/CMakeLists.txt:50 (target_link_libraries):
  The "optimized" argument must be followed by a library.
Call Stack (most recent call first):
  test/CMakeLists.txt:138 (add_spring_test)


-- Configuring incomplete, errors occurred!

S:\spring_develop_2013_aug\spring>
Threadpool OFF:

Code: Select all

S:\spring_develop_2013_aug\spring>cmake -G "Visual Studio 11" .
-- Boost version: 1.52.0
-- Found the following Boost libraries:
--   thread
--   regex
--   program_options
--   system
--   chrono
--   signals
--   filesystem
-- Could NOT find Boost
-- Found win32 libraries: dbghelp;imagehlp;ws2_32;winmm
-- Building Spring for 32bit environment
-- Compiling with C++11
-- Building Assimp with flags  /DWINDOWS /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd40
18 /wd4800 /wd4305 /DWIN32 /D_WINDOWS /W3 /EHa /GR
-- Found AI Wrapper: CUtils (sources only wrapper)
-- Found AI Interface: C-AIInterface 0.1
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_
PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
CMake Warning at AI/Interfaces/Java/CMakeLists.txt:337 (Message):
  No Java includes found!


warning: Java AI Interface will not be built!
-- Found AI Wrapper: Cpp-AIWrapper
warning: Java OO AI Wrapper will not be built!
-- Found AI Wrapper: LegacyCpp-AIWrapper
-- Found AI Wrapper: LegacyCpp-Creg-AIWrapper
-- Found Skirmish AI: AAI 0.9
-- Found Skirmish AI: CppTestAI 0.1
-- Found Skirmish AI: NullAI 0.1
warning: NullJavaAI Skirmish AI will not be built!
warning: NullOOJavaAI Skirmish AI will not be built!
-- Found Skirmish AI: RAI 0.601
-- S:/spring_develop_2013_aug/spring/springsettings.cfg already exists!
-- Using legacy as default engine
-- Boost version: 1.52.0
-- Found the following Boost libraries:
--   unit_test_framework
CMake Error at test/CMakeLists.txt:50 (target_link_libraries):
  The "optimized" argument must be followed by a library.
Call Stack (most recent call first):
  test/CMakeLists.txt:138 (add_spring_test)


-- Configuring incomplete, errors occurred!

S:\spring_develop_2013_aug\spring>
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: VS2012 compiling issues

Post by abma »

Beherith wrote: test/CMakeLists.txt:138 (add_spring_test)
oops, thanks for reporting!
fixed: https://github.com/spring/spring/commit ... 87e24f271c

please try again with the fix...
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Abma, thank you so much for your help, spring finally compiles for me!

There was only one minor bug:

Code: Select all

8>..\..\Game\UI\SelectionKeyHandler.cpp(198): error C3861: 'strtof': identifier not found
Which I commented out for now, as I dont need it for testing.

much love!
velteyn
Posts: 40
Joined: 25 Jan 2012, 10:53

Re: VS2012 compiling issues

Post by velteyn »

I have SUPER MANY problems too

I'm using latest develop branch
Visual Studio 2012 update 3

I followed carefully all the wiki instructions than I had
this : http://www.heypasteit.com/clip/10A4

Is there someone can help me ??

Please please please :lol:
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Try to grab the develop branch as it was in 2013 august 12, as that worked for me.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Trying to compile 95 with VS2012 throws a lot of linker errors:

Code: Select all

20>FreeController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMicroSecs<__int64>(__int64)" (??$ToMicroSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>FreeController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMilliSecs<__int64>(__int64)" (??$ToMilliSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>FreeController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToSecs<__int64>(__int64)" (??$ToSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverheadController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMicroSecs<__int64>(__int64)" (??$ToMicroSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverheadController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMilliSecs<__int64>(__int64)" (??$ToMilliSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverheadController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToSecs<__int64>(__int64)" (??$ToSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverviewController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMicroSecs<__int64>(__int64)" (??$ToMicroSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverviewController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToMilliSecs<__int64>(__int64)" (??$ToMilliSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
20>OverviewController.obj : error LNK2005: "__int64 __cdecl spring_clock::ToSecs<__int64>(__int64)" (??$ToSecs@_J@spring_clock@@YA_J_J@Z) already defined in Camera.obj
Any ideas on how to solve?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: VS2012 compiling issues

Post by Kloot »

Code: Select all

diff --git a/rts/System/Misc/SpringTime.h b/rts/System/Misc/SpringTime.h
index 5b5abaa..6db8463 100644
--- a/rts/System/Misc/SpringTime.h
+++ b/rts/System/Misc/SpringTime.h
@@ -42,9 +42,9 @@ namespace spring_clock {
        template<typename T> static T ToNanoSecs (const boost::int64_t ns) { return (ns       ); }
 
        // specializations
-       template<> boost::int64_t ToSecs     <boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e9)); }
-       template<> boost::int64_t ToMilliSecs<boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e6)); }
-       template<> boost::int64_t ToMicroSecs<boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e3)); }
+       template<> static boost::int64_t ToSecs     <boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e9)); }
+       template<> static boost::int64_t ToMilliSecs<boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e6)); }
+       template<> static boost::int64_t ToMicroSecs<boost::int64_t>(const boost::int64_t ns) { return (ns / boost::int64_t(1e3)); }
 
        template<typename T> static boost::int64_t FromSecs     (const T  s) { return ( s * boost::int64_t(1e9)); }
        template<typename T> static boost::int64_t FromMilliSecs(const T ms) { return (ms * boost::int64_t(1e6)); }
Unsurprisingly this breaks compilation with gcc so we can't push it upstream.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

Thanks, but there are a few more:

Code: Select all

12>LuaOpenGL.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>SMFGroundDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>SMFRenderState.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>AdvTreeDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>AdvTreeGenerator.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>BumpWater.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>GrassDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>GroundDecalHandler.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>DecalsDrawerGL4.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>FeatureDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>LightHandler.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>ModelDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>ProjectileDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>GLSLCopyState.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>Shader.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>ShaderHandler.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>ShadowHandler.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>UnitDrawer.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>UnitDrawerState.obj : error LNK2005: "unsigned int __cdecl hashString(char const *,unsigned int)" (?hashString@@YAIPBDI@Z) already defined in UnsyncedGameCommands.obj
12>     Creating library S:/spring_95_source/spring/rts/builds/legacy/Release/spring.lib and object S:/spring_95_source/spring/rts/builds/legacy/Release/spring.exp
12>S:\spring_95_source\spring\Release\spring.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 11 succeeded, 1 failed, 8 up-to-date, 0 skipped ==========
NOTE: I had to remove the constexpr qualifier from hashString as msvc does not support it.

EDIT: changing constexpr to static got me a successful compile. Thanks!
User avatar
REVENGE
Posts: 2382
Joined: 24 Aug 2006, 06:13

Re: VS2012 compiling issues

Post by REVENGE »

Delete this if you think it's offtopic, but why not edit using Visual Studio and compile using mingw32?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: VS2012 compiling issues

Post by Beherith »

in this case it was actually better to test with an msvc build.
Post Reply

Return to “Engine”