How to tell a C project to link using a C++ compiler? #13185
-
Hi, Some files to help illustrate what I'm trying to do. a/a.cc#include <iostream>
extern "C" void hello(void) {
std::cout << "Hello World\n";
} a/a.h#ifndef A_H
#define A_H
#ifdef __cplusplus
extern "C" {
#endif
void hello(void);
#ifdef __cplusplus
}
#endif
#endif a/meson.buildproject(
'a',
'cpp',
version: '0.1',
default_options: ['warning_level=3', 'cpp_std=c++14'],
)
pkg = import('pkgconfig')
a = library('a', 'a.cc', 'a.h', install: true)
install_headers('a.h')
pkg.generate(a) b/b.c#include "a.h"
int main() {
hello();
} b/meson.buildproject('b', 'c', version: '0.1', default_options: ['warning_level=3'])
a = dependency('a', version: '>=0.1')
executable('b', 'b.c', install: true, dependencies: [a]) I'm essentially compiling two projects, One is a C++ project that isn't using meson, but generates a .pc file. Both projects are not owned/developed/maintained by me, I'm simply just trying to compile them. "Normally," project In my case, this results in lld being called with For meson, I could not find any equivalent way to set the linker for a Of course, if I had infinite patience and time, I could either modify the meson.build and change tldrTrying to find a way to link a C meson project to a C++ library without specifying |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Try to add --driver-mode=g++ to LDFLAGS? |
Beta Was this translation helpful? Give feedback.
Try to add --driver-mode=g++ to LDFLAGS?