kestrelm / Creature_Godot

2D Skeletal Animation Creature Runtime for Godot Engine
Apache License 2.0
84 stars 12 forks source link

fails to compile on linux x11 godot editor #1

Closed blurymind closed 8 years ago

blurymind commented 8 years ago

I get this error:

modules/creaturegodot/gason/gason.h:137:12: error: 'nullptr' was not declared in this scope In file included from modules/creaturegodot/creaturegodot.h:7:0, from modules/creaturegodot/register_types.cpp:5: modules/creaturegodot/CreatureModule.h:242:40: error: expected ')' before '<' token CreatureManager(std::shared_ptrCreatureModule::Creature target_creatu ^ modules/creaturegodot/CreatureModule.h:251:32: error: 'std::shared_ptr' has not been declared void AddAnimation(std::shared_ptrCreatureModule::CreatureAnimation an ^ modules/creaturegodot/CreatureModule.h:251:42: error: expected ',' or '...' before '<' token void AddAnimation(std::shared_ptrCreatureModule::CreatureAnimation an ^ modules/creaturegodot/CreatureModule.h:268:14: error: 'unordered_map' in namespace 'std' does not name a template type std::unordered_map<std::string, std::shared_ptr<CreatureModule::Creatur ^ modules/creaturegodot/CreatureModule.h:327:44: error: 'std::function' has not been declared void SetBonesOverrideCallback(std::function<void (std::unordered_map<st ^ modules/creaturegodot/CreatureModule.h:327:52: error: expected ',' or '...' before '<' token void SetBonesOverrideCallback(std::function<void (std::unordered_map<st ^ modules/creaturegodot/CreatureModule.h:378:32: error: 'std::unordered_map' has not been declared void AlterBonesByAnchor(std::unordered_map<std::string, meshBone >& bones_ma ^ modules/creaturegodot/CreatureModule.h:378:45: error: expected ',' or '...' before '<' token void AlterBonesByAnchor(std::unordered_map<std::string, meshBone >& bones_ma ^ modules/creaturegodot/CreatureModule.h:380:14: error: 'unordered_map' in namespace 'std' does not name a template type std::unordered_map<std::string, std::shared_ptr<CreatureModule::Creatur ^ modules/creaturegodot/CreatureModule.h:381:14: error: 'shared_ptr' in namespace 'std' does not name a template type std::shared_ptr target_creature; ^ modules/creaturegodot/CreatureModule.h:390:8: error: 'unordered_map' in namespace 'std' does not name a template type std::unordered_map<std::string, float> active_blend_run_times; ^ modules/creaturegodot/CreatureModule.h:400:14: error: 'function' in namespace 'std' does not name a template type std::function<void (std::unordered_map<std::string, meshBone *>&) > bon ^ In file included from modules/creaturegodot/register_types.cpp:5:0: modules/creaturegodot/creaturegodot.h:28:10: error: 'shared_ptr' in namespace 'std' does not name a template type std::shared_ptrCreatureModule::CreatureManager manager; ^ scons: *\ [modules/creaturegodot/register_types.x11.tools.64.o] Error 1 scons: building terminated because of errors.

kestrelm commented 8 years ago

You need a C++11 compiler to build the module. Your C++ compiler looks outdated and doesn't support the C++11 standard.

blurymind commented 8 years ago

this http://codeforces.com/blog/entry/15667

says I need gcc-4.7 g++-4.7 and I need to run it with -std=c++11 How do I pass that argument to the scons script?

kestrelm commented 8 years ago

Hello,

This is more of a scons/compiler specific question. You might want to take a look here: http://stackoverflow.com/questions/13179316/how-to-tell-scons-to-use-the-c11-standard

blurymind commented 8 years ago

so do I have to add this line somewhere in the sconstruct file?

env=Environment(CPPPATH='/usr/include/boost/', CPPDEFINES=[], LIBS=[], CXXFLAGS="-std=c++0x" )

I have no idea where to add it

kestrelm commented 8 years ago

No that is the incorrect line. Look at this one instead: http://stackoverflow.com/questions/31232955/using-scons-to-compile-c-file-with-std-c11-flag

Also please read this doc too: https://bitbucket.org/scons/scons/wiki/SConsCrashCourse

blurymind commented 8 years ago

the scons script doesnt even have an env= line. It is more complicated because it builds to different targets

kestrelm commented 8 years ago

Sorry but I am in the middle of fixing some other bugs right now. I can definitely look at the issue for you when I get the cycles. However, this really is more of a general Godot Engine or even scons question. You might want to ask in the general Godot Engine forums how to setup your compiler for C++11 support. Depending on your platform and default compiler configuration, the C++11 environment setup might be different. Cheers

blurymind commented 8 years ago

@kestrelm forwarded the question to godot's issue tracker.

Thank you kindly for the help so far! I will try to get it compiled and test the example files that you have provided.

kestrelm commented 8 years ago

While you are at it, if you really want to use Godot it will help you a lot if you learn a bit about the scons build system since that's how they build their engine. In the future if you want to use some other feature you will also know what to do. Cheers

blurymind commented 8 years ago

So far I am mostly interested in learning gdscript. :) But I might give it a try later on.

blurymind commented 8 years ago

I might be able to get it to compile with scons p=x11 CCFLAGS="-std=c++11"

will give it a try a bit later :)

blurymind commented 8 years ago

it still fails to build it with that! One godot user actually had a suggestion for your code:

You don't need to enable it for the whole build, just for your module on the SCsub, something like this:

module_sources=['file1.cpp', 'file2.cpp']

env_mymodule = env.Clone() env_mymodule.Append(CXXFLAGS=['--enable-c++11', '-D_SOME_MODULE_DEFINE'])

env_mymodule.add_source_files(env.modules_sources, module_sources)

That will add the compiler flags only to your sources and not to the rest of the build. Keep in mind that not all compilers use the same flags obviously (maybe there's a scons option to enable c++11 that is more portable), the point is whatever you do to that environment won't affect the rest of the build (which means if you enable or disable the module it won't trigger a recompile of all the sources, only the ones specifically affected by your module) https://github.com/godotengine/godot/issues/4490#issuecomment-215941526

blurymind commented 8 years ago

We found a solution. In order to get it to compile on godot editor - non windows version, you need to change your SCsub file of the module(https://github.com/kestrelm/Creature_Godot/blob/master/creaturegodot/SCsub) to this:

# SCsub
Import('env')

env_module = env.Clone()
env_module.Append(CPPDEFINES=['_USE_MATH_DEFINES'])
env_module.Append(CPPPATH='#modules/creaturegodot') # Added to find headers
env_module.Append(CPPPATH='#modules/creaturegodot/glm')
env_module.Append(CPPPATH='#modules/creaturegodot/gason')
env_module.Append(CXXFLAGS=['-std=c++11'])
env_module.add_source_files(env.modules_sources,"*.cpp") # just add all cpp files to the build

it should also improve the module build for windows and mac users - as the c++ flag is restricted only to the module.

If you keep the c++11 flag only to your module, you shouldn't have a problem with the rest of the headers of the engine..

one of godot devs:

It looks like issues with the module itself, you should probably take it to the upstream developer directly.

You could commit that change to master and test it if you like :) Hope this helps improve the module and helps other users!

kestrelm commented 8 years ago

I just updated the build scons file. Actually this probably only applies to linux, both mac and windows compilers are already C++11 compliant so that flag is not required.

Cheers

blurymind commented 8 years ago

seems to work like a charm. I will test it with the other example files