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

Author Topic: SFML static build: Unresolved externals from sf::priv namespace  (Read 2501 times)

0 Members and 1 Guest are viewing this topic.

LeksiDor

  • Newbie
  • *
  • Posts: 5
    • View Profile
SFML static build: Unresolved externals from sf::priv namespace
« on: February 16, 2020, 10:18:27 pm »
Hello!
I've managed to clone SFML git repo, then build with CMake and compile together with examples. All examples are working, no errors were detected. Then, I wrote a simple HelloWorld project using locally-built SFML lib, but when I compile it, I get 10 unresolved externals. All of them refer to system-specific functions implemented in sf::priv namespace. Could you help me to fix it? I have no clues what's wrong...

My environment: Windows 10, CMake 3.14.1, MSVC 16 2019.
My folder structure:
    * cloned SFML project: D:\Work\SFML ;
    * HelloWorld project: D:\Work\TestSFML ;
    * content of TestSFML folder: CMakeLists.txt, Initialize3rdparty.sh (copies SFML lib and headers), src\HelloWorld\main.cpp .

CMakeLists.txt:
(click to show/hide)

Initialize3rdparty.sh:
(click to show/hide)

src\HelloWorld\main.cpp:
(click to show/hide)

MSVC build output:
(click to show/hide)

Thanks!
« Last Edit: February 16, 2020, 10:56:00 pm by LeksiDor »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #1 on: February 17, 2020, 08:38:59 am »
That's not how you're supposed to use SFML with CMake. See this topic: https://en.sfml-dev.org/forums/index.php?topic=24070.0
Laurent Gomila - SFML developer

LeksiDor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #2 on: February 17, 2020, 10:27:34 am »
Ok, I have downloaded SFML binaries (2.5.1 x64 VC15), and changed CMakeLists.txt correspondingly. Now everything works.

That's my new CMakeListst.txt:
(click to show/hide)

However, how can I use SFML lib that is built from currrent git repo?

Also, how can I have Debug and Release versions of SFML for my HelloWorld Debug and Release builds correspondingly?

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #3 on: February 17, 2020, 10:38:02 am »
Quote
However, how can I use SFML lib that is built from currrent git repo?
The exact same way. Once you've built the "install" target, you have a SFML folder that is similar to the official releases.

Quote
Also, how can I have Debug and Release versions of SFML for my HelloWorld Debug and Release builds correspondingly?
That's handled by the SFML config file automatically, you don't have to care about it.
Laurent Gomila - SFML developer

LeksiDor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #4 on: February 17, 2020, 09:25:37 pm »
I've modified CMakeLists.txt in my HelloWorld project once again, and that's how it looks now:
(click to show/hide)

Value SFML_DIR now points to locally built Git repo.
But CMake refuses to build HelloWorld project, and shows this output:
(click to show/hide)

Any guesses what should I change now?

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #5 on: February 18, 2020, 07:57:03 am »
Can you describe what you did (how you built SFML) in detail?
Laurent Gomila - SFML developer

LeksiDor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #6 on: February 18, 2020, 08:53:40 am »
1. Open Git bash in "D:\Work". Run "git clone https://github.com/SFML/SFML.git".
2. Open CMake GUI and run with parameters as on screenshot (see "cmake.png" attached).
3. Open MSVC solution. Compile all, in both Debug and Release.
4. Run examples. Everything is fine.
5. Create folder "D:\Work\TestSFML". It now contains "TestSFML\CMakeLists.txt" and "TestSFML\src\HelloWorld\main.cpp".
6. Run CMake with Source "D:\Work\TestSFML" and Build "D:\Work\TestSFML\build", and get mentioned errors.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #7 on: February 18, 2020, 12:13:20 pm »
So you didn't compile the INSTALL target?

Quote from: Laurent
Once you've built the "install" target, you have a SFML folder that is similar to the official releases.
Laurent Gomila - SFML developer

LeksiDor

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #8 on: February 18, 2020, 12:35:56 pm »
I've just ran INSTALL, and then copied resulting SFML folder in "C:\Program Files (x86)\SFML" to the proper location in my HelloWorld. Then, run CMake, and got the same CMake errors ("dependencies are missing").

Then, I just manually copied missing libs (flac.lib, freetype.lib, ogg.lib, openal32.lib, vorbis.lib, vorbisenc.lib, vorbisfile.lib), and put them in "SFML\lib" folder.

Now everything works.

Thank you very much for time and effort!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML static build: Unresolved externals from sf::priv namespace
« Reply #9 on: February 18, 2020, 01:09:45 pm »
You correctly changed SFML_DIR to point to the install folder instead of the build folder, right?

You shouldn't have to copy anything manually, as I said, the INSTALL target produces a release similar to what you can download on the website and thus should work out of the box.
Laurent Gomila - SFML developer

 

anything