Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
42PercentHealth

Can't Compile GZDoom

Recommended Posts

Hi all,

 

Trying to build GZDoom on Linux (Fedora 20 -- I know it's outdated... Don't judge me), and I get the following error:

 

[ 58%] Building CXX object src/CMakeFiles/zdoom.dir/gl/shaders/gl_ambientshader.cpp.o
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp: In member function ‘void FLinearDepthShader::Bind()’:
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:42:13: error: ‘make_unique’ is not a member of ‘std’
   mShader = std::make_unique<FShaderProgram>();
             ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:42:44: error: expected primary-expression before ‘>’ token
   mShader = std::make_unique<FShaderProgram>();
                                            ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:42:46: error: expected primary-expression before ‘)’ token
   mShader = std::make_unique<FShaderProgram>();
                                              ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp: In member function ‘void FSSAOShader::Bind()’:
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:70:13: error: ‘make_unique’ is not a member of ‘std’
   mShader = std::make_unique<FShaderProgram>();
             ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:70:44: error: expected primary-expression before ‘>’ token
   mShader = std::make_unique<FShaderProgram>();
                                            ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:70:46: error: expected primary-expression before ‘)’ token
   mShader = std::make_unique<FShaderProgram>();
                                              ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp: In member function ‘void FSSAOCombineShader::Bind()’:
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:146:13: error: ‘make_unique’ is not a member of ‘std’
   mShader = std::make_unique<FShaderProgram>();
             ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:146:44: error: expected primary-expression before ‘>’ token
   mShader = std::make_unique<FShaderProgram>();
                                            ^
/ptmp/gzdoom_build/gzdoom/src/gl/shaders/gl_ambientshader.cpp:146:46: error: expected primary-expression before ‘)’ token
   mShader = std::make_unique<FShaderProgram>();
                                              ^
make[2]: *** [src/CMakeFiles/zdoom.dir/gl/shaders/gl_ambientshader.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/zdoom.dir/all] Error 2
make: *** [all] Error 2

 

I'm guessing that the first error is the only one that matters... Is there a fix for this? I already checked that I have the minimum gcc/cmake versions required. Not sure what else to try.

 

Thanks!

Share this post


Link to post

This error means your compiler does not support the std::make_unique<T> template function, which is formally part of C++14 but generally available for most C++11 implementations as well.

 

You can fix it by replacing all those lines with mShader.reset(new FShaderProgram()) instead.

Share this post


Link to post
11 minutes ago, dpJudas said:

This error means your compiler does not support the std::make_unique<T> template function, which is formally part of C++14 but generally available for most C++11 implementations as well.

 

Why did you use C++14 stuff if there's a working equivalent in C++11?

Share this post


Link to post

Because frankly I figured if it worked on MSVC, then it would work everywhere. I didn't factor in very old versions of GCC into that.

Share this post


Link to post

Encountered the same bug on release g2.4.0  on Ubuntu 14.04 LTS 64 bit. It's still long-term-supported, but old-ish.

 

Following the gzdoom wiki steps, it compiles by default with /usr/bin/c++ which appears to be a wrapper for gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

 

The normal CMakeFlags include -std=gnu++1y . I tried to change the CXX_FLAGS to adding -std=c++14 , but that option is unrecognized until a later gcc (5.2 I remember reading). Then I tried adding -std=c++1y, which is recognized, but I guess still doesn't include the feature.

 

your patch did resolve that issue. Thanks.

 

--- gl_ambientshader.cpp.orig	2017-04-18 02:30:41.462766707 -0700
+++ gl_ambientshader.cpp	2017-04-18 02:34:44.638760737 -0700
@@ -39,7 +39,7 @@
 
 	if (!mShader)
 	{
-		mShader = std::make_unique<FShaderProgram>();
+		mShader.reset(new FShaderProgram());
 		mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
 		mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", multisample ? "#define MULTISAMPLE\n" : "", 330);
 		mShader->SetFragDataLocation(0, "FragColor");
@@ -67,7 +67,7 @@
 
 	if (!mShader)
 	{
-		mShader = std::make_unique<FShaderProgram>();
+		mShader.reset(new FShaderProgram());
 		mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
 		mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", GetDefines(gl_ssao, multisample), 330);
 		mShader->SetFragDataLocation(0, "FragColor");
@@ -143,7 +143,7 @@
 
 	if (!mShader)
 	{
-		mShader = std::make_unique<FShaderProgram>();
+		mShader.reset(new FShaderProgram());
 		mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
 		mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", multisample ? "#define MULTISAMPLE\n" : "", 330);
 		mShader->SetFragDataLocation(0, "FragColor");

Not knowing much about that code, it seems worrying to invoke methods on something which satisfies (!mShader). But I guess that's done before the check as well. Operator overloading for logical not?

Edited by DoubleBarrel

Share this post


Link to post

mShader is a smart pointer. The operation you are concerned about is not with the object being pointed to, but with the pointer itself (i.e. it sets it.)

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×