I have a Vulkan Engine I'm working on. I plan to eventually make a game with it, so I've a graphics engine part compile into a .so file from object files and then I link the final application with the graphics engine library. I'm using a makefile that I recently ported from Windows to Linux (Nobara, a fork of Fedora). The failed command is
g++ app/obj/main.o -obin/NuclearLaunchActivator.bin -Lbin -lGraphicsEngine.so
/usr/bin/ld: cannot find -lGraphicsEngine.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:63: bin/NuclearLaunchActivator.bin] Error 1
If i run it with -v I get this:
g++ app/obj/main.o -obin/NuclearLaunchActivator.bin -L/home/user/documents/vulkan-engine-main/bin -lGraphicsEngine.so -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-14.2.1-20240912/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.1 20240912 (Red Hat 14.2.1-3) (GCC)
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/14/:/usr/libexec/gcc/x86_64-redhat-linux/14/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/14/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/14/:/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/14/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'bin/NuclearLaunchActivator.bin' '-L/home/user/documents/vulkan-engine-main/bin' '-v' '-foffload-options=-l_GCC_m' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'bin/NuclearLaunchActivator.bin.'
/usr/libexec/gcc/x86_64-redhat-linux/14/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/14/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper -plugin-opt=-fresolution=/tmp/ccsn7e7s.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o bin/NuclearLaunchActivator.bin /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/14/crtbegin.o -L/home/user/documents/vulkan-engine-main/bin -L/usr/lib/gcc/x86_64-redhat-linux/14 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/14/../../.. app/obj/main.o -lGraphicsEngine.so -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-redhat-linux/14/crtend.o /usr/lib/gcc/x86_64-redhat-linux/14/../../../../lib64/crtn.o
/usr/bin/ld: cannot find -lGraphicsEngine.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:63: bin/NuclearLaunchActivator.bin] Error 1
I don't know what any of this means.
I've tried replacing the -Lbin
with -L/home/documents/vulkan_engine_main/bin
and -L./bin
. This still returns the same error.
The full sequence of commands is this:
g++ -O0 -Wall -std=c++20 -c app/src/main.cpp -Iapp/header -IgraphicsEngine/header -oapp/obj/main.o
g++ -O0 -Wall -std=c++20 -c -fPIC graphicsEngine/src/graphics_engine.cpp -IgraphicsEngine/header -ographicsEngine/obj/graphics_engine.o
g++ graphicsEngine/obj/graphics_engine.o -obin/GraphicsEngine.so -shared -lglfw -lvulkan
g++ app/obj/main.o -obin/NuclearLaunchActivator.bin -Lbin -lGraphicsEngine
/usr/bin/ld: cannot find -lGraphicsEngine: No such file or directory collect2: error: ld returned 1 exit status
make: *** [Makefile:63: bin/NuclearLaunchActivator.bin] Error 1
-lGraphicsEngine
looks for either of files libGraphicsEngine.so
or libGraphicsEngine.a
but the previous command outputs into bin/GraphicsEngine.so
.
You can apply any of two solutions:
-obin/libGraphicsEngine.so
.-Lbin -lGraphicsEngine
with bin/libGraphicsEngine.so
.