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

Author Topic: CSFML static linking & dlls  (Read 8515 times)

0 Members and 2 Guests are viewing this topic.

migf1

  • Newbie
  • *
  • Posts: 6
    • View Profile
CSFML static linking & dlls
« on: December 22, 2013, 02:53:28 am »
Hello everybody, my 1st post here (btw, big thanks for C/SFML).

I've just set up CSFML 2.1 to give it a go, on a vanilla mingw32 toolchain, with gcc 4.7.0 on Win XP SP3...

Code: [Select]
> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/unix/mingw/bin/../libexec/gcc/mingw32/4.7.0/lto-wrapper.e
xe
Target: mingw32
Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-
with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.7.0 (GCC)

No problems, all is fine with the sample code written with notepad++ and compiled via the command line.

But am I supposed to have CSFML's bin folder in the PATH environment variable, even when I'm linking statically? If I don't, the runtime complains it cannot find the CSFML dll's...

Code: [Select]
gcc -g3 -std=c99 -Wall -Wextra -DSFML_STATIC test.c -o test.exe -Ic:/unix/csfml/include -Lc:/unix/csfml/lib/gcc -lcsfml-graphics -lcsfml-audio -lcsfml-window -lcsfml-network -lcsfml-system -Wl,--subsystem,windows

I took a wild guess and also defined -DCSFML_STATIC... did no difference.

Thanks in advance.
« Last Edit: December 22, 2013, 02:59:15 am by migf1 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CSFML static linking & dlls
« Reply #1 on: December 22, 2013, 08:25:37 am »
There's no static version of CSFML.
Laurent Gomila - SFML developer

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: CSFML static linking & dlls
« Reply #2 on: December 22, 2013, 10:15:03 am »
There's no static version of CSFML.

Shouldn't it be theoretically possible though? If you built a static version of csfml and sfml, and then linked all dependencies? Unless I am missing something, in which case I will feel very silly.
DSFML - SFML for the D Programming Language.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CSFML static linking & dlls
« Reply #3 on: December 22, 2013, 03:10:13 pm »
Quote
Shouldn't it be theoretically possible though? If you built a static version of csfml and sfml, and then linked all dependencies? Unless I am missing something, in which case I will feel very silly.
You wouldn't be able to link a static version of CSFML, since it's written in C++. Your C linker would complain about all these crazy C++ symbols that it doesn't know about.

Sorry for making you feel silly ;D
Laurent Gomila - SFML developer

migf1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: CSFML static linking & dlls
« Reply #4 on: December 22, 2013, 04:25:07 pm »
It makes perfect sense, thanks for the rapid responses guys!

Jebbs

  • Sr. Member
  • ****
  • Posts: 358
  • DSFML Developer
    • View Profile
    • Email
Re: CSFML static linking & dlls
« Reply #5 on: December 22, 2013, 06:08:19 pm »
Quote
Shouldn't it be theoretically possible though? If you built a static version of csfml and sfml, and then linked all dependencies? Unless I am missing something, in which case I will feel very silly.
You wouldn't be able to link a static version of CSFML, since it's written in C++. Your C linker would complain about all these crazy C++ symbols that it doesn't know about.

Sorry for making you feel silly ;D

That's ok. :P

I think my view on what will and won't link correctly is skewed because of D. I'm fairly certain that the D compiler would be ok with linking everything statically like how I described.
DSFML - SFML for the D Programming Language.

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: CSFML static linking & dlls
« Reply #6 on: December 23, 2013, 12:46:35 am »
Maybe you could get it to work if you use a C++ linker with your C project?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: CSFML static linking & dlls
« Reply #7 on: December 23, 2013, 08:16:58 am »
Quote
Maybe you could get it to work if you use a C++ linker with your C project?
It would work, yes. In this case it would just be a C++ static lib linked to a C++ program.
Laurent Gomila - SFML developer