summaryrefslogtreecommitdiffstats
path: root/test cases/common/6 linkshared
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/common/6 linkshared')
-rw-r--r--test cases/common/6 linkshared/cpplib.cpp6
-rw-r--r--test cases/common/6 linkshared/cpplib.h12
-rw-r--r--test cases/common/6 linkshared/cppmain.cpp5
-rw-r--r--test cases/common/6 linkshared/libfile.c14
-rw-r--r--test cases/common/6 linkshared/main.c11
-rw-r--r--test cases/common/6 linkshared/meson.build12
-rw-r--r--test cases/common/6 linkshared/test.json6
7 files changed, 66 insertions, 0 deletions
diff --git a/test cases/common/6 linkshared/cpplib.cpp b/test cases/common/6 linkshared/cpplib.cpp
new file mode 100644
index 0000000..247f820
--- /dev/null
+++ b/test cases/common/6 linkshared/cpplib.cpp
@@ -0,0 +1,6 @@
+#define BUILDING_DLL
+#include "cpplib.h"
+
+int DLL_PUBLIC cppfunc(void) {
+ return 42;
+}
diff --git a/test cases/common/6 linkshared/cpplib.h b/test cases/common/6 linkshared/cpplib.h
new file mode 100644
index 0000000..e2b0206
--- /dev/null
+++ b/test cases/common/6 linkshared/cpplib.h
@@ -0,0 +1,12 @@
+/* See http://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support */
+#if defined(_WIN32) || defined(__CYGWIN__)
+ #ifdef BUILDING_DLL
+ #define DLL_PUBLIC __declspec(dllexport)
+ #else
+ #define DLL_PUBLIC __declspec(dllimport)
+ #endif
+#else
+ #define DLL_PUBLIC __attribute__ ((visibility ("default")))
+#endif
+
+int DLL_PUBLIC cppfunc(void);
diff --git a/test cases/common/6 linkshared/cppmain.cpp b/test cases/common/6 linkshared/cppmain.cpp
new file mode 100644
index 0000000..29e9a44
--- /dev/null
+++ b/test cases/common/6 linkshared/cppmain.cpp
@@ -0,0 +1,5 @@
+#include "cpplib.h"
+
+int main(void) {
+ return cppfunc() != 42;
+}
diff --git a/test cases/common/6 linkshared/libfile.c b/test cases/common/6 linkshared/libfile.c
new file mode 100644
index 0000000..91489b2
--- /dev/null
+++ b/test cases/common/6 linkshared/libfile.c
@@ -0,0 +1,14 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_PUBLIC __declspec(dllexport)
+#else
+ #if defined __GNUC__
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
+ #else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define DLL_PUBLIC
+ #endif
+#endif
+
+int DLL_PUBLIC func(void) {
+ return 0;
+}
diff --git a/test cases/common/6 linkshared/main.c b/test cases/common/6 linkshared/main.c
new file mode 100644
index 0000000..7777327
--- /dev/null
+++ b/test cases/common/6 linkshared/main.c
@@ -0,0 +1,11 @@
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_IMPORT __declspec(dllimport)
+#else
+ #define DLL_IMPORT
+#endif
+
+int DLL_IMPORT func(void);
+
+int main(void) {
+ return func();
+}
diff --git a/test cases/common/6 linkshared/meson.build b/test cases/common/6 linkshared/meson.build
new file mode 100644
index 0000000..846b4a0
--- /dev/null
+++ b/test cases/common/6 linkshared/meson.build
@@ -0,0 +1,12 @@
+project('shared library linking test', 'c', 'cpp')
+
+lib = shared_library('mylib',
+ 'libfile.c' # Split to different lines before and after the comma to test parser.
+ , install : false) # Don't install libraries in common tests; the path is platform-specific
+exe = executable('prog', 'main.c', link_with : lib, install : true)
+
+test('runtest', exe)
+
+cpplib = shared_library('mycpplib', 'cpplib.cpp')
+cppexe = executable('cppprog', 'cppmain.cpp', link_with : cpplib)
+test('cpptest', cppexe)
diff --git a/test cases/common/6 linkshared/test.json b/test cases/common/6 linkshared/test.json
new file mode 100644
index 0000000..067bca7
--- /dev/null
+++ b/test cases/common/6 linkshared/test.json
@@ -0,0 +1,6 @@
+{
+ "installed": [
+ { "type": "exe", "file": "usr/bin/prog" },
+ { "type": "pdb", "file": "usr/bin/prog" }
+ ]
+}