conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.26k stars 981 forks source link

[question] Compile with `_GLIBCXX_DEBUG` #12618

Open Btlmd opened 1 year ago

Btlmd commented 1 year ago

Hello, I'm trying to debug a project and attempt to use preprocessor macro _GLIBCXX_DEBUG to assist the debug. This requires all packages to be compiled with this macro, or a link error will occur.

However, I don't know how I can get the required packages compiled with this macro. Is it possible to get the packages in conanfile compiled with custom macros?

canonfile.txt

[requires]
boost/1.80.0
antlr4-cppruntime/4.9.3
fmt/9.1.0
gtest/1.10.0
magic_enum/0.8.1
tabulate/1.4

[generators]
cmake

with profile

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
build_type=Debug
[options]
[build_requires]
[env]
CXXFLAGS=-D_GLIBCXX_DEBUG

This profile is not working, and cannot get the required packages compiled with _GLIBCXX_DEBUG, and when I enabled this macro in CMake, the link error occurs

/usr/bin/ld: CMakeFiles/main.dir/parser/SQLParser.cpp.o: in function `SQLParser::SQLParser(antlr4::TokenStream*)':
.../parser/SQLParser.cpp:14: undefined reference to `antlr4::atn::ParserATNSimulator::ParserATNSimulator(antlr4::Parser*, antlr4::atn::ATN const&, std::__debug::vector<antlr4::dfa::DFA, std::allocator<antlr4::dfa::DFA> >&, std::__debug::unordered_set<std::shared_ptr<antlr4::atn::PredictionContext>, antlr4::atn::PredictionContextHasher, antlr4::atn::PredictionContextComparer, std::allocator<std::shared_ptr<antlr4::atn::PredictionContext> > >&)'
fanselm commented 1 year ago

Second this. Also in need of this option.

I think it should be a compiler setting just like runtime_type for MSVC. Then just like the compiler.libcxx setting defines _GLIBCXX_USE_CXX11_ABI in the build helpers, it should similarly define _GLIBCXX_DEBUG.

SoShiny commented 1 year ago

I third this. What is the current approach to deal with this?