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

Author Topic: linker cannot find dlls  (Read 1569 times)

0 Members and 1 Guest are viewing this topic.

ThatGodDamnSemicolon

  • Newbie
  • *
  • Posts: 1
    • View Profile
linker cannot find dlls
« on: June 05, 2024, 04:14:33 pm »
Hi,

I have a problem with sfml while compiling.

I installed:
-VS Code
-VS Code Extension: C/C++
-g++, gpp and gdb
-msys
-SFML 2.6.1

A normal 'hello_world.cpp' compiles and runs fine, no errors, everything as expected.

But now I want to execute test code from sfml tutorial (code from https://www.sfml-dev.org/tutorials/2.6/start-vc.php).

My MakeFile is this:

all: compile link

compile:
        g++ -Isrc/include -c coding/*.cpp

link:
        g++ *.o -o main -Lsrc\lib -lsfml-graphics-2 -lsfml-window-2 -lsfml-system-2 -lopenal32 -lsfml-audio-2
 

This is the terminal output/error:
g++ -Isrc/include -c coding/*.cpp
g++ *.o -o main -Lsrc\lib -lsfml-graphics-2 -lsfml-window-2 -lsfml-system-2 -lopenal32 -lsfml-audio-2
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-graphics-2: No such file or directory
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-window-2: No such file or directory
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-system-2: No such file or directory
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src\lib/libopenal32.a when searching for -lopenal32
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src\lib\libopenal32.a when searching for -lopenal32
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src\lib/libopenal32.a when searching for -lopenal32
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lopenal32: No such file or directory
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible src\lib/libopenal32.a when searching for -lopenal32
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lsfml-audio-2: No such file or directory
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [MakeFile:7: link] Error 1
 

The main.o is created, but no .exe.

Pic of repo structure is in attachments.

I would be very thankful to any kind of help. I saw a lot of similar issues while googleing the problem, but not really any solution. Thanks!

« Last Edit: June 05, 2024, 07:49:50 pm by ThatGodDamnSemicolon »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: linker cannot find dlls
« Reply #1 on: June 06, 2024, 06:11:16 pm »
The import libraries (*.a files) don't have a -2 suffix. Check the files in src/lib
Since you're dynamically linking SFML, you don't have to link OpenAL separately.

So it should be:
g++ *.o -o main -Lsrc\lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio

The DLLs come into play, once you ant to start your application. Then they need to be next to your executable.

We highly recommend to use the SFML CMake Template. VS Code has a great CMake extension. Then you don't have to worry about linking and build SFML, but it's automatically done for you.

https://github.com/SFML/cmake-sfml-project
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything