4 ms·
C++ is really becoming easier to use! compiler error: you have to match the flags of that one dependency you're not familiar with and you didn't even compi
by stabbles 3y ago
C++ is really becoming easier to use!
compiler error: you have to match the flags of that one dependency you're not familiar with and you didn't even compile yourself, rookie!
- maccard 3y agoYouve always needed to do this. If you link against a static library that's compiled with -D_GLIBCXX_ASSERTIONS=1 it needs to be defined in your code too. Same for the CRT flags with MSVC
- stabbles 3y agoYou'd hope that modules would make those issues go away, instead of making them worse. Also, CPPFLAGS ensure the shared code in headers is the same, whereas with modules it feels as if you have to manually bring the compiler itself in the right state.
- pjmlp 3y agoNo, it has been the same since compiled languages exist, modules only improve the packaging and type safety story. CPPFLAGS ensures not such thing when using binary libraries.
- gpderetta 3y agoABI-breaking flags break the ABI. There is no way around that. edit: incidentally, _GLIBCXX_ASSERTIONS is not ABI breaking.
- maccard 3y agoTIL!
- senkora 3y agoYou really just have to compile all of your dependencies yourself (or use pre-compiled distro packages and compile your code with the distro toolchain). Of course, compiling everything yourself is the only way to get LTO to work well, and you probably want that.
- chlorion 3y agoYou can use pkg-config for this! I'm not sure if a lot of people are using pkg-config manually but you can do it easily. If you have a pkg-config file for the library it will handle the flags for you. I guess a build system would handle this for you also. Even for "hello world" I've found meson to be useful, and it's only two lines of meson to get "hello world" to compile. I would prefer this to manually compiling by calling "c++ main.c++ -o hello" from the shell.