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

Author Topic: [Solved] Undefined reference [Static Linking]  (Read 7656 times)

0 Members and 1 Guest are viewing this topic.

Mokka

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
[Solved] Undefined reference [Static Linking]
« on: April 13, 2015, 06:57:08 pm »
I fixed it, look down below for my working linking order....


---------------
Hey there

I am using SFML for quite a while now, but just used dynamic linking.

Now I decided to set up static linking.

But every time I try to compile something, I get a few errors...

I think I did set up the project properly...

(click to show/hide)

(click to show/hide)

(click to show/hide)

I also added the "SFML_STATIC" to the #defines...

The code is:
(click to show/hide)

That's the error message:
 
(click to show/hide)

Quote
||=== Build: Debug in MTG (compiler: GNU GCC Compiler) ===|
C:\SFML-2.2\lib\libsfml-system-s-d.a(SleepImpl.cpp.obj)||In function `ZN2sf4priv9sleepImplENS_4TimeE':|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|41|   undefined reference to `_imp__timeGetDevCaps@8'|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|44|   undefined reference to `_imp__timeBeginPeriod@4'|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|50|   undefined reference to `_imp__timeEndPeriod@4'|
C:\SFML-2.2\lib\libglew.a(glew.c.o):glew.c   ||   undefined reference to `wglGetCurrentDC@0'|
C:\SFML-2.2\lib\libglew.a(glew.c.o):glew.c   ||   undefined reference to `wglGetCurrentDC@0'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|



I hope that somebody can help me.

Thanks in advance

Mokka

(Please excuse bad english ^^)
« Last Edit: April 14, 2015, 03:13:55 pm by Mokka »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Undefined reference [Static Linking]
« Reply #1 on: April 13, 2015, 07:14:44 pm »
Maybe it's just me (on my phone right now), but the image of the error message is too small and blurred for me to read anything... Have you considered posting the text of the message instead?

Anyway, a "undefined reference" error is a linker error and basically means that there is a symbol referenced in your code that the linker couldn't resolve (find). This usually means that there's a library you forgot to link or you linked the libraries in the wrong order.
Are you sure you are linking all sfml's dependencies explicitly (needed when doing static linking)?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10822
    • View Profile
    • development blog
    • Email
Re: Undefined reference [Static Linking]
« Reply #2 on: April 13, 2015, 09:26:35 pm »
Read the official SFML 2.2 tutorial and I mean read it. Because the static linking has changed for SFML 2.2 and you now need to link against SFML's dependencies as well.

Maybe it's just me (on my phone right now), but the image of the error message is too small and blurred for me to read anything...
Yeah that's a phone issue...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Undefined reference [Static Linking]
« Reply #3 on: April 14, 2015, 09:51:00 am »
Read the official SFML 2.2 tutorial and I mean read it. Because the static linking has changed for SFML 2.2 and you now need to link against SFML's dependencies as well.

Maybe it's just me (on my phone right now), but the image of the error message is too small and blurred for me to read anything...
Yeah that's a phone issue...

If i'm not mistaken he does indeed link against SFML's dependencies :o
To me it looks like he declared the libs in a wrong order.
« Last Edit: April 14, 2015, 02:13:55 pm by SpeCter »

Mokka

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Undefined reference [Static Linking]
« Reply #4 on: April 14, 2015, 01:59:25 pm »
To me it looks like he declared the libs in a wrong order.

So how is the right linking order. ^^

Thanks for your replies though :D

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10822
    • View Profile
    • development blog
    • Email
AW: Undefined reference [Static Linking]
« Reply #5 on: April 14, 2015, 02:07:16 pm »
Look at the tutorial, the way it's listed there is an order that works.

It usually is if x depends on y then x comes before y.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mokka

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: AW: Undefined reference [Static Linking]
« Reply #6 on: April 14, 2015, 02:40:38 pm »
Look at the tutorial, the way it's listed there is an order that works.

It usually is if x depends on y then x comes before y.


I understood it. I now moved all the main module (sfml-system-s(-d) and so on) and let the dependencies stay at the top. It changed like nothing...

Quote
||=== Build: Debug in MTG (compiler: GNU GCC Compiler) ===|
)    ||    undefined reference to `wglGetCurrentDC@0'|
C:\SFML-2.2\lib\libglew.a(glew.c.o):glew.c     ||     undefined reference to `wglGetCurrentDC@0'|
C:\SFML-2.2\lib\libsfml-system-s-d.a(SleepImpl.cpp.obj)     ||     In function `ZN2sf4priv9sleepImplENS_4TimeE':|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|41|    undefined reference to `_imp__timeGetDevCaps@8'|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|44|    undefined reference to `_imp__timeBeginPeriod@4'|
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp|50|    undefined reference to `_imp__timeEndPeriod@4'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

But I recognised that in the error log there is a file that is located on my D:\\ drive:
Quote
D:\sfml-release\_Sources\SFML\src\SFML\System\Win32\SleepImpl.cpp

But I didn't find the folder/directory. The dir "D:\sfml-release\" is not existent on my PC?!

Is that supposed to happen or am I missing some files?!


Also: Which order it's listed??
The table that lists the needed dependencies?! Because otherwise there is just the dynamic linking shown-

Thanks for the reply ^^
« Last Edit: April 14, 2015, 02:43:20 pm by Mokka »

Mokka

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Undefined reference [Static Linking]
« Reply #7 on: April 14, 2015, 02:55:31 pm »
Ok....
I moved all the modules to the top...
So sfml-system-s and co. to the top of the list and then the dependencies...

This got rid of the
Quote
C:\SFML-2.2\lib\libsfml-system-s.a(SleepImpl.cpp.obj):SleepImpl.cpp   ||   undefined reference to `_imp__timeGetDevCaps@8'|
C:\SFML-2.2\lib\libsfml-system-s.a(SleepImpl.cpp.obj):SleepImpl.cpp   ||   undefined reference to `_imp__timeBeginPeriod@4'|
C:\SFML-2.2\lib\libsfml-system-s.a(SleepImpl.cpp.obj):SleepImpl.cpp   ||   undefined reference to `_imp__timeEndPeriod@4'|

error, but instead I now have an
Quote
||=== Build: Debug in MTG (compiler: GNU GCC Compiler) ===|
C:\SFML-2.2\lib\libglew.a(glew.c.o):glew.c      ||      undefined reference to `wglGetCurrentDC@0'|
C:\SFML-2.2\lib\libglew.a(glew.c.o):glew.c      ||      undefined reference to `wglGetCurrentDC@0'|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
error...
I'm completely stuck now :(

Mokka

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Undefined reference [Static Linking]
« Reply #8 on: April 14, 2015, 03:10:36 pm »
Got it to work....

I had the dependencies setted wrong.

If anyone should have problems with it, here is a picture of the finished order.
Note: I used the "extlib" included on the github directory.....

Thank you all so much for helping. It is working perfectly for me now :D

CU
Mokka
« Last Edit: April 14, 2015, 03:12:15 pm by Mokka »