Cannot build with static link - go

I'm trying to build a go program with static link. I want to run this on a different system, with different version of glibc, without all the dependencies etc ...
So i looked up and found that you can pass arguments to the gcc compiler and tell him to statically link the dependencies. But i'm facing issue with "undefined_reference"
Here's the command i'm using : go build --ldflags '-extldflags "-static"' src/main/command/main.go
And the result :
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/usr/bin/ld: /tmp/go-link-376220047/000023.o: in function `_cgo_26061493d47f_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libtesseract.a(libtesseract_la-baseapi.o): in function `tesseract::TessBaseAPI::ProcessPagesInternal(char const*, char const*, int, tesseract::TessResultRenderer*)':
(.text+0x7356): undefined reference to `curl_easy_init'
/usr/bin/ld: (.text+0x7378): undefined reference to `curl_easy_setopt'
/usr/bin/ld: (.text+0x7387): undefined reference to `curl_easy_strerror'
/usr/bin/ld: (.text+0x73b6): undefined reference to `curl_easy_cleanup'
/usr/bin/ld: (.text+0x7700): undefined reference to `curl_easy_setopt'
/usr/bin/ld: (.text+0x771e): undefined reference to `curl_easy_setopt'
/usr/bin/ld: (.text+0x773e): undefined reference to `curl_easy_setopt'
/usr/bin/ld: (.text+0x775e): undefined reference to `curl_easy_setopt'
/usr/bin/ld: (.text+0x7770): undefined reference to `curl_easy_perform'
/usr/bin/ld: (.text+0x777f): undefined reference to `curl_easy_strerror'
/usr/bin/ld: (.text+0x7b16): undefined reference to `curl_easy_cleanup'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libtesseract.a(libtesseract_la-par_control.o): in function `tesseract::Tesseract::PrerecAllWordsPar(std::vector<tesseract::WordData, std::allocator<tesseract::WordData> > const&) [clone ._omp_fn.0]':
(.text+0x36): undefined reference to `omp_get_num_threads'
/usr/bin/ld: (.text+0x3e): undefined reference to `omp_get_thread_num'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libtesseract.a(libtesseract_la-par_control.o): in function `tesseract::Tesseract::PrerecAllWordsPar(std::vector<tesseract::WordData, std::allocator<tesseract::WordData> > const&)':
(.text+0x3eb): undefined reference to `GOMP_parallel'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libtesseract.a(libtesseract_ccutil_la-tessdatamanager.o): in function `tesseract::TessdataManager::LoadArchiveFile(char const*)':
(.text+0x406): undefined reference to `archive_read_new'
/usr/bin/ld: (.text+0x416): undefined reference to `archive_read_support_filter_all'
/usr/bin/ld: (.text+0x41e): undefined reference to `archive_read_support_format_all'
/usr/bin/ld: (.text+0x42e): undefined reference to `archive_read_open_filename'
/usr/bin/ld: (.text+0x44e): undefined reference to `archive_entry_pathname'
/usr/bin/ld: (.text+0x45e): undefined reference to `archive_read_next_header'
/usr/bin/ld: (.text+0x470): undefined reference to `archive_read_free'
...
The output is way bigger than that, it's just the start, but other errors are the same with different libraries.
i tried telling ld to find curl (for example) with the flag -lcurl, it works, but the problem is the same for many other libraries.
If you want to know the depedencies i use, here's the output of ldd main (the binary compiled dynamically) :
linux-vdso.so.1 (0x00007ffe273ed000)
liblept.so.5 => /usr/lib/x86_64-linux-gnu/liblept.so.5 (0x00007f70737d2000)
libtesseract.so.5 => /usr/lib/x86_64-linux-gnu/libtesseract.so.5 (0x00007f707345e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f707343c000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f707326f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f707312b000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7073111000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7072f4a000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f7072f10000)
libjpeg.so.62 => /usr/lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f7072e8c000)
libgif.so.7 => /usr/lib/x86_64-linux-gnu/libgif.so.7 (0x00007f7072e81000)
libtiff.so.5 => /usr/lib/x86_64-linux-gnu/libtiff.so.5 (0x00007f7072dfb000)
libwebpmux.so.3 => /usr/lib/x86_64-linux-gnu/libwebpmux.so.3 (0x00007f7072def000)
libwebp.so.6 => /usr/lib/x86_64-linux-gnu/libwebp.so.6 (0x00007f7072d84000)
libopenjp2.so.7 => /usr/lib/x86_64-linux-gnu/libopenjp2.so.7 (0x00007f7072d27000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7072d0a000)
libarchive.so.13 => /usr/lib/x86_64-linux-gnu/libarchive.so.13 (0x00007f7072c42000)
libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f7072ba7000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f7072b67000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7073a90000)
libzstd.so.1 => /usr/lib/x86_64-linux-gnu/libzstd.so.1 (0x00007f7072a8a000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f7072a62000)
libjbig.so.0 => /usr/lib/x86_64-linux-gnu/libjbig.so.0 (0x00007f7072854000)
libdeflate.so.0 => /usr/lib/x86_64-linux-gnu/libdeflate.so.0 (0x00007f7072838000)
libnettle.so.8 => /usr/lib/x86_64-linux-gnu/libnettle.so.8 (0x00007f70727f0000)
libacl.so.1 => /usr/lib/x86_64-linux-gnu/libacl.so.1 (0x00007f70727e3000)
liblz4.so.1 => /usr/lib/x86_64-linux-gnu/liblz4.so.1 (0x00007f70727c0000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f70727ad000)
libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f70725ff000)
libnghttp2.so.14 => /usr/lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007f70725d2000)
libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f70725b1000)
librtmp.so.1 => /usr/lib/x86_64-linux-gnu/librtmp.so.1 (0x00007f7072590000)
libssh2.so.1 => /usr/lib/x86_64-linux-gnu/libssh2.so.1 (0x00007f707255b000)
libpsl.so.5 => /usr/lib/x86_64-linux-gnu/libpsl.so.5 (0x00007f7072547000)
libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f70724b4000)
libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f70721c0000)
libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f707216d000)
libldap_r-2.4.so.2 => /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2 (0x00007f7072115000)
liblber-2.4.so.2 => /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2 (0x00007f7072104000)
libbrotlidec.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f70720f6000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f70720f0000)
libicuuc.so.67 => /usr/lib/x86_64-linux-gnu/libicuuc.so.67 (0x00007f7071f07000)
libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f7071d83000)
libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f7071b83000)
libhogweed.so.6 => /usr/lib/x86_64-linux-gnu/libhogweed.so.6 (0x00007f7071b3a000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f7071ab9000)
libgcrypt.so.20 => /usr/lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f7071999000)
libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f70718bd000)
libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f707188d000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f7071887000)
libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f7071878000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f707185e000)
libsasl2.so.2 => /usr/lib/x86_64-linux-gnu/libsasl2.so.2 (0x00007f7071841000)
libbrotlicommon.so.1 => /usr/lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f707181c000)
libicudata.so.67 => /usr/lib/x86_64-linux-gnu/libicudata.so.67 (0x00007f706fd03000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f706fbcf000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f706fbb9000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f706fb93000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f706fb8a000)
libffi.so.7 => /usr/lib/x86_64-linux-gnu/libffi.so.7 (0x00007f706fb7e000)
My questions are :
Why ld cannot find curl and other libraries by itself ?
How to know everything i need to install ?
Even if i install every lib it needs, will it work ?

Add required libraries to the linker flags: -static -lcurl -lssh2 -lssl -lcrypto -lz. Also you probably need to install -dev versions of the libraries: apt install libcurl4-openssl-dev libssh-dev zlib1g-dev. It will install lib*.a files which are needed for static linking.

Related

Replace linux dynamic loader in bazel run/test execution

I have an issue writing a custom wrapper around go_test from rules_go:
My situation: I have a set of precompiled libraries (.so) for Fedora that I want to link against go code using cgo. This part works beautifully. The resulting binaries run correctly on Fedora.
I even have declared all of the libraries as dependencies correctly and they show up in the runfiles of my go_binary outputs.
The precompiled .so files also include glibc from fedora (this is required since the other shared libraries depend on this version of the glibc) and ld-linux-x86-64.so.2 from Fedora.
How would I write a wrapper around go_test that uses the vendored ld from Fedora as a binary and passes the original go binary path as the first argument?
Additional info:
All of the libraries are accessible via the runfiles and findable via the ELF runpath. It's only ld itself that is selected incorrectly:
$ readelf -a bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs:$ORIGIN/initserver_test.runfiles/__main__/_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs]
$ ldd bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test
/lib64/ld-linux-x86-64.so.2 (0x00007f944795d000)
linux-vdso.so.1 (0x00007fff66347000)
libargon2.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libargon2.so.1 (0x00007f9447952000)
libblkid.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libblkid.so.1 (0x00007f9447919000)
libc.so.6 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libc.so.6 (0x00007f944773c000)
libcrypto.so.3 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libcrypto.so.3 (0x00007f9447312000)
libcryptsetup.so.12 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libcryptsetup.so.12 (0x00007f9447294000)
libdevmapper.so.1.02 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libdevmapper.so.1.02 (0x00007f9447238000)
libgcc_s.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libgcc_s.so.1 (0x00007f9447218000)
libjson-c.so.5 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libjson-c.so.5 (0x00007f9447205000)
libm.so.6 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libm.so.6 (0x00007f9447123000)
libpcre2-8.so.0 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libpcre2-8.so.0 (0x00007f9447086000)
libpthread.so.0 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libpthread.so.0 (0x00007f9447081000)
libselinux.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libselinux.so.1 (0x00007f9447054000)
libssl.so.3 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libssl.so.3 (0x00007f9446fb1000)
libudev.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libudev.so.1 (0x00007f9446f81000)
libuuid.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libuuid.so.1 (0x00007f9446f78000)
libz.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libz.so.1 (0x00007f9446f5e000)
$ bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/ld-linux-x86-64.so.2 --list bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test
/lib64/ld-linux-x86-64.so.2 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/ld-linux-x86-64.so.2 (0x00007f637dec7000)
linux-vdso.so.1 (0x00007ffd2e1e8000)
libargon2.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libargon2.so.1 (0x00007f637debc000)
libblkid.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libblkid.so.1 (0x00007f637de83000)
libc.so.6 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libc.so.6 (0x00007f637dca6000)
libcrypto.so.3 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libcrypto.so.3 (0x00007f637d87c000)
libcryptsetup.so.12 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libcryptsetup.so.12 (0x00007f637d7fe000)
libdevmapper.so.1.02 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libdevmapper.so.1.02 (0x00007f637d7a2000)
libgcc_s.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libgcc_s.so.1 (0x00007f637d782000)
libjson-c.so.5 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libjson-c.so.5 (0x00007f637d76f000)
libm.so.6 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libm.so.6 (0x00007f637d68d000)
libpcre2-8.so.0 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libpcre2-8.so.0 (0x00007f637d5f0000)
libpthread.so.0 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libpthread.so.0 (0x00007f637d5eb000)
libselinux.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libselinux.so.1 (0x00007f637d5be000)
libssl.so.3 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libssl.so.3 (0x00007f637d51b000)
libudev.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libudev.so.1 (0x00007f637d4eb000)
libuuid.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libuuid.so.1 (0x00007f637d4e2000)
libz.so.1 => /some/path/bazel-bin/bootstrapper/internal/initserver/initserver_test_/../../../../_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/libz.so.1 (0x00007f637d4c8000)
When using bazel run or bazel test on Ubuntu, my host ld-linux-x86-64.so.2 is used and I get a segfault. This is due to the hardcoded path to the interpreter (LD) embedded in the go binary and because ld and libc have to match:
readelf -p .interp bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test
String dump of section '.interp':
[ 0] /lib64/ld-linux-x86-64.so.2
bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test
Segmentation fault (core dumped)
The same works if I execute fedoras ld-linux-x86-64.so.2 directly and give it the path to the go binary as an argument (this is equivalent to setting the interpreter in the elf header to the absolute path of the location of the fedora ld on my host).
bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test.runfiles/__main__/_solib_k8/_U_S_Srpm_Ccryptsetup___Urpm_Scryptsetup-libs/ld-linux-x86-64.so.2 bazel-bin/bootstrapper/internal/initserver/initserver_test_/initserver_test
PASS

/usr/bin/ld: cannot find -lnetcdf?

First of all, this is my first question on here. If I make mistake, I'm sorry about that. By the way I'm a newbie in Fortran. I want to compile the "MMIF" model and the model has a compiler "makefile". I edited my "makefile" but I have an error message. When I used the make command, I'm getting this error:
...
/usr/bin/ld: cannot find -lnetcdf
collect2: error: ld returned 1 exit status
makefile:62: recipe for target 'mmif' failed
make: *** [mmif] Error 1
When I checked the location, I realised libnetcdf.a is missing. I don't know if it is needed in order to run the "makefile". Can you help me with this situation?
...
/usr/lib/x86_64-linux-gnu/libnetcdff.a
/usr/lib/x86_64-linux-gnu/libnetcdff.so
/usr/lib/x86_64-linux-gnu/libnetcdff.so.6
/usr/lib/x86_64-linux-gnu/libnetcdff.so.6.1.1
/usr/lib/x86_64-linux-gnu/libnetcdf.settings
/usr/lib/x86_64-linux-gnu/libnetcdf.so
/usr/lib/x86_64-linux-gnu/libnetcdf.so.13
...
Update 1
Thanks for helping and guiding me. I changed -lnetcdf to -lnetcdff. It works but I have a another problem now. I'm getting so many "undefined reference to..". Now, I'm trying to resolve these problems.
Error Code
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_text_':
(.text+0xb3): undefined reference to `nc_put_att_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_text_a_':
(.text+0x193): undefined reference to `nc_put_att_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_int1_':
(.text+0x277): undefined reference to `nc_put_att_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_int2_':
(.text+0x357): undefined reference to `nc_put_att_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_int_':
(.text+0x437): undefined reference to `nc_put_att_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_real_':
(.text+0x517): undefined reference to `nc_put_att_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_put_att_double_':
(.text+0x5f7): undefined reference to `nc_put_att_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_text_':
(.text+0x745): undefined reference to `nc_get_att_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_text_a_':
(.text+0x846): undefined reference to `nc_get_att_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_int1_':
(.text+0x916): undefined reference to `nc_get_att_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_int2_':
(.text+0x9e6): undefined reference to `nc_get_att_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_int_':
(.text+0xab6): undefined reference to `nc_get_att_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_real_':
(.text+0xb86): undefined reference to `nc_get_att_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_attio.o): In function `nf_get_att_double_':
(.text+0xc56): undefined reference to `nc_get_att_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_create_':
(.text+0xa1): undefined reference to `nc_create'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf__create_':
(.text+0x19a): undefined reference to `nc__create'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf__create_mp_':
(.text+0x292): undefined reference to `nc__create_mp'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_open_':
(.text+0x371): undefined reference to `nc_open'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf__open_':
(.text+0x45d): undefined reference to `nc__open'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf__open_mp_':
(.text+0x557): undefined reference to `nc__open_mp'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_open_mem_':
(.text+0x63c): undefined reference to `nc_open_mem'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_inq_path_':
(.text+0x78d): undefined reference to `nc_inq_path'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_set_fill_':
(.text+0x8ba): undefined reference to `nc_set_fill'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_set_default_format_':
(.text+0x910): undefined reference to `nc_set_default_format'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_delete_':
(.text+0xa3a): undefined reference to `nc_delete'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_delete_mp_':
(.text+0xb02): undefined reference to `nc_delete_mp'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_inq_base_pe_':
(.text+0xb60): undefined reference to `nc_inq_base_pe'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_redef_':
(.text+0x943): undefined reference to `nc_redef'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_enddef_':
(.text+0x953): undefined reference to `nc_enddef'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf__enddef_':
(.text+0x96f): undefined reference to `nc__enddef'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_sync_':
(.text+0x983): undefined reference to `nc_sync'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_abort_':
(.text+0x993): undefined reference to `nc_abort'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_close_':
(.text+0x9a3): undefined reference to `nc_close'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_control.o): In function `nf_set_base_pe_':
(.text+0xb35): undefined reference to `nc_set_base_pe'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_def_dim_':
(.text+0xb7): undefined reference to `nc_def_dim'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_inq_dim_':
(.text+0x24c): undefined reference to `nc_inq_dim'
(.text+0x2a6): undefined reference to `nc_inq_dim'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_inq_dimid_':
(.text+0x45d): undefined reference to `nc_inq_dimid'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_inq_dimlen_':
(.text+0x4c9): undefined reference to `nc_inq_dimlen'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_inq_dimname_':
(.text+0x63f): undefined reference to `nc_inq_dimname'
(.text+0x691): undefined reference to `nc_inq_dimname'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_dim.o): In function `nf_rename_dim_':
(.text+0x82e): undefined reference to `nc_rename_dim'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_def_var_':
(.text+0x111): undefined reference to `nc_def_var'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_varndims_':
(.text+0x1a5): undefined reference to `nc_inq_varndims'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_var_':
(.text+0x2f8): undefined reference to `nc_inq_varndims'
(.text+0x363): undefined reference to `nc_inq_var'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_vardimid_':
(.text+0x550): undefined reference to `nc_inq_varndims'
(.text+0x59a): undefined reference to `nc_inq_vardimid'
(.text+0x611): undefined reference to `nc_inq_vardimid'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_varid_':
(.text+0x6cf): undefined reference to `nc_inq_varid'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_varname_':
(.text+0x7e9): undefined reference to `nc_inq_varname'
(.text+0x831): undefined reference to `nc_inq_varname'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_vartype_':
(.text+0x955): undefined reference to `nc_inq_vartype'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_inq_varnatts_':
(.text+0x9a5): undefined reference to `nc_inq_varnatts'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_rename_var_':
(.text+0xa6e): undefined reference to `nc_rename_var'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_genvar.o): In function `nf_copy_var_':
(.text+0xaaa): undefined reference to `nc_copy_var'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_text_':
(.text+0x3d): undefined reference to `nc_inq_varndims'
(.text+0x139): undefined reference to `nc_put_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_text_a_':
(.text+0x1cd): undefined reference to `nc_inq_varndims'
(.text+0x2c9): undefined reference to `nc_put_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int1_':
(.text+0x35d): undefined reference to `nc_inq_varndims'
(.text+0x459): undefined reference to `nc_put_vara_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int2_':
(.text+0x4ed): undefined reference to `nc_inq_varndims'
(.text+0x5e9): undefined reference to `nc_put_vara_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int_':
(.text+0x67d): undefined reference to `nc_inq_varndims'
(.text+0x779): undefined reference to `nc_put_vara_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_real_':
(.text+0x80d): undefined reference to `nc_inq_varndims'
(.text+0x909): undefined reference to `nc_put_vara_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_double_':
(.text+0x99d): undefined reference to `nc_inq_varndims'
(.text+0xa99): undefined reference to `nc_put_vara_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_':
(.text+0xb2d): undefined reference to `nc_inq_varndims'
(.text+0xc29): undefined reference to `nc_put_vara'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_text_':
(.text+0xd31): undefined reference to `nc_inq_varndims'
(.text+0xe3a): undefined reference to `nc_get_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_text_a_':
(.text+0xefd): undefined reference to `nc_inq_varndims'
(.text+0xff9): undefined reference to `nc_get_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int1_':
(.text+0x108d): undefined reference to `nc_inq_varndims'
(.text+0x1189): undefined reference to `nc_get_vara_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int2_':
(.text+0x121d): undefined reference to `nc_inq_varndims'
(.text+0x1319): undefined reference to `nc_get_vara_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int_':
(.text+0x13ad): undefined reference to `nc_inq_varndims'
(.text+0x14a9): undefined reference to `nc_get_vara_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_real_':
(.text+0x153d): undefined reference to `nc_inq_varndims'
(.text+0x1639): undefined reference to `nc_get_vara_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_double_':
(.text+0x16cd): undefined reference to `nc_inq_varndims'
(.text+0x17c9): undefined reference to `nc_get_vara_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_':
(.text+0x185d): undefined reference to `nc_inq_varndims'
(.text+0x1959): undefined reference to `nc_get_vara'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_text_':
(.text+0x7e): undefined reference to `nc_put_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_text_a_':
(.text+0x20e): undefined reference to `nc_put_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int1_':
(.text+0x39e): undefined reference to `nc_put_vara_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int2_':
(.text+0x52e): undefined reference to `nc_put_vara_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_int_':
(.text+0x6be): undefined reference to `nc_put_vara_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_real_':
(.text+0x84e): undefined reference to `nc_put_vara_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_double_':
(.text+0x9de): undefined reference to `nc_put_vara_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_put_vara_':
(.text+0xb6e): undefined reference to `nc_put_vara'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_text_':
(.text+0xd72): undefined reference to `nc_get_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_text_a_':
(.text+0xf3e): undefined reference to `nc_get_vara_text'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int1_':
(.text+0x10ce): undefined reference to `nc_get_vara_schar'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int2_':
(.text+0x125e): undefined reference to `nc_get_vara_short'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_int_':
(.text+0x13ee): undefined reference to `nc_get_vara_int'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_real_':
(.text+0x157e): undefined reference to `nc_get_vara_float'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_double_':
(.text+0x170e): undefined reference to `nc_get_vara_double'
/usr/lib/x86_64-linux-gnu/libnetcdff.a(nf_varaio.o): In function `nf_get_vara_':
(.text+0x189e): undefined reference to `nc_get_vara'
collect2: error: ld returned 1 exit status
makefile:62: recipe for target 'mmif' failed
make: *** [mmif] Error 1
makefile
#
# Makefile for MMIF VERSION 3.4.1 2019-03-11
#
# Edit this file to un-comment the section for your compiler.
# You will also need to edit the line that specifies where to find the
# NetCDF libraries, which must be compiled by the same compiler.
# The directory "netcdf.4.1.1-mingw" is used to commpile under MS Windows.
# It was compiled using MinGW version 20110802, see http://www.mingw.org,
# and the script compile_netcdf_mingw.sh.
#
# PGI started linking with the OpenMP library by default in their 11.0 release,
# so that users would be able to use CPU binding even with serial code.
# Adding "-mp=nonuma -nomp" to FFLAGS fixes "can't find libnuma.so" problems.
# PGI Fortran:
# FC = pgf90
# FFLAGS = -g -fast -Mlfs # -Mlfs is default on for x86_64
# FFLAGS += -Mbounds # for bounds checking/debugging
# FFLAGS += -Bstatic_pgi # to use static PGI libraries
# FFLAGS += -Bstatic # to use static netCDF libraries
# FFLAGS += -mp=nonuma -nomp # fix for "can't find libnuma.so"
# NETCDF = /usr/local/src/netcdf-4.1.1.pgi
# GNU gfortran (Windows or Linux, just set NETCDF below correctly)
FC = gfortran
FFLAGS = -g -Wall
FFLAGS += -fbounds-check # for bounds checking/debugging
FFLAGS += -static # to use static libraries
NETCDF = /usr
# Intel Fortran:
#FC = ifort
#FFLAGS = -O2 -align dcommons -ipo
#FFLAGS += -static # to use static libraries
#NETCDF = /path/to/netcdf-4.1.1.ifort
# NETCDF values that are the same for all compilers
INCL = -I$(NETCDF)/include
LIBS = -L/usr/lib/x86_64-linux-gnu -lnetcdff
PROGRAM = mmif
TODAY = 2019-03-11
VERSION = 3.4.1
NEWTAG = 3.4.1 2019-03-11
OLDTAG = 3.4.1 2019-03-01
MODULES = met_fields.f90 functions.f90 module_llxy.f90 wrf_netcdf.f90 \
parse_control.f90
SOURCES = aggregate.f90 avg_zface.f90 cloud_cover.f90 interpolate.f90 \
landuse.f90 mmif.f90 output_aercoare.f90 output_aermet.f90 \
output_calmet.f90 output_onsite.f90 output_scichem.f90 \
pasquill_gifford.f90 pbl_height.f90 read_mm5.f90 read_wrf.f90 \
sfc_layer.f90 timesubs.f90
OBJECTS = $(SOURCES:.f90=.o)
MODOBJS = $(MODULES:.f90=.o)
MODMODS = $(MODULES:.f90=.mod)
$(PROGRAM): $(MODOBJS) $(OBJECTS)
$(FC) $(FFLAGS) $(MODOBJS) $(OBJECTS) $(LIBS) -o $#
%.o : %.f90
$(FC) $(FFLAGS) $(INCL) -c $< -o $#
install: $(PROGRAM)
cp $(PROGRAM) /usr/local/bin
update_version:
sed -i "s|VERSION $(OLDTAG)|VERSION $(NEWTAG)|g" \
*.f90 README.txt makefile makefile.windows mmif_change_log.txt
distro:
mmif --sample > mmif.inp
unix2dos *.f90 *.sh makefile.windows old_compile.bat README*.txt mmif.inp
zip -j MMIFv$(VERSION)_$(TODAY).zip \
mmif.exe mmif mmif.inp *.f90 *.sh makefile \
makefile.windows old_compile.bat README*.txt \
MMIFv$(VERSION)_Users_Manual.pdf \
mmif_change_log.txt test_problems/*/*.inp
dos2unix *.f90
test_pkg:
zip -r MMIFv$(VERSION)_test_problems.zip \
test_problems -x \*/wrf/\* \*/mm5/\*
test_pkg_mm5+wrf:
zip -r MMIF_test_problems_mm5+wrf.zip \
test_problems/wrf \
test_problems/mm5
clean:
rm $(MODMODS) $(MODOBJS) $(OBJECTS) $(PROGRAM)
Library
-------
This netCDF 4.6.0 has been built with the following features:
--cc -> /usr/bin/cc
--cflags -> -I/usr/include -I/usr/include/hdf5/serial
--libs -> -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lnetcdf -lhdf5_hl -lhdf5 -lpthread -lsz -lz -ldl -lm -lcurl
--has-c++ -> no
--cxx ->
--has-c++4 -> no
--cxx4 ->
--has-fortran-> yes
--fc -> gfortran
--fflags -> -I/usr/include
--flibs -> -L/usr/lib -lnetcdff -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -lnetcdf -lnetcdf
--has-f90 -> no
--has-f03 -> yes
--has-dap -> yes
--has-dap2 -> yes
--has-dap4 -> yes
--has-nc2 -> yes
--has-nc4 -> yes
--has-hdf5 -> yes
--has-hdf4 -> no
--has-logging-> no
--has-pnetcdf-> no
--has-szlib -> no
--has-cdf5 -> no
--has-parallel-> no
--prefix -> /usr
--includedir-> /usr/include
--libdir -> /usr/lib/x86_64-linux-gnu
--version -> netCDF 4.6.0

Linking PGI OpenACC Runtime Library directly with gcc

I am insterested in using PGI OpenACC runtime API directly from code compiled by GCC.
I've noticed that the PGI OpenACC installation provides two openacc.h headers. One for PGI (located in include/openacc.h) and another that seems to be compatible with GCC (etc/include_acc/openacc.h). It is safe to use the second header with GCC?
So far I've been able to compile & run a small test:
#include <openacc.h>
#include <cuda_runtime_api.h>
#include <stdio.h>
int main()
{
acc_init( acc_device_nvidia );
int ndev = acc_get_num_devices( acc_device_nvidia );
printf("Num OpenACC devices: %d\n", ndev);
cudaGetDeviceCount(&ndev);
printf("Num CUDA devices: %d\n", ndev);
return 0;
}
Using PGI:
pgcc -acc -ta=tesla,cuda8.0 -Mcuda ./test.c -o oacc_test.pgi
Using GCC + PGI OpenACC:
gcc -isystem /usr/local/cuda-8.0/include -isystem /usr/local/pgi/linux86-64/17.4/etc/include_acc -o oacc_test.both test.c -L/usr/local/cuda-8.0/lib64 -Wl,-rpath,/usr/local/cuda-8.0/lib64 -lcudart -lcuda -L/usr/local/pgi/linux86-64/17.4/lib -Wl,-rpath,/usr/local/pgi/linux86-64/17.4/lib -laccapi -laccg -laccnc -laccn -laccg2 -ldl -lpgc -lm
Using GCC + GCC OpenACC: (for comparison)
gcc -fopenacc -isystem /usr/local/cuda-8.0/include -o oacc_test.gnu test.c -L/usr/local/cuda-8.0/lib64 -Wl,-rpath,/usr/local/cuda-8.0/lib64 -lcudart -lcuda
And execute:
$ ./oacc_test.pgi
Num OpenACC devices: 4
Num CUDA devices: 4
$ ./oacc_test.both
Num OpenACC devices: 4
Num CUDA devices: 4
$ ./oacc_test.gnu
libgomp: device type nvidia not supported
More info:
$ ldd oacc_test.pgi
linux-vdso.so.1 (0x00007ffd843f8000)
libaccapi.so => /usr/local/pgi/linux86-64/17.4/lib/libaccapi.so (0x00007fa5a2b9f000)
libaccg.so => /usr/local/pgi/linux86-64/17.4/lib/libaccg.so (0x00007fa5a2981000)
libaccnc.so => /usr/local/pgi/linux86-64/17.4/lib/libaccnc.so (0x00007fa5a2777000)
libaccn.so => /usr/local/pgi/linux86-64/17.4/lib/libaccn.so (0x00007fa5a2552000)
libaccg2.so => /usr/local/pgi/linux86-64/17.4/lib/libaccg2.so (0x00007fa5a233c000)
libcudapgi.so => /usr/local/pgi/linux86-64/17.4/lib/libcudapgi.so (0x00007fa5a213b000)
libcudart.so.8.0 => /usr/local/cuda/lib64/libcudart.so.8.0 (0x00007fa5a1ed5000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa5a1b49000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa5a1945000)
libcudadevice.so => /usr/local/pgi/linux86-64/17.4/lib/libcudadevice.so (0x00007fa5a1731000)
libpgmp.so => /usr/local/pgi/linux86-64/17.4/lib/libpgmp.so (0x00007fa5a14af000)
libnuma.so => /usr/local/pgi/linux86-64/17.4/lib/libnuma.so (0x00007fa5a12ae000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa5a1091000)
libpgc.so => /usr/local/pgi/linux86-64/17.4/lib/libpgc.so (0x00007fa5a0dae000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa5a0aaa000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa5a070b000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa5a04f2000)
/lib64/ld-linux-x86-64.so.2 (0x000055767be3b000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa5a02ea000)
$ ldd oacc_test.both
linux-vdso.so.1 (0x00007ffe55753000)
libcudart.so.8.0 => /usr/local/cuda/lib64/libcudart.so.8.0 (0x00007f7ddfe3c000)
libcuda.so.1 => /usr/lib/x86_64-linux-gnu/libcuda.so.1 (0x00007f7ddf3d8000)
libaccapi.so => /usr/local/pgi/linux86-64/17.4/lib/libaccapi.so (0x00007f7ddf1b8000)
libaccg.so => /usr/local/pgi/linux86-64/17.4/lib/libaccg.so (0x00007f7ddef9a000)
libaccnc.so => /usr/local/pgi/linux86-64/17.4/lib/libaccnc.so (0x00007f7dded90000)
libaccn.so => /usr/local/pgi/linux86-64/17.4/lib/libaccn.so (0x00007f7ddeb69000)
libaccg2.so => /usr/local/pgi/linux86-64/17.4/lib/libaccg2.so (0x00007f7dde955000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7dde751000)
libpgc.so => /usr/local/pgi/linux86-64/17.4/lib/libpgc.so (0x00007f7dde46e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7dde16a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7ddddcb000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7dddbac000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f7ddd9a4000)
libnvidia-fatbinaryloader.so.378.13 => /usr/lib/x86_64-linux-gnu/libnvidia-fatbinaryloader.so.378.13 (0x00007f7ddd753000)
/lib64/ld-linux-x86-64.so.2 (0x00005593f06f5000)
$ ldd oacc_test.gnu
linux-vdso.so.1 (0x00007ffd967d7000)
libcudart.so.8.0 => /usr/local/cuda/lib64/libcudart.so.8.0 (0x00007f9002679000)
libcuda.so.1 => /usr/lib/x86_64-linux-gnu/libcuda.so.1 (0x00007f9001c15000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f90019e8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f90017cb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f900142c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9001226000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f900101e000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9000d1a000)
libnvidia-fatbinaryloader.so.378.13 => /usr/lib/x86_64-linux-gnu/libnvidia-fatbinaryloader.so.378.13 (0x00007f9000ac9000)
/lib64/ld-linux-x86-64.so.2 (0x0000563eee684000)
Is is safe to use the PGI OpenACC Runtime API that way?
Also threre is any difference between the CUDA runtime provided by Nvidia (usually in /usr/local/cuda) and the one provided by PGI (in my case in /usr/local/pgi/linux86-64/2017/cuda)?
I've noticed that pgcc uses the CUDA 7.5 from it's own install path but when -ta=cuda8.0 is provided it uses the one in /usr/local/cuda. Any special reason?
PGI compiled objects are interoperable with GNU and it's fine to mix in PGI OpenACC compiled code with GNU compiled objects. Though, the OpenACC runtimes libraries aren't compatible so I'd recommend not mixing the OpenACC code. Note that GNU support for OpenACC has gotten a lot better in their 7.0 release, so while I work for PGI, I'd encourage you to try both compilers. The one caveat is the they (GNU) don't support the "kernels" construct, so you'll want to stick to using "parallel" regions.
As for the CUDA libraries, PGI ships all the libraries that we need to compile your OpenACC code. Though, there's no difference in the CUDA libraries themselves. We didn't want users to have to co-install the CUDA SDK and it allows us to add convenience flags such as "-Mcudalib[=cublas|cufft|curand|cusolver|cusparse]" since we know where these libraries are located as well as include our own Fortran interface modules to these libraries.
Unless you have the flag "CUDAROOT=" set on your compilation line, "-ta=tesla:cuda8.0" should be using the PGI supplied CUDA 8.0 directory located in "$PGI/linux86-64/2017/cuda/8.0". Are you sure it's using the /usr/local/cuda install? You can double check by adding the verbose flag (-v) to see what the compiler driver is executing or "-dryrun" to see the commands without having the driver execute them.
Another possibility is that you're using "-L" or "-Wl" flags to point to the CUDA install (like you do with GNU) in which case the linker will pick-up the CUDA libraries from these directories. Though since they're the same libraries as we ship, it shouldn't be a problem.

Firefox 3.6 under debian squeeze

While I want to start my Firefox 3.6 which I installed under /opt/firefox/
I have the Following Error:
[root#box]: ./firefox-bin
./firefox-bin: error while loading shared libraries: libxul.so: cannot open shared object file: No such file or directory
Here is my ldd output:
ldd firefox-bin
linux-gate.so.1 => (0xf77cf000)
libpthread.so.0 => /lib32/libpthread.so.0 (0xf779e000)
libxul.so => not found
libxpcom.so => not found
libmozalloc.so => not found
libplds4.so => /usr/lib32/libplds4.so (0xf779a000)
libplc4.so => /usr/lib32/libplc4.so (0xf7796000)
llibnspr4.so => /usr/lib32/libnspr4.so (0xf7762000)
libdl.so.2 => /lib32/libdl.so.2 (0xf775d000)
libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf7668000)
libm.so.6 => /lib32/libm.so.6 (0xf7642000)
libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7624000)
libc.so.6 => /lib32/libc.so.6 (0xf74dd000)
/lib/ld-linux.so.2 (0xf77d0000)
The file is there an all the others too:
[root#box]: locate libxul
/opt/firefox/libxul.so
So they are 3 files missing. Can you help to get me them?
EDIT:
With the short fix:
export LD_LIBRARY_PATH=/opt/firefox/
I get the same error with ./firefox-bin
./firefox-bin: error while loading shared libraries: libpangoft2-1.0.so.0: cannot open shared object file: No such file or directory
You should start it with /opt/firefox/firefox
Looks like there is something wrong with you package mananger ...
ldd firefox-bin
libxul.so => not found
...
locate libxul
/opt/firefox/libxul.so
this part can be solved with
export LD_LIBRARY_PATH=/opt/firefox/
..../firefox-bin
or
LD_LIBRARY_PATH=/opt/firefox/ ..../firefox-bin
Try:
sudo apt-get install ia32-libs-gtk

Compiling libshout using QT/qmake

I'm trying to link my QT application to a DLL (libshout), while building for Windows.
I've added the appropriate lines to my .pro file:
LIBS += -L/local/lib -lmp3lame
LIBS += -L/local/lib -lshout
LIBS += -L/local/lib -logg
LIBS += -L/local/lib -lvorbis
LIBS += -lwsock32
I've also successfully built and installed libshout to /local/lib (I'm using mingw and the gcc-dw2 compiler).
However, qmake fails to link successfully. I've pasted the gcc/make output below. I'm not even sure it's trying to link to the right library (isn't .a/.la a static library?).
I've been tearing my hair out for 3 days over this one so any help appreciated :)
g++-dw2 -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPP
ORT -DQT_DLL -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CO
RE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I'../../Qt/4.6.3/include/QtCore' -I
'../../Qt/4.6.3/include/QtNetwork' -I'../../Qt/4.6.3/include/QtGui' -I'../../Qt/
4.6.3/include/QtWebKit' -I'../../Qt/4.6.3/include' -I'../../Qt/4.6.3/include/Act
iveQt' -I'release' -I'../../Qt/4.6.3/mkspecs/win32-g++' -o release/qrc_resources
.o release/qrc_resources.cpp
g++-dw2 -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo
-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o build/release/MyApp.exe ob
ject_script.MyApp.Release -L'c:/Qt/4.6.3/lib' -lmingw32 -lqtmain -L/local/lib -
lmp3lame -L/local/lib -lshout -lwsock32 -lQtWebKit4 -lQtGui4 -lQtNetwork4 -lQtCo
re4
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `free_codec':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:188: undefined reference to `ogg_
stream_clear'
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `close_ogg':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:144: undefined reference to `ogg_
sync_clear'
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `send_ogg':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:90: undefined reference to `ogg_s
ync_buffer'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:92: undefined reference to `ogg_s
ync_wrote'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:94: undefined reference to `ogg_s
ync_pageout'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:95: undefined reference to `ogg_p
age_bos'
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `open_codec':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:154: undefined reference to `ogg_
page_serialno'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:154: undefined reference to `ogg_
stream_init'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:155: undefined reference to `ogg_
stream_pagein'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:160: undefined reference to `ogg_
stream_clear'
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `send_ogg':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:117: undefined reference to `ogg_
page_serialno'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:119: undefined reference to `ogg_
stream_pagein'
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:94: undefined reference to `ogg_s
ync_pageout'
C:/msys/1.0/local/lib/libshout.a(ogg.o): In function `shout_open_ogg':
c:\myapp_app\external\libshout-2.2.2\src/ogg.c:74: undefined reference to `ogg_s
ync_init'
C:/msys/1.0/local/lib/libshout.a(vorbis.o): In function `free_vorbis_data':
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:103: undefined reference to `v
orbis_info_clear'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:104: undefined reference to `v
orbis_comment_clear'
C:/msys/1.0/local/lib/libshout.a(vorbis.o): In function `read_vorbis_page':
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:83: undefined reference to `vo
rbis_synthesis_headerin'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:82: undefined reference to `og
g_stream_packetout'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:91: undefined reference to `og
g_stream_packetout'
C:/msys/1.0/local/lib/libshout.a(vorbis.o): In function `vorbis_blocksize':
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:110: undefined reference to `v
orbis_packet_blocksize'
C:/msys/1.0/local/lib/libshout.a(vorbis.o): In function `shout_open_vorbis':
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:57: undefined reference to `vo
rbis_info_init'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:58: undefined reference to `vo
rbis_comment_init'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:60: undefined reference to `og
g_stream_packetout'
c:\myapp_app\external\libshout-2.2.2\src/vorbis.c:62: undefined reference to `vo
rbis_synthesis_headerin'
collect2: ld returned 1 exit status
make[1]: *** [build/release/Myapp.exe] Error 1
make[1]: Leaving directory `/c/myapp_app/src'
make: *** [release] Error 2
My first guess would be that libogg and libvorbis aren't installed in /local/lib, did you check that they are there?

Resources