Hello! I’ve been trying to get this library (libcs50) to work in a nix-shell and or flake, problem is the shell doesn’t recognize the library every time I try to compile it with gcc, The result is 2 months of torture ha ha!
(I am at my breaking point hehehehehe)
I’ve tried nix-ld to link the files and it doesn’t work I tried making my own simple shell.nix in order to compile it and it doesn’t work. I eventually resorted to getting a flake development environment, guess what? It also doesn’t work! What is even more odd when I first got into NixOs it worked perfectly well, and then something happened to where it just stopped. The error message that it gives it usually to this effect:
/nix/store/2p1sq1nr09xr3xb1a9lrjgdanvk1aakb-binutils-2.42/bin/ld:
/tmp/nix-shell.m1ou1c/cctXhvMD.o: in function `main': debug.c: (.text.startup+0xd):
undefined reference to `get_string`
/nix/store/2p1sq1nr09xr3xb1a9lrjgdanvk1aakb-binutils-2.42/bin/ld:
debug.c: (.text.startup+0x20): undefined reference to `get_string$
And here’s my flake:
{
description = "A Nix-flake-based C/C++ development environment";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell.override
{
# Override stdenv in order to change compiler:
# stdenv = pkgs.clangStdenv;
}
{
packages = with pkgs; [
clang-tools
cmake
codespell
conan
cppcheck
doxygen
gtest
lcov
vcpkg
vcpkg-tool
] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
};
});
};
}
I hope you guys can help me out on this because it’s been miserable trying to get this to work! Thanks in advance.