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

Author Topic: Compiling with g++ on windows.  (Read 8201 times)

0 Members and 1 Guest are viewing this topic.

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Compiling with g++ on windows.
« on: March 14, 2015, 10:02:09 pm »
I read over this thread: http://en.sfml-dev.org/forums/index.php?topic=12301.msg85572#msg85572

However, a solution wasn't really posted, at least one that i understood.
The OP fixed his problem and left a link, that link is now private unfortunately.

Basically this is how it goes:

"g++ -c source.cpp"     .o file is created.



"C:\Users\Kankei\Desktop\GCC>g++ source.o -o sfml-app -LC:\Users\Kankei\Desktop\GCC\SFML-2.2\lib -lsfml-graphics -lsfml-window -lsfml-system"

Error:

"c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status"


Thanks in advance...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling with g++ on windows.
« Reply #1 on: March 14, 2015, 10:08:47 pm »
What does C:\Users\Kankei\Desktop\GCC\SFML-2.2\lib contain?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #2 on: March 14, 2015, 10:14:15 pm »
libsfml-audio.so
libsfml-audio.so.2.2.0
libsfml-graphics.so
libsfml-graphics.so.2.2.0
libsfml-network.so
libsfml-network.so.2.2.0
libsfml-system.so
libsfml-system.so.2.2.0
libsfml-window.so
libsfml-window.so.2.2.0





eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling with g++ on windows.
« Reply #3 on: March 14, 2015, 10:19:55 pm »
So you're trying to use Linux binaries on Windows? ???

Yeah that's not gonna work. Build SFML on Windows with MinGW or get precompiled binaries that match your compiler version.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #4 on: March 14, 2015, 10:33:51 pm »
Thanks for the Help!

I got the exe file to pop out now that i got the windows version.

but when i started the exe file i get an error window displaying:

"The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz could not be located in the dynamic link library libstdc++-6.dll"

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling with g++ on windows.
« Reply #5 on: March 14, 2015, 10:45:30 pm »
Did you build SFML yourself? Or which package did you download?
Where did you get your compiler from?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #6 on: March 14, 2015, 11:21:47 pm »
Sorry for the late response.

Yes i built it myself using the cmake guide.

I got my compiler from mingw.org

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling with g++ on windows.
« Reply #7 on: March 14, 2015, 11:31:03 pm »
Do you also get that error if you build a simple hello world example?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #8 on: March 14, 2015, 11:36:08 pm »
Works fine with a simple hello world program.

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #9 on: March 15, 2015, 12:12:55 am »
UPDATE: I reinstalled everything and rebuilt everything, during the build i check to use static librarys.

Anywho, I went in a giant circle and got this again:

C:\Users\Kankei\Desktop\Test>g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status

same thing goes for this command aswell:
g++ main.o -o sfml-app -LC:\Users\Kankei\Desktop\Coding\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system




Also when i just run this command:
g++ main.cpp -o sfml-app

I get this:
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0xe5): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x10b): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x147): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x17d): undefined reference to `_imp___ZN2sf11CircleShapeC1Efj'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x18e): undefined reference to `_imp___ZN2sf5Color5GreenE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x198): undefined reference to `_imp___ZN2sf5Shape12setFillColorERKNS_5ColorE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x1b8): undefined reference to `_imp___ZN2sf6Window5closeEv'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x1cd): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x1ff): undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x21a): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x22d): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x241): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x253): undefined reference to `_imp___ZN2sf6Window7displayEv'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x262): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x28b): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x2b2): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x2ec): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o: bad reloc address 0xf in section `.text$_ZN2sf6StringD1Ev[__ZN2sf6StringD1Ev]'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation

« Last Edit: March 15, 2015, 12:18:20 am by Borat »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Compiling with g++ on windows.
« Reply #10 on: March 15, 2015, 12:25:12 am »
C:\Users\Kankei\Desktop\Test>g++ main.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status
You didn't tell your linker where to find the libraries. See your command in your first post.

Also when i just run this command:
g++ main.cpp -o sfml-app

I get this:
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0xe5): undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
C:\Users\Kankei\AppData\Local\Temp\cc8WEyC5.o:main.cpp:(.text+0x10b): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
You didn't tell the linker that you want to link any libraries.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #11 on: March 15, 2015, 12:35:19 am »
C:\Users\Kankei\Desktop\Test>g++ main.o -o sfml-app -LC:\Users\Kankei\Desktop\SFML\lib -lsfml-graphics -lsfml-window -lsfml-system
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-window
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsfml-system
collect2.exe: error: ld returned 1 exit status

It's still not happy with me.
I got this configured on code::blocks without any problems.
I may just drop this method all together :/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Re: Compiling with g++ on windows.
« Reply #12 on: March 15, 2015, 12:41:14 am »
What does C:\Users\Kankei\Desktop\SFML\lib contain?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Borat

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Compiling with g++ on windows.
« Reply #13 on: March 15, 2015, 12:43:55 am »
libsfml-audio-s.a
libsfml-graphics-s.a
libsfml-main.a
libsfml-network-s.a
libsfml-system-s.a
libsfml-window-s.a

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Compiling with g++ on windows.
« Reply #14 on: March 15, 2015, 12:59:04 am »
libsfml-xxxx-s.a are for static linking.
Your directory should contain libsfml-xxxx.a (and libsfml-xxxx-d.a for debug).

Unless you want to statically link SFML (it's unclear if you want to or not). In that case you should define SFML_STATIC, link sfml-xxxx-s and also link SFML dependencies.
« Last Edit: March 15, 2015, 01:08:24 am by G. »