Skip to content

Cannot build stb_image when spdlog is imported from the precompiled header #1432

Answered by mmozeiko
OverShifted asked this question in Q&A
Discussion options

You must be logged in to vote

The problem comes from fmt library that is bundled with spdlog: https://github.com/fmtlib/fmt/blob/master/include/fmt/core.h#L287
This line enables optimization - so any code included afterwards will work as if __OPTIMIZE__ define is set. This makes your precompiled header be created with __OPTIMIZE__ define. Even for "debug" builds. But when you compile actual code then optimizations are not enabled and _mm_slli_si128 intrinsic will not be able to work (no inlining) as it is defined as inline function when __OPTIMIZE__ is enabled.

Kind of related gcc bug here: https://gcc.gnu.org/bugzilla//show_bug.cgi?id=105120

One workaround would be to put #define FMT_GCC_PRAGMA(...) inside your pch.h…

Replies: 4 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@OverShifted
Comment options

Comment options

You must be logged in to vote
2 replies
@OverShifted
Comment options

@nothings
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@OverShifted
Comment options

@OverShifted
Comment options

@mmozeiko
Comment options

@OverShifted
Comment options

Answer selected by OverShifted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants