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

Author Topic: Problem linking SFML: fatal error: stdlib.h: No such file or directory  (Read 2457 times)

0 Members and 1 Guest are viewing this topic.

zzador

  • Newbie
  • *
  • Posts: 4
    • View Profile
Hello everybody,

I tried to link SFML dynamically (DLLs) in a little test program. I use GCC 8.1.0 64Bit and when I try to compile the following error occurs:

In file included from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ext/string_conversions.h:41,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/basic_string.h:6361,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/string:52,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/locale_classes.h:40,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/ios_base.h:41,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ios:42,
                 from D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/ostream:38,
                 from D:/sourcecode/SFML-2.5.1/include/SFML/System/Err.hpp:32,
                 from D:/sourcecode/SFML-2.5.1/include/SFML/System.hpp:34,
                 from D:/sourcecode/SFML-2.5.1/include/SFML/Audio.hpp:32,
                 from src/main.cpp:1:
D:/GCC64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.


The makefile is:

CC         = g++
OBJ         = bin/main.o
LIB         = -L"D:/sourcecode/SFML-2.5.1/lib"
INCLUDE      = -I"D:/sourcecode/SFML-2.5.1/include"
LIBS      = -lmingw32 -lsmfl-graphics -lsmfl-audio -lsmfl-window -lsmfl-system
OUTPUT      = sfmltest.exe
C_FLAGS      = $(INCLUDE) -march=x86-64 -mtune=corei7-avx -O3 -Wall -static -std=c++11
L_FLAGS      = $(LIBS) -s
RM         = del /q
CPY         = copy

all: $(OUTPUT)

$(OUTPUT): $(OBJ)
   $(CC) -o $(OUTPUT) $(C_FLAGS) $(L_FLAGS) $(OBJ) $(LIB)

bin/main.o : src/main.cpp
   $(CC) $(C_FLAGS) -c -o bin/main.o src/main.cpp

clean:
   del bin\*.o


Can someone help me here?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Have you built SFML yourself?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zzador

  • Newbie
  • *
  • Posts: 4
    • View Profile
No. I used the precompiled binaries.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email


Your compiler doesn't match the one used to compile SFML, so this won't work. You need to rebuild SFML with your compiler. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zzador

  • Newbie
  • *
  • Posts: 4
    • View Profile
Really? How does SDL get it right? Ok, so I have to use cmake to build sfml...well www.cmake.org is down again...as always...how am I supposed to build it now? By hand?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SDL is written in C, and C has a standard ABI which makes a compiled binary compatible with every compiler / linker. C++ on the other hand has no standard ABI and each compiler defines its own "language" when it creates object files from source code, and they don't understand each other.

But I don't think that this is the cause of your problem. Are you able to compile a simple (non-SFML) example that uses stdlib.h? It seems like your environment is broken somehow.
Laurent Gomila - SFML developer

zzador

  • Newbie
  • *
  • Posts: 4
    • View Profile
The fault was really on my side here. Thanks to Laurent for pointing that out. I had two paths on the include-paths-environment-variable messed up and in the wrong order. Now I get the following errors:
bin/main.o:main.cpp:(.text$_ZN2sf4TextD1Ev[_ZN2sf4TextD1Ev]+0x9): undefined reference to `__imp__ZTVN2sf4TextE'
bin/main.o:main.cpp:(.text$_ZN2sf4TextD1Ev[_ZN2sf4TextD1Ev]+0x10): undefined reference to `__imp__ZTVN2sf11VertexArrayE'
bin/main.o:main.cpp:(.text$_ZN2sf4TextD1Ev[_ZN2sf4TextD1Ev]+0x8d): undefined reference to `__imp__ZN2sf13TransformableD2Ev'
bin/main.o:main.cpp:(.text$_ZThn8_N2sf4TextD1Ev[_ZThn8_N2sf4TextD1Ev]+0x9): undefined reference to `__imp__ZTVN2sf4TextE'
bin/main.o:main.cpp:(.text$_ZThn8_N2sf4TextD1Ev[_ZThn8_N2sf4TextD1Ev]+0x10): undefined reference to `__imp__ZTVN2sf11VertexArrayE'
bin/main.o:main.cpp:(.text$_ZThn8_N2sf4TextD1Ev[_ZThn8_N2sf4TextD1Ev]+0x8d): undefined reference to `__imp__ZN2sf13TransformableD2Ev'
bin/main.o:main.cpp:(.text.startup+0x65): undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'
bin/main.o:main.cpp:(.text.startup+0x96): undefined reference to `__imp__ZN2sf9VideoModeC1Ejjj'
bin/main.o:main.cpp:(.text.startup+0xda): undefined reference to `__imp__ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
bin/main.o:main.cpp:(.text.startup+0x109): undefined reference to `__imp__ZN2sf7TextureC1Ev'
bin/main.o:main.cpp:(.text.startup+0x133): undefined reference to `__imp__ZN2sf7Texture12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_4RectIiEE'
bin/main.o:main.cpp:(.text.startup+0x15e): undefined reference to `__imp__ZN2sf7TextureD1Ev'
bin/main.o:main.cpp:(.text.startup+0x167): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
bin/main.o:main.cpp:(.text.startup+0x192): undefined reference to `__imp__ZN2sf6SpriteC1ERKNS_7TextureE'
bin/main.o:main.cpp:(.text.startup+0x19b): undefined reference to `__imp__ZN2sf4FontC1Ev'
bin/main.o:main.cpp:(.text.startup+0x1b6): undefined reference to `__imp__ZN2sf4Font12loadFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
bin/main.o:main.cpp:(.text.startup+0x213): undefined reference to `__imp__ZN2sf4TextC1ERKNS_6StringERKNS_4FontEj'
bin/main.o:main.cpp:(.text.startup+0x242): undefined reference to `__imp__ZN2sf5MusicC1Ev'
bin/main.o:main.cpp:(.text.startup+0x25d): undefined reference to `__imp__ZN2sf5Music12openFromFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
bin/main.o:main.cpp:(.text.startup+0x288): undefined reference to `__imp__ZN2sf5MusicD1Ev'
bin/main.o:main.cpp:(.text.startup+0x297): undefined reference to `__imp__ZTVN2sf6SpriteE'
bin/main.o:main.cpp:(.text.startup+0x2b6): undefined reference to `__imp__ZN2sf4FontD1Ev'
bin/main.o:main.cpp:(.text.startup+0x2c9): undefined reference to `__imp__ZN2sf13TransformableD2Ev'
bin/main.o:main.cpp:(.text.startup+0x2d9): undefined reference to `__imp__ZN2sf11SoundStream4playEv'
bin/main.o:main.cpp:(.text.startup+0x2e0): undefined reference to `__imp__ZN2sf6Window9pollEventERNS_5EventE'
bin/main.o:main.cpp:(.text.startup+0x2e9): undefined reference to `__imp__ZNK2sf6Window6isOpenEv'
bin/main.o:main.cpp:(.text.startup+0x32e): undefined reference to `__imp__ZN2sf5ColorC1Ehhhh'
bin/main.o:main.cpp:(.text.startup+0x33b): undefined reference to `__imp__ZN2sf12RenderTarget5clearERKNS_5ColorE'
bin/main.o:main.cpp:(.text.startup+0x342): undefined reference to `__imp__ZN2sf12RenderStates7DefaultE'
bin/main.o:main.cpp:(.text.startup+0x350): undefined reference to `__imp__ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
bin/main.o:main.cpp:(.text.startup+0x373): undefined reference to `__imp__ZN2sf6Window7displayEv'
bin/main.o:main.cpp:(.text.startup+0x385): undefined reference to `__imp__ZN2sf6Window5closeEv'
bin/main.o:main.cpp:(.text.startup+0x3e4): undefined reference to `__imp__ZTVN2sf6SpriteE'
bin/main.o:main.cpp:(.text.startup+0x40d): undefined reference to `__imp__ZN2sf13TransformableD2Ev'
bin/main.o:main.cpp:(.text.startup+0x416): undefined reference to `__imp__ZN2sf7TextureD1Ev'
bin/main.o:main.cpp:(.text.startup+0x41f): undefined reference to `__imp__ZN2sf12RenderWindowD1Ev'
bin/main.o:main.cpp:(.text.startup+0x433): undefined reference to `__imp__ZN2sf4FontD1Ev'
bin/main.o:main.cpp:(.text.startup+0x45a): undefined reference to `__imp__ZN2sf5MusicD1Ev'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:15: sfmltest.exe] Error 1


I guess it is because I use a newer GCC so I will try to build SFML myself.

 

anything