Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
509 stars 128 forks source link

Fix: undefined-var-template #213

Closed khiav223577 closed 5 years ago

khiav223577 commented 5 years ago

I encountered this problem when I tried to build mkxp.

make: *** [filesystem.o] Error 1
In file included from src/bitmap.cpp:33:
src/gl-meta.h:57:44: warning: instantiation of variable 'VertexTraits<Vertex>::attr' required here, but no definition is available [-Wundefined-var-template]
        vao.attr      = VertexTraits<VertexType>::attr;
                                                  ^
src/quad.h:79:11: note: in instantiation of function template specialization 'GLMeta::vaoFillInVertexData<Vertex>' requested here
                GLMeta::vaoFillInVertexData<Vertex>(vao);
                        ^
src/vertex.h:65:32: note: forward declaration of template entity is here
        static const VertexAttribute *attr;
                                      ^
src/gl-meta.h:57:44: note: add an explicit instantiation declaration to suppress this warning if 'VertexTraits<Vertex>::attr' is explicitly instantiated in another translation unit
        vao.attr      = VertexTraits<VertexType>::attr;
                                                  ^
2018-11-15 8 02 55

Not sure why, but I managed to fix it by adding a line to define VertexTraits<Vertex>::attr, and it worked for me.

Environment

Ancurio commented 5 years ago

And the engine runs without graphical problems?

Edit: Also, what compiler is this?

khiav223577 commented 5 years ago

I hasn't encountered any problem yet. It can display the title scene, maps, characters, and pictures.

My compiler is:

Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Ancurio commented 5 years ago

Can't compile this with g++ 8.3.1, unsure what the issue with clang is:

vertex.o:(.data.rel.local+0x0): multiple definition of `VertexTraits<Vertex>::attr'
bitmap.o:(.bss._ZN12VertexTraitsI6VertexE4attrE[_ZN12VertexTraitsI6VertexE4attrE]+0x0): first defined here
vertex.o:(.data.rel.local+0x8): multiple definition of `VertexTraits<CVertex>::attr'
tilemap.o:(.bss._ZN12VertexTraitsI7CVertexE4attrE[_ZN12VertexTraitsI7CVertexE4attrE]+0x0): first defined here
vertex.o:(.data.rel.local+0x10): multiple definition of `VertexTraits<SVertex>::attr'
plane.o:(.bss._ZN12VertexTraitsI7SVertexE4attrE[_ZN12VertexTraitsI7SVertexE4attrE]+0x0): first defined here
collect2: error: ld returned 1 exit status

Will reopen this if more people report issues.