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

Author Topic: sfml-static linking  (Read 1842 times)

0 Members and 1 Guest are viewing this topic.

C_Worm

  • Newbie
  • *
  • Posts: 18
    • View Profile
sfml-static linking
« on: July 30, 2019, 01:20:00 pm »
hey im getting a few unrseolved externals but i don't know how to resolve them! :)

here's my build.bat:

Code: [Select]
@echo off

REM set Windows_Libs = user32.lib gdi32.lib winmm.lib opengl32.lib ws2_32.lib
REM set SFML_Libs = sfml-graphics-s.lib sfml-window-s.lib sfml-audio-s.lib sfml-network-s.lib sfml-system-s.lib
REM set CompilerFlags = -Zi

If NOT EXIST ..\build mkdir build

pushd ..\build

cl /MD /EHsc -Zi /I ..\include ..\src\CJsfml_001.cpp user32.lib gdi32.lib winmm.lib opengl32.lib ws2_32.lib /link /LIBPATH:..\lib freetype.lib openal32.lib flac.lib vorbisenc.lib vorbisfile.lib vorbis.lib ogg.lib sfml-system-s.lib sfml-graphics-s.lib sfml-window-s.lib sfml-audio-s.lib sfml-network-s.lib

popd

and here are the unresolved externals:

Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27025.1 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

CJsfml_001.cpp
Microsoft (R) Incremental Linker Version 14.16.27025.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:CJsfml_001.exe
/debug
/LIBPATH:..\lib
freetype.lib
openal32.lib
flac.lib
vorbisenc.lib
vorbisfile.lib
vorbis.lib
ogg.lib
sfml-system-s.lib
sfml-graphics-s.lib
sfml-window-s.lib
sfml-audio-s.lib
sfml-network-s.lib
CJsfml_001.obj
user32.lib
gdi32.lib
winmm.lib
opengl32.lib
ws2_32.lib
sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "class sf::String __cdecl `anonymous namespace'::getDeviceName(unsigned int,struct tagJOYCAPSW)" (?getDeviceName@?A0x8939b4a8@@YA?AVString@sf@@IUtagJOYCAPSW@@@Z)
sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExW@20 referenced in function "class sf::String __cdecl `anonymous namespace'::getDeviceName(unsigned int,struct tagJOYCAPSW)" (?getDeviceName@?A0x8939b4a8@@YA?AVString@sf@@IUtagJOYCAPSW@@@Z)
sfml-window-s.lib(JoystickImpl.cpp.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExW@24 referenced in function "class sf::String __cdecl `anonymous namespace'::getDeviceName(unsigned int,struct tagJOYCAPSW)" (?getDeviceName@?A0x8939b4a8@@YA?AVString@sf@@IUtagJOYCAPSW@@@Z)
CJsfml_001.exe : fatal error LNK1120: 3 unresolved externals
 

here's the file im compiling, its just taken from the sfml tutorial page:

#define SFML_STATIC

#include "SFML\Graphics.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

 

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: sfml-static linking
« Reply #1 on: July 30, 2019, 02:26:32 pm »
Googling the error finds multiple posts of eXpl0it3r telling people they are missing user32.lib and advapi32.lib, both are usually inherited from project settings.
I see you already have User32, and regclosekey is from advapi32, so add advapi32.lib too :p

C_Worm

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: sfml-static linking
« Reply #2 on: July 30, 2019, 04:57:03 pm »
Allright it worked thanks!

btw i have another problem when i try to bundle the link libraries.
It works for the standard windows LIBS and the LIBS included with sfml (the freetype/vorbis etc..) but not the actual sfml libraries (sfml-graphics-s.lib etc....).

any idea?
heres my batch file which works FINE:

Code: [Select]
@echo off

REM set CompilerFlags = -Zi

SET winLibs = user32.lib gdi32.lib winmm.lib opengl32.lib ws2_32.lib advapi32.lib
SET sfmlDependLibs = /LIBPATH:..\lib freetype.lib openal32.lib flac.lib vorbisenc.lib vorbisfile.lib vorbis.lib ogg.lib

If NOT EXIST ..\build mkdir build

pushd ..\build

cl /MD /EHsc -Zi -nologo /I ..\include ..\src\CJsfml_001.cpp %winLibs% /link /LIBPATH:..\lib %sfmlDependLibs% sfml-system-s.lib sfml-graphics-s.lib sfml-window-s.lib sfml-audio-s.lib sfml-network-s.lib


popd


del *.~ *.cpp~ *.bat~ *.un~


this one, however (when i try to bundle the sfml-graphics-s.lib etc in the sfmlStaticRelLib variable), DOES NOT work:

Code: [Select]
@echo off

REM set CompilerFlags = -Zi

SET winLibs = user32.lib gdi32.lib winmm.lib opengl32.lib ws2_32.lib advapi32.lib
SET sfmlDependLibs = /LIBPATH:..\lib freetype.lib openal32.lib flac.lib vorbisenc.lib vorbisfile.lib vorbis.lib ogg.lib
SET sfmlStaticRelLibs = /LIBPATH:..\lib sfml-system-s.lib sfml-graphics-s.lib sfml-window-s.lib sfml-audio-s.lib sfml-network-s.lib

If NOT EXIST ..\build mkdir build

pushd ..\build

cl /MD /EHsc -Zi -nologo /I ..\include ..\src\CJsfml_001.cpp %winLibs% /link /LIBPATH:..\lib %sfmlDependLibs% %sfmlStaticRelLibs%

popd


del *.~ *.cpp~ *.bat~ *.un~