compile error when building shared libs

May 9, 2025 at 6:49pm
I I'm trying to compile my lib on shared but I get this error message that I don't understand :

1
2
3
4
5
6
7
8
9
10
11
12
13
[ 37%] Linking CXX shared library ..\..\..\lib\libodfaeg-graphics-d.dll
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\odfaeg-graphics.dir/objects.a(application.cpp.obj): in function `odfaeg::core::EntitySystem::~EntitySystem()':
C:/Users/Laurent et Christian/ODFAEG-master/ODFAEG/include/odfaeg/Core/entitySystem.h:22:(.text$_ZN6odfaeg4core12EntitySystemD1Ev[_ZN6odfaeg4core12EntitySystemD1Ev]+0xf): undefined reference to `__imp__ZTVN6odfaeg4core12EntitySystemE'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\odfaeg-graphics.dir/objects.a(application.cpp.obj): in function `odfaeg::core::Timer::~Timer()':
C:/Users/Laurent et Christian/ODFAEG-master/ODFAEG/include/odfaeg/Core/timer.h:19:(.text$_ZN6odfaeg4core5TimerD1Ev[_ZN6odfaeg4core5TimerD1Ev]+0xf): undefined reference to `__imp__ZTVN6odfaeg4core5TimerE'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\odfaeg-graphics.dir/objects.a(animationUpdater.cpp.obj): in function `odfaeg::core::Timer::Timer()':
C:/Users/Laurent et Christian/ODFAEG-master/ODFAEG/include/odfaeg/Core/timer.h:19:(.text$_ZN6odfaeg4core5TimerC2Ev[_ZN6odfaeg4core5TimerC2Ev]+0xf): undefined reference to `__imp__ZTVN6odfaeg4core5TimerE'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\odfaeg-graphics.dir/objects.a(particleSystem.cpp.obj): in function `odfaeg::core::Timer::~Timer()':
C:/Users/Laurent et Christian/ODFAEG-master/ODFAEG/include/odfaeg/Core/timer.h:19:(.text$_ZN6odfaeg4core5TimerD2Ev[_ZN6odfaeg4core5TimerD2Ev]+0xf): undefined reference to `__imp__ZTVN6odfaeg4core5TimerE'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [src\odfaeg\Graphics\CMakeFiles\odfaeg-graphics.dir\build.make:1731: lib/libodfaeg-graphics-d.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:418: src/odfaeg/Graphics/CMakeFiles/odfaeg-graphics.dir/all] Error 2
mingw32-make: *** [makefile:135: all] Error 2


I have a class EntitySystem and other classes on another module inherits from this class.

The base class :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef ODFAEG_ENTITY_SYSTEM_HPP
#define ODFAEG_ENTITY_SYSTEM_HPP
#include <condition_variable>
#include <mutex>
#include <thread>
#include "export.hpp"
#include <chrono>
/**
*\namespace odfaeg
* the namespace of the Opensource Development Framework Adapted for Every Games.
*/
namespace odfaeg {
    namespace core {
        /**
        * \file entitySystem.h
        * \class EntitiesSystem
        * \brief base class of all entities systems of the odfaeg.
        * \author Duroisin.L
        * \version 1.0
        * \date 1/02/2014
        */
        class ODFAEG_CORE_API EntitySystem {
        public :
            /**
            *\fn void update()
            *\brief function called when we need to update the entities, this function block the current thread until it's finished.
            */
            void update () {
                onUpdate();
            }
            void setName(std::string name) {
                this->name = name;
            }
            std::string getName() {
                return name;
            }
            /**
            *\fn void onUpdate()
            *\brief function to refefines to updates the entities.
            */
            virtual void onUpdate() = 0;
        private:
            std::string name;
        };
    }
}
#endif // ENTITY_SYSTEM 


The derived class :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef ODFAEG_ENTITIES_UPDATER_HPP
#define ODFAEG_ENTITIES_UPDATER_HPP
#include "../Core/entitySystem.h"
#include "../Graphics/application.h"
#include "export.hpp"
/**
*\namespace odfaeg
* the namespace of the Opensource Development Framework Adapted for Every Games.
*/
 
namespace odfaeg {
    namespace graphic {
        /**
        * \file entitiesUpdater.h
        * \class EntitiesUpdater
        * \brief update all the entities in the world which are in the current view with a thread.
        * \author Duroisin.L
        * \version 1.0
        * \date 1/02/2014
        */
        class ODFAEG_GRAPHICS_API EntitiesUpdater : public core::EntitySystem {
        public :
            EntitiesUpdater(EntityFactory& factory, World& world) : world(world), factory(factory), EntitySystem() {}
            /**
            * \fn void onUpdate ()
            * \brief update all the entities which are in the current view.
            */
            void onUpdate () {
                //std::cout<<"update world"<<std::endl;
                world.checkVisibleEntities(factory);
                //std::cout<<"world updated"<<std::endl;
            }
        private :
            World& world;
            EntityFactory& factory;
        };
    }
}


I'm new with making libraries so..., but in static mode it compile without any problems...

Thanks.
Last edited on May 9, 2025 at 6:50pm
May 10, 2025 at 4:28pm
Ok Solved I just had to put the code in .cpp files. It seems in shared mode mingw doesn't like code in .h files.
Last edited on May 10, 2025 at 4:28pm
May 10, 2025 at 8:43pm
C and C++ use different name mangling.
Registered users can post here. Sign in or register to post.