Add a testcase for linking C and C++ static archives into a shared library

This exercises a regression where the C rather than C++ linker is
chosen, resulting in symbol errors.

Test for #1653
pull/1654/head
Dylan Baker 8 years ago
parent 407130a1d2
commit af9d1f8f15
  1. 19
      test cases/common/146 C and CPP link/foo.c
  2. 24
      test cases/common/146 C and CPP link/foo.cpp
  3. 16
      test cases/common/146 C and CPP link/foo.h
  4. 24
      test cases/common/146 C and CPP link/foo.hpp
  5. 23
      test cases/common/146 C and CPP link/foobar.c
  6. 16
      test cases/common/146 C and CPP link/foobar.h
  7. 28
      test cases/common/146 C and CPP link/meson.build

@ -0,0 +1,19 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "foo.h"
int forty_two(void) {
return 42;
}

@ -0,0 +1,24 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vector>
#include <boost/assign/list_of.hpp>
namespace {
std::vector<int> numbers = boost::assign::list_of(61);
}
extern "C" int six_one(void) {
return numbers[1];
}

@ -0,0 +1,16 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
int forty_two(void);

@ -0,0 +1,24 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __cplusplus
extern "C" {
#endif
int six_one(void);
#ifdef __cplusplus
}
#endif

@ -0,0 +1,23 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "foo.h"
#include "foo.hpp"
#include "foobar.h"
void mynumbers(int nums[]) {
nums[0] = forty_two();
nums[1] = six_one();
}

@ -0,0 +1,16 @@
/* Copyright © 2017 Dylan Baker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
void mynumbers(int nums[]);

@ -0,0 +1,28 @@
# Copyright © 2017 Dylan Baker
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project('C and C++ static link test', ['c', 'cpp'],
default_options : ['cpp_std=c++03'])
dep_boost = dependency('boost')
libcppfoo = static_library('cppfoo', ['foo.cpp', 'foo.hpp'],
dependencies : dep_boost)
libcfoo = static_library('cfoo', ['foo.c', 'foo.h'])
libfoo = shared_library(
'foo',
['foobar.c', 'foobar.h'],
link_with : [libcfoo, libcppfoo],
)
Loading…
Cancel
Save