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

Author Topic: Help me linking with MinGW (command prompt)  (Read 4479 times)

0 Members and 1 Guest are viewing this topic.

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Help me linking with MinGW (command prompt)
« on: April 05, 2015, 11:46:01 pm »
So, I just registered today and I have to say that SDL SUCKS >:(. They don't care about MinGW windows users. I'm pretty sure SFML is more suppportive with MinGW Windows.

So here's my problem. I found that SFML includes libraries with <> operator, which means that I have to put my include folder inside of MinGW folder because <> will look for my MinGW directory, not my current directory. So it solved my problem. But now I have a new problem. Whenever I compile my main.cpp file, I'm getting tons of undefined reference errors. I think this is because of lib files but I have no idea how to link them. Where do I put my lib files? inside of MinGW or my current directory? and do I use
Code: [Select]
-L/mypath -lsomething?

thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
Re: Help me linking with MinGW (command prompt)
« Reply #1 on: April 05, 2015, 11:58:36 pm »
If you want to use MinGW from the command line, you'll have to learn how GCC works with the command line. It's neither the SDL guys nor ours to explain that to you. ;)

I found that SFML includes libraries with <> operator, which means that I have to put my include folder inside of MinGW folder because <> will look for my MinGW directory, not my current directory.
This works, but is bad practice. Again learn how the command line works and you'd have known that you can provide any kind of include directory with the -I option.

Whenever I compile my main.cpp file, I'm getting tons of undefined reference errors. I think this is because of lib files but I have no idea how to link them. Where do I put my lib files? inside of MinGW or my current directory?
If you think using a library will just magically work, you need to wake up from your dream and start reading up on how libraries work, what linking does, etc. It's a general programming thing, not specific to SDL or SFML.

And yes you'll need to use the -L option to point to the library directory and the -l option to link a library. Look at the tutorials for information on which libraries to link etc. Even if they use an IDE the principle stays the same.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Help me linking with MinGW (command prompt)
« Reply #2 on: April 06, 2015, 03:09:04 am »
Somehow, I managed to fix this problem and was able to make an execrable file. But i'm getting an error whenever I try to run my program. (also, I get the same error whenever I try to run sample codes.)

"The procedure entry point
_ZN2sf4Font12LoadFromFileERKsjRKNS_7Unicode4TextE could not be located in the dynamic link library sfml-graphics.dll"

What's wrong with this?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Help me linking with MinGW (command prompt)
« Reply #3 on: April 06, 2015, 03:17:10 am »
Your DLL isn't the same one that came with the lib you are linking to.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Help me linking with MinGW (command prompt)
« Reply #4 on: April 06, 2015, 03:26:38 am »
What does that mean? I'm using libsfml-graphics.a and my dll is sfml-graphics-2.dll

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10846
    • View Profile
    • development blog
    • Email
AW: Help me linking with MinGW (command prompt)
« Reply #5 on: April 06, 2015, 10:22:01 am »
But when you run the executable it finds a different sfml-graphics.dll, meaning you have a different version lying around that might be in PATH. Copy the new Ll next to your executable.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Help me linking with MinGW (command prompt)
« Reply #6 on: April 06, 2015, 02:49:44 pm »
I'm sorry, i'm holding this topic too long. I already copied my graphics.dll and moved to my executable but it still doesn't work (same error happens with the example codes). I'm thinking of giving up SFML and get in to another library if this won't work...

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Help me linking with MinGW (command prompt)
« Reply #7 on: April 06, 2015, 03:00:18 pm »
Give up if you want. But you are not really running into any problems that are SFML specific. You'd have to sort out similar issues with any other library.
And remember, SFML works just fine for thousands of people; the problem here really seems to be your own lack of knowledge about the C++ preprocess/compile/assemble/link process as well as a lack of knowledge about your chosen toolchain and switching libraries really won't help fix that.
« Last Edit: April 06, 2015, 03:03:39 pm by Jesper Juhl »

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Help me linking with MinGW (command prompt)
« Reply #8 on: April 07, 2015, 12:58:47 am »
I fixed it by downloading SFML-Master INSTEAD of SFML. Then I used camke to create cmake file for MinGW and then I compiled it using mingw32-make. Next, I copied my dll and lib files which are generated by akefile and moved to a folder where my main.exe is. When I run my exe file, it works perfectly fine.

Now, this is so confusing me. I'm going to have to learn how dll and lib files work...

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Help me linking with MinGW (command prompt)
« Reply #9 on: April 07, 2015, 04:18:37 pm »
"Now, this is so confusing me. I'm going to have to learn how dll and lib files work..."

Which is what you should have done before, and what a few here have told you to do.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

 

anything