Skip to content

Commit f9c2d9d

Browse files
authored
Merge pull request #123 from nataraj-hates-MS-for-stealing-github/main
Fix building with gcc 8.3 (need to link stdc++fs for that) Closes #122
2 parents 660e5cb + d8e2ad9 commit f9c2d9d

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

buildsys/autotools/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ AM_CFLAGS = \
1515

1616
AM_CPPFLAGS = $(AM_CFLAGS)
1717

18-
AM_LDFLAGS = $(SDL_LIBS) $(X11_LIBS) $(ZLIB_LIBS)
18+
AM_LDFLAGS = $(SDL_LIBS) $(X11_LIBS) $(ZLIB_LIBS) $(SYSLIBS)
1919

2020

2121
lib_LTLIBRARIES = libtcod.la

buildsys/autotools/configure.ac

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,30 @@ AC_SUBST([SOVERSION], [m4_esyscmd_s(./get_version.py --so)])
5353

5454
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
5555

56+
# In older versions of gcc implementation of std::filesystem is kept
57+
# in separate stdc++fs library. You should link it explicitly
58+
AC_LANG_SAVE
59+
AC_LANG([C++])
60+
AC_MSG_CHECKING([if std::filesystem requires linking stdc++fs])
61+
AC_LINK_IFELSE(
62+
[AC_LANG_SOURCE([
63+
#include <filesystem>
64+
int main() {
65+
std::filesystem::create_directory("/dev/null");
66+
}
67+
])],
68+
[ac_cv_fs_stdlib=no],
69+
[ac_cv_fs_stdlib=yes]
70+
)
71+
if test "x$ac_cv_fs_stdlib" = xyes; then
72+
AC_MSG_RESULT(yes)
73+
SYSLIBS="$SYSLIBS -lstdc++fs"
74+
else
75+
AC_MSG_RESULT(no)
76+
fi
77+
AC_LANG_RESTORE
78+
79+
AC_SUBST(SYSLIBS)
80+
5681
AC_CONFIG_FILES([Makefile libtcod.pc])
5782
AC_OUTPUT

0 commit comments

Comments
 (0)