Trying to make an sfml project with cpp but having trouble compiling.
Am using this shell.nix:
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
mkShell rec {
nativeBuildInputs = [
gcc
];
buildInputs = [
sfml
];
}
Here is my main.cpp
from following https://www.sfml-dev.org/tutorials/3.0/window/window/
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode({800, 600}), "My window");
return 0;
}
After running g++ main.cpp
I get these errors:
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: /tmp/ccPqpHTk.o: in function `main':
main.cpp:(.text.startup+0x61): undefined reference to `sf::String::String(char const*, std::locale const&)'
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: main.cpp:(.text.startup+0x7c): undefined reference to `sf::VideoMode::VideoMode(sf::Vector2<unsigned int>, unsigned int)'
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: main.cpp:(.text.startup+0xb0): undefined reference to `sf::Window::Window(sf::VideoMode, sf::String const&, unsigned int, sf::State, sf::ContextSettings const&)'
/nix/store/v63bxfiacw082c7ijshf60alvvrpfxsq-binutils-2.44/bin/ld: main.cpp:(.text.startup+0xca): undefined reference to `sf::Window::~Window()'
collect2: error: ld returned 1 exit status
Not sure what I’m doing wrong.
I found this post: https://discourse.nixos.org/t/install-sfml-in-nixos/8298 which simply instructs to use sfml and not system packages.
I found this; https://discourse.nixos.org/t/cant-link-sfml-dynamically-on-nixos-only-a-files-available/65618 which seems to be the same problem but with no responses.
Thanks in advance for your help