Hi, I am porting a script from 2.49 to a more recent blender version and I needed to run the old version to compare the results, however the official 2.49b binaries use python2.6 which is not available on recent linux distributions. So I recompiled blender against python2.7 but in order to do so I had to patch the code to make it work with newer compilers.
Here is the patch attached in case someone may need it. Some more info about the command I used to set up the build are in the patch itself. To make it easier to find maybe it can be uploaded to https://download.blender.org/release/Blender2.49b/ Thanks, Antonio -- Antonio Ospite https://ao2.it https://twitter.com/ao2it A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?
>From 457d1e97695adc1ff3bf29c7ff2b0335d5c1675f Mon Sep 17 00:00:00 2001 From: Antonio Ospite <[email protected]> Date: Thu, 17 Aug 2017 13:08:59 +0200 Subject: [PATCH] Allow blender 2.49 to build with modern gcc versions X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM<pyWR#k60!#=#>/Vb;]yA5<GWI5`6u&+ ;6b'@y|8w"wB;4/e!7wYYrcqdJFY,~%Gk_4]cq$Ei/7<j&N3ah(m`ku?pX.&+~:_/wC~dwn^)MizBG !pE^+iDQQ1yC6^,)YDKkxDd!T>\I~93>J<_`<4)A{':UrE Users may need to run blender-2.49 to port old scripts to newer versions and be able to compare and verify the results. However the official blender-2.49b builds are linked against python2.6 and newer systems may not ship it anymore, making it hard to run the official pre-compiled binaries with the python infrastructure working. In these cases re-compiling blender may be a better option compared to using virtual machines, but the code is not compatible with newer compilers. So patch the code and the build system in the v2.49b branch to allow to compile blender on newer systems using cmake. Tested on a Debian Unstable as per 2017-08-17 (gcc-7 and python2.7), with the following commands: $ mkdir build $ cd build $ cmake \ -D CMAKE_CXX_FLAGS="-fpermissive" \ -D PYTHON_LIBRARY=/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so \ -D PYTHON_INCLUDE_DIR=/usr/include/python2.7 \ -D PYTHON_EXECUTABLE=/usr/bin/python2.7 \ ../ --- CMakeLists.txt | 2 +- intern/elbeem/intern/ntl_blenderdumper.cpp | 2 +- intern/elbeem/intern/particletracer.cpp | 2 +- intern/memutil/MEM_Allocator.h | 2 ++ source/blender/imbuf/intern/dds/ColorBlock.cpp | 4 ++-- source/blender/imbuf/intern/dds/Common.h | 10 +++------- source/blender/imbuf/intern/dds/DirectDrawSurface.cpp | 14 +++++++------- source/creator/CMakeLists.txt | 1 - source/gameengine/Expressions/PyObjectPlus.h | 2 ++ source/gameengine/GameLogic/SCA_PythonController.cpp | 2 +- source/gameengine/Ketsji/KX_Light.cpp | 2 +- .../gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp | 2 +- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcb2f546bce..5a90ce421b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,7 @@ IF(UNIX) SET(ZLIB_LIB z) - SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++") + SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11 -ldl") IF(WITH_OPENMP) SET(LLIBS "${LLIBS} -lgomp") diff --git a/intern/elbeem/intern/ntl_blenderdumper.cpp b/intern/elbeem/intern/ntl_blenderdumper.cpp index b1fece25890..35329947558 100644 --- a/intern/elbeem/intern/ntl_blenderdumper.cpp +++ b/intern/elbeem/intern/ntl_blenderdumper.cpp @@ -164,7 +164,7 @@ int ntlBlenderDumper::renderScene( void ) boutfilename << ".bobj.gz"; gzf = gzopen(boutfilename.str().c_str(), "wb1"); // wb9 is slow for large meshes! if (!gzf) { - errMsg("ntlBlenderDumper::renderScene","Unable to open output '"<<boutfilename<<"' "); + errMsg("ntlBlenderDumper::renderScene","Unable to open output '"<<boutfilename.str()<<"' "); return 1; } // dont transform velocity output, this is handled in blender diff --git a/intern/elbeem/intern/particletracer.cpp b/intern/elbeem/intern/particletracer.cpp index 819fcdd0b9a..be472759438 100644 --- a/intern/elbeem/intern/particletracer.cpp +++ b/intern/elbeem/intern/particletracer.cpp @@ -231,7 +231,7 @@ void ParticleTracer::checkDumpTextPositions(double simtime) { if(mDumpTextFile.length()>1) { boutfilename << mDumpTextFile << ".cpart2"; } else { - boutfilename << boutfilename <<"_particles" << ".cpart2"; + boutfilename << boutfilename.str() <<"_particles" << ".cpart2"; } debMsgStd("ParticleTracer::checkDumpTextPositions",DM_MSG,"T-Dumping: "<< this->getName() <<", particles:"<<mParts.size()<<" "<< " to "<<boutfilename.str()<<" " , 7); diff --git a/intern/memutil/MEM_Allocator.h b/intern/memutil/MEM_Allocator.h index b2c3c5e82e2..73a65b138fc 100644 --- a/intern/memutil/MEM_Allocator.h +++ b/intern/memutil/MEM_Allocator.h @@ -24,6 +24,8 @@ #ifndef __MEM_Allocator_h_included__ #define __MEM_Allocator_h_included__ 1 +#include <stddef.h> + #include "guardedalloc/MEM_guardedalloc.h" #include "guardedalloc/BLO_sys_types.h" diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 043fba9d675..167603127c9 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -78,8 +78,8 @@ ColorBlock::ColorBlock(const Image * img, uint x, uint y) void ColorBlock::init(const Image * img, uint x, uint y) { - const uint bw = min(img->width() - x, 4U); - const uint bh = min(img->height() - y, 4U); + const uint bw = std::min(img->width() - x, 4U); + const uint bh = std::min(img->height() - y, 4U); static int remainder[] = { 0, 0, 0, 0, diff --git a/source/blender/imbuf/intern/dds/Common.h b/source/blender/imbuf/intern/dds/Common.h index 6f09346f770..5248e195b36 100644 --- a/source/blender/imbuf/intern/dds/Common.h +++ b/source/blender/imbuf/intern/dds/Common.h @@ -25,14 +25,10 @@ #ifndef _DDS_COMMON_H #define _DDS_COMMON_H -#ifndef min -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) ((a) >= (b) ? (a) : (b)) -#endif +#include <algorithm> + #ifndef clamp -#define clamp(x,a,b) min(max((x), (a)), (b)) +#define clamp(x,a,b) std::min(std::max((x), (a)), (b)) #endif template<typename T> diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 0981ae88db6..3d6290ab9b8 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -858,8 +858,8 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) // Compute width and height. for (uint m = 0; m < mipmap; m++) { - w = max(1U, w / 2); - h = max(1U, h / 2); + w = std::max(1U, w / 2); + h = std::max(1U, h / 2); } img->allocate(w, h); @@ -963,9 +963,9 @@ void DirectDrawSurface::readBlockImage(Image * img) readBlock(&block); // Write color block. - for (uint y = 0; y < min(4U, h-4*by); y++) + for (uint y = 0; y < std::min(4U, h-4*by); y++) { - for (uint x = 0; x < min(4U, w-4*bx); x++) + for (uint x = 0; x < std::min(4U, w-4*bx); x++) { img->pixel(4*bx+x, 4*by+y) = block.color(x, y); } @@ -1085,9 +1085,9 @@ uint DirectDrawSurface::mipmapSize(uint mipmap) const for (uint m = 0; m < mipmap; m++) { - w = max(1U, w / 2); - h = max(1U, h / 2); - d = max(1U, d / 2); + w = std::max(1U, w / 2); + h = std::max(1U, h / 2); + d = std::max(1U, d / 2); } if (header.pf.flags & DDPF_FOURCC) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index f31a68365fb..f88bcd38df2 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -95,7 +95,6 @@ IF(UNIX AND NOT APPLE) COMMAND mkdir ${TARGETDIR}/.blender/ COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/ COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/scripts ${TARGETDIR}/.blender/ COMMAND find ${TARGETDIR} -name CVS -prune -exec rm -rf {} "\;" ) diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index c002dccefe4..5c44337acae 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -36,6 +36,8 @@ #error Must be compiled with C++ #endif +#include <cstddef> + #include "KX_Python.h" #include "STR_String.h" #include "MT_Vector3.h" diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 80e4f54c9c5..a65b1ecf259 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -203,7 +203,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) PyErr_Format(PyExc_ValueError, "'%s' not in this python controllers actuator list", PyString_AsString(value_str)); Py_DECREF(value_str); - return false; + return NULL; } /* warning, self is not the SCA_PythonController, its a PyObjectPlus_Proxy */ diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index ae9e097a96e..95d77f16ae7 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -188,7 +188,7 @@ GPULamp *KX_LightObject::GetGPULamp() if(m_glsl) return GPU_lamp_from_blender(m_blenderscene, GetBlenderObject(), GetBlenderGroupObject()); else - return false; + return NULL; } void KX_LightObject::Update() diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index e41574ff181..626f49709ab 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -111,6 +111,6 @@ void DummyPhysicsEnvironment::removeConstraint(int constraintid) PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { //collision detection / raytesting - return NULL; + return nullptr; } -- 2.14.1
_______________________________________________ Bf-committers mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-committers
