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

Author Topic: Link Errors moving from 2.6 to 3.0  (Read 340 times)

0 Members and 1 Guest are viewing this topic.

Reicha7

  • Newbie
  • *
  • Posts: 3
    • View Profile
Link Errors moving from 2.6 to 3.0
« on: January 21, 2025, 02:36:25 am »
Hello,

So I will preface this but saying that whilst I know my way around C++ I have never had to do much project setup in work environments so I wanted to use this project as an opportunity to learn.

I was making a simple SFML app with a couple of different projects making up the solution. There is a Vendor project which, in theory, builds all the 3rd party stuff I download into a static library. I have my own Core project which links Vendor and also builds as a static library. Finally I have my App project which builds as a Console App.

I have been using Premake to get all this set up (as I find the Lua a bit easier to work with than CMake) and had it comfortably linking with the non-static SFML libs (downloaded from the website rather than self-built) so it could build the app exe no problem and I just had to include the SFML dlls with it.

I've now decided to try upgrading to 3.0 and building SFML myself to get at least a little familiar with CMake. Building the libraries all seemed good and it spit out all the static debug library files I needed (although for the non-sfml libs like FLAC it added a "d" to them so I just created a separate folder for "shared" libs and downloaded them from the site separately).

I hook up my project to point at my new libs and include locations and both my Vendor and Core static libraries build fine but as soon as I attempt to build the app (which should automatically include the dependencies of Core which includes those of Vendor) I get linker errors.

This probably isn't anything SFML-specific and is just me failing to understand something I probably should know by now but figured I'd ask for advice here.

Included a link with some images: https://imgur.com/a/sfml-3-0-error-4CyR2YF and can provide more info if needed.

Cheers :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: Link Errors moving from 2.6 to 3.0
« Reply #1 on: January 21, 2025, 09:20:05 am »
You need to defined SFML_STATIC in all the projects that use the SFML headers, otherwise the export macro will mark the SFML symbols as DLL export.

I don't remember how VS handles project references in C++, your setup may not work, as all static libs need to be linked in the final binary directly.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Reicha7

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Link Errors moving from 2.6 to 3.0
« Reply #2 on: January 21, 2025, 12:03:14 pm »
Yeah I was doing some reading and it does seem that my understanding of "daisy-chaining" static libs doesn't work how I thought.

It is kind of odd that it did seem to work before. I could reference my "Vendor" project in the my app and it was fine which suggested the Core lib was chaining the Vendor lib.

I'll try out your suggestion for the preprocessor macro stuff tonight.

Reicha7

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Link Errors moving from 2.6 to 3.0
« Reply #3 on: January 21, 2025, 10:47:14 pm »
Yeah adding SFML static pre-processor to each project setup seems to have fixed it all :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: Link Errors moving from 2.6 to 3.0
« Reply #4 on: January 21, 2025, 11:07:08 pm »
🥳
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything