With C/C++, on Windows you don't need to pass any arguments for a static library to be PIC. On UNIX platforms you need to pass -fPIC. Other languages such as D have compiler-specific PIC arguments required for PIC support in static libraries on UNIX platforms. This kwarg allows people to specify which static libraries should be built with PIC support. This is usually used for static libraries that will be linked into shared libraries.pull/856/head
parent
71eddecdc7
commit
ee8b3b12a0
7 changed files with 52 additions and 20 deletions
@ -1,6 +1,7 @@ |
||||
project('statchain', 'c') |
||||
|
||||
subdir('subdir') |
||||
statlib = static_library('stat', 'stat.c', link_with : shlib) |
||||
exe = executable('prog', 'prog.c', link_with : statlib) |
||||
statlib = static_library('stat', 'stat.c', link_with : shlib, pic : true) |
||||
shlib2 = shared_library('shr2', 'shlib2.c', link_with : statlib) |
||||
exe = executable('prog', 'prog.c', link_with : shlib2) |
||||
test('runtest', exe) |
||||
|
@ -1,5 +1,10 @@ |
||||
int shlibfunc2(); |
||||
int statlibfunc(); |
||||
|
||||
int main(int argc, char **argv) { |
||||
return statlibfunc() == 42 ? 0 : 1; |
||||
if (statlibfunc() != 42) |
||||
return 1; |
||||
if (shlibfunc2() != 24) |
||||
return 1; |
||||
return 0; |
||||
} |
||||
|
@ -0,0 +1,7 @@ |
||||
#include "subdir/exports.h" |
||||
|
||||
int statlibfunc(void); |
||||
|
||||
int DLL_PUBLIC shlibfunc2(void) { |
||||
return statlibfunc() - 18; |
||||
} |
@ -0,0 +1,12 @@ |
||||
#pragma once |
||||
|
||||
#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 |
Loading…
Reference in new issue