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

Author Topic: Compiling GCC into the exe  (Read 3533 times)

0 Members and 1 Guest are viewing this topic.

Asimov

  • Newbie
  • *
  • Posts: 13
    • View Profile
Compiling GCC into the exe
« on: August 01, 2024, 01:23:36 pm »
Hi all,
I am having a problem. Basically if I try to run the exe on another computer I get the libgcc_s_dw2-1.dll not found error. Which is strange because I am running hte 64 bit version of SFML and I am sure that should be the seh lib. I am using code::blocks.

 I compiled SFML from source. I compiled it 4 times. For debug and release, and the I compiled it with the Build Shared libs unticked, so I could link SFML statically.

In Code::blocks I am setting the flags
-static-libstdc++
-static-libgcc
-static

In other compiler options. I have even gone into global compiler settings and ticked the static libraries there too. I have done my research before posting. I read a pile of posts on this forum, and on stackoverflow and tried everything I have found, to no avail.


I even tried adding SFML_STATIC to #defines as well.

I have been trying to get this to work for 3 days without getting it to work, and now I thought I would ask the question.

Asimov

Asimov

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Compiling GCC into the exe
« Reply #1 on: August 02, 2024, 04:23:03 pm »
I have had another go at compiling from source. This time I unticked BUILD_SHAREd_LIBS and ticked SFML_USE_STATIC_STD_LIBS. I copied them to the libs folder and compiled my program. However after copying the exe to another computer it still complains that the libgcc_s_dw2-1.dll is missing.

I am pulling my hair out over this. Can anyone help. I am attaching a screenshot of my cmake settings.

Asimov

Asimov

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Compiling GCC into the exe
« Reply #2 on: August 02, 2024, 10:07:09 pm »
Ok I have read a bit more of the documentation and it said if i want to make a static exe i have to add the static version of the libraries eg.
sfml-graphics-s
sfml-window-s
sfml-audio-s
sfml-network-s
sfml-system-s

Seeing as I compile these as static from source it should work, however when I do this I get a pile of errors.
Lots of undefined reference errors. See attachment.

Asimov

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: Compiling GCC into the exe
« Reply #3 on: August 03, 2024, 07:24:45 am »
These linking errors are because you aren't linking to SFML's dependencies (which as requires when linking statically).

If you link to sfml-graphics-s then you also need to add the following libraries to the linker (you don't need to tell codeblocks where to find them as those are system libraries):
Code: [Select]
opengl32
freetype
winmm
gdi32

If you are going to link to sfml-network-s and sfml-audio-s (which is only needed when you need these modules), then you need to add even more libraries, see the list in https://www.sfml-dev.org/tutorials/2.6/start-cb.php
TGUI: C++ SFML GUI

Asimov

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Compiling GCC into the exe
« Reply #4 on: August 03, 2024, 01:11:12 pm »
Hi Texus,

Thanks I think you have solved my problem. Because I didn't want to complicate it, I removed audio-s and network-s seeing as I didn't need them for this project, which is basically the standard circle which I am using for testing. So this is what libraries I used.

sfml-graphics-s
sfml-window-s
sfml-system-s
opengl32
winmm
gdi32

I did add freetype, but when I tried to compile it said that it couldn't find freetype. Is this something I have to install? Anyway I removed freetype and it compiled ok.
So I tried it on my test pc in virtualbox and a black window came up complaining about hardware rendering, but other than that it worked. I wonder if there is a way to surpress that black console window from opening.

For my debug I am sticking with shared libraries. I only need static libraries for Release.
How do I mark this as solved?

Asimov