Skip to content

undefined reference to `__stack_chk_fail' #382

@camielverdult

Description

@camielverdult

This still seems to happen for the winlibs mingw compiler (GCC 12.2.0 + LLVM/Clang/LLD/LLDB 14.0.6 + MinGW-w64 10.0.0 (UCRT) - release 2)

cmd.exe /C "cd . && C:\Users\cverdult\mingw64\bin\c++.exe -g  CMakeFiles/cheese.dir/main.cpp.obj CMakeFiles/cheese.dir/src/dataset.cpp.obj CMakeFiles/cheese.dir/src/cheese_maker.cpp.obj CMakeFiles/cheese.dir/src/helpers.cpp.obj CMakeFiles/cheese.dir/src/cheese_eater.cpp.obj -o cheese.exe -Wl,--out-implib,libcheese.dll.a -Wl,--major-image-version,0,--minor-image-version,0  _deps/sqlitecpp-build/libSQLiteCpp.a  _deps/fmt-build/libfmtd.a  _deps/csv-build/include/internal/libcsv.a  --coverage  _deps/sqlitecpp-build/sqlite3/libsqlite3.a  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj): in function `SQLite::Database::execAndGet(char const*)':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Database.cpp:129: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj): in function `SQLite::Database::tableExists(char const*) const':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Database.cpp:138: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj): in function `SQLite::Database::isUnencrypted(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Database.cpp:287: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj): in function `SQLite::Database::getHeaderInfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Database.cpp:421: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj): in function `SQLite::Database::backup(char const*, SQLite::Database::BackupType)':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Database.cpp:437: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Database.cpp.obj):Database.cpp:(.rdata$.refptr.__stack_chk_guard[.refptr.__stack_chk_guard]+0x0): undefined reference to `__stack_chk_guard'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/libSQLiteCpp.a(Statement.cpp.obj): in function `SQLite::Statement::getColumnIndex(char const*) const':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/src/Statement.cpp:289: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/sqlite3/libsqlite3.a(sqlite3.c.obj): in function `datetimeFunc':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/sqlite3/sqlite3.c:24317: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/sqlite3/libsqlite3.a(sqlite3.c.obj): in function `timeFunc':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/sqlite3/sqlite3.c:24346: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/sqlite3/libsqlite3.a(sqlite3.c.obj): in function `dateFunc':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/sqlite3/sqlite3.c:24383: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/sqlite3/libsqlite3.a(sqlite3.c.obj): in function `sqlite3_str_vappendf':
C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/sqlite3/sqlite3.c:30563: undefined reference to `__stack_chk_fail'
c:/users/cverdult/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: _deps/sqlitecpp-build/sqlite3/libsqlite3.a(sqlite3.c.obj):C:/Users/cverdult/Documents/cheese/cmake-build-debug/_deps/sqlitecpp-src/sqlite3/sqlite3.c:30861: more undefined references to `__stack_chk_fail' follow

Sqlite is downloaded and linked as following:

FetchContent_Declare(
        SQLiteCpp
        GIT_REPOSITORY      https://github.com/SRombauts/SQLiteCpp.git
        GIT_TAG             master
)

FetchContent_MakeAvailable(SQLiteCpp)

add_executable(
        cheese
        main.cpp
        src/dataset.cpp
        src/cheese_maker.cpp
        src/helpers.cpp
        src/cheese_eater.cpp

        include/constants.hpp
        include/dataset.hpp
        include/cheese_maker.hpp
        include/helpers.hpp
        include/cheese_eater.hpp
)

target_link_libraries(
        cheese 
        PRIVATE
        SQLiteCpp
)

target_compile_features(cheese PRIVATE cxx_std_20)

This is very similiar to #74

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions