How to build both C and C++ binaries in the same meson.build file #11788
Unanswered
ericcurtin
asked this question in
Q&A
Replies: 1 comment 2 replies
-
The compiler used for any source file, regardless of whatever other compilers are available in the build context, should always be the correct compiler for that source filetype. So, .cpp files will always be compiled with the CXX compiler, and .c files will always be compiled with the C compiler. The question is which linker to use... meson will try to autodetect the optimal linker to use based on the sources included in that target, but you can also control this with |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I opened this MR:
https://gitlab.com/sdm845-mainline/qbootctl/-/merge_requests/5
which builds a binary with the C++ library included and one without it included, but it uses C++ compilers and linkers for both binaries. The only reason this works is I manually built the C one with a C compiler and when using this build file the C++ library is optimized out when there are no references to it. It would be very easy for C++ to sneak into that binary again without the build failing.
Is there a way of making sure the C binary builds with only a C toolchain? Compiler, linker, etc. And that the C++ builds with a C++ toolchain?
Beta Was this translation helpful? Give feedback.
All reactions