opened
yxiang92128
username_0
Answering these questions before submitting your bug report will help us give
you a quicker answer. Thank you!

If one or more of these questions are not applicable, feel free to remove them.
Does this issue affect the google-cloud-cpp project?

Yes, stuck at using the API CreateAuthorizedUserCredentialsFromJsonContents or CreateAuthorizedUserCredentialsFromJsonFilePath
What component of google-cloud-cpp is this related to?

    Cloud Storage.

What version of google-cloud-cpp are you using?

latest HEAD git rev-parse HEAD
66cb4f9
What compiler and version are you using?

gcc-5.3.1

Please include the output of g++ -v or the equivalent command-line flag.
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/5/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,fortran,ada,go --enable-checking=release --with-gxx-include-dir=/usr/include/c++/5 --enable-ssp --disable-libssp --disable-libvtv --enable-libmpx --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --with-default-libstdcxx-abi=gcc4-compatible --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-5 --without-system-libunwind --enable-multilib --with-arch-32=x86-64 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 5.3.1 20160301 [gcc-5-branch revision 233849] (SUSE Linux)
What operating system and version are you using?

SLES12SP3
If you are using a Linux distribution include the name and version of the
distribution too.
What were you trying to do?

I am trying to link the gcloud library to compile with my existing library which is using pthread and it gives me the following error, is there a way to get around it?  If so,  how do I change the default compilation option in google-cloud-cpp to generate .so instead of .a and add the -fPIC option:
g++ -shared -fPIC -g -Wl,-rpath=/opt/teradata/tdobject/lib:/usr/local/lib64:/usr/local/lib -rdynamic  -o libGSobjectif.so GSSDKInterface.o ../../google-cloud-cpp/cmake-out/external/lib64/libstorage_client.a ../../google-cloud-cpp/cmake-out/external/lib64/libgmock_main.a ../../google-cloud-cpp/cmake-out/external/lib64/libgmock.a ../../google-cloud-cpp/cmake-out/external/lib64/libgtest.a ../../google-cloud-cpp/cmake-out/external/lib64/libcurl.a ../../google-cloud-cpp/cmake-out/external/lib/libcares.so /usr/lib64/libssl.so /usr/lib64/libcrypto.so ../../google-cloud-cpp/cmake-out/external/lib/libz.so ../../google-cloud-cpp/cmake-out/external/lib64/libcrc32c.a /usr/lib64/libssl.so /usr/lib64/libcrypto.so ../../google-cloud-cpp/cmake-out/external/lib/libz.so ../../google-cloud-cpp/cmake-out/external/lib64/libgoogle_cloud_cpp_common.a  -L. -ltdobjectif
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: ../../google-cloud-**_cpp/cmake-out/external/lib64/libstorage_client.a(client.cc.o): relocation R_X86_64_32 against `__pthread_key_create' can not be used when making a shared object; recompile with -fPIC
../../google-cloud-cpp/cmake-out/external/lib64/libstorage_client.a: error adding symbols: Bad value_**


Thanks,

Yang
Newbie Question: how to get around a linking issue with pthread_key_create?
issue
created
coryan
username_1
Looks like you are trying to compile a shared object (a `lib*.so`) and linking static versions of the `google-cloud-cpp` libraries (a bunch of `lib*.a` files).

You probably want to compile the `google-cloud-cpp` libraries as shared objects too, which can be done using:

```sh
cmake -DBUILD_SHARED_LIBS=yes -H. -Bcmake-out
cmake --build cmake-out
```

Please note that any dependencies will need to be compiled as shared objects too.

If you are using the super build, I think this should work:

```sh
cmake -DBUILD_SHARED_LIBS=yes -Hsuper -Bcmake-out
cmake --build cmake-out
```

Please let us know if that helps.
comment
created
yxiang92128
username_0
that works! thanks.
comment
closed
yxiang92128
username_0
issue