Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Code::Blocks linking problems  (Read 2267 times)

0 Members and 1 Guest are viewing this topic.

pstudio

  • Newbie
  • *
  • Posts: 3
    • View Profile
Code::Blocks linking problems
« on: April 27, 2010, 01:21:16 am »
Hi all :)

I've recently decided to start on a new game project in c++ and I've decided to use SFML over SDL since it simply looks more to my taste.

I've downloaded the SFML 2 source, compiled it, and written a few test programs that works fine, so I know it's setup correctly.

Now for my game I've decided to split it up into two projects in the same workspace. The first is a static library that is going to be a general game engine. The second is the actual game that links to the before mentioned static library. Both projects are supposed to dynamically link to SFML.

So far everything is quite simple but I've ran into a serious problem. There are no problems under the compilation phase, but during the linking phase I get following error messages:

Quote
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x16)||undefined reference to `__imp___ZNK2sf6Window8IsOpenedEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x29)||undefined reference to `__imp___ZN2sf6Window8GetEventERNS_5EventE'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x4b)||undefined reference to `__imp___ZN2sf6Window5CloseEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x58)||undefined reference to `__imp___ZN2sf6Window8GetEventERNS_5EventE'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x65)||undefined reference to `__imp___ZN2sf6Window7DisplayEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x6e)||undefined reference to `__imp___ZNK2sf6Window8IsOpenedEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x87)||undefined reference to `__imp___ZN2sf6Window5CloseEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x197)||undefined reference to `__imp___ZN2sf9VideoModeC1Ejjj'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x1d7)||undefined reference to `__imp___ZN2sf6Window6CreateENS_9VideoModeERKSsmRKNS_15ContextSettingsE'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x2aa)||undefined reference to `__imp___ZN2sf9VideoModeC1Ejjj'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x2ea)||undefined reference to `__imp___ZN2sf6Window6CreateENS_9VideoModeERKSsmRKNS_15ContextSettingsE'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x512)||undefined reference to `__imp___ZNK2sf6Window8IsOpenedEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x524)||undefined reference to `__imp___ZN2sf6Window5CloseEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x539)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x580)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x602)||undefined reference to `__imp___ZNK2sf6Window8IsOpenedEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x614)||undefined reference to `__imp___ZN2sf6Window5CloseEv'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x629)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x670)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x6f0)||undefined reference to `__imp___ZN2sf12RenderWindowC1Ev'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x764)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x7e0)||undefined reference to `__imp___ZN2sf12RenderWindowC1Ev'|
..\APE\libAPE.a(APEengine.o):APEengine.cpp:(.text+0x854)||undefined reference to `sf::RenderWindow::~RenderWindow()'|
||=== Build finished: 23 errors, 0 warnings ===|


For some reason it can't find the definition of those functions. Now I don't expect this to be a specific SFML problem. More likely it's me who don't know how to setup CB probably. However I will greatly appreciate it, if someone knows how to solve this, probably stupid, problem. In the meantime I'll continue reading through the CB manual to see if I can solve it myself.

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Code::Blocks linking problems
« Reply #1 on: April 27, 2010, 01:58:47 am »
dll = dynamic link library

How are you going to statically link to a dll?

pstudio

  • Newbie
  • *
  • Posts: 3
    • View Profile
Code::Blocks linking problems
« Reply #2 on: April 27, 2010, 02:52:21 am »
Quote from: "Ashenwraith"
dll = dynamic link library

How are you going to statically link to a dll?


Well I won't deny the possibility that I'm completely wrong here, but the idea is, that the the static library, which will be included in the game exe, dynamically links to the SFML dll's. I can't see the big difference between a static library dynamically linking to some dll's and a compiled exe dynamically linking to the same dll's. If there is, you're welcome to enlighten me :)

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
Code::Blocks linking problems
« Reply #3 on: April 27, 2010, 05:46:31 am »
But why do you need a static library to compile inside your workspace with your project?

I guess it's possible.

pstudio

  • Newbie
  • *
  • Posts: 3
    • View Profile
Code::Blocks linking problems
« Reply #4 on: April 27, 2010, 06:33:32 am »
Quote
But why do you need a static library to compile inside your workspace with your project?

Well the static library (which I supposed could be dynamic as well), is a simple general game engine. You know things like state handling, assets handling etc. The other project in the workspace right now is just a test project to test the engine. They don't need to be in the same workspace, but it seems more logical to me and I can't see why it would hurt.

To me the errors look they are caused by some name mangling in the static library. I just tried compiling the library as a dll which seems to solve this problem, though I recieved a new error. I'll try and look some more into this.

 

anything