I have written a code in fortran using MPI for parallelization and I always used gfortran as a compiler, but now I want to go with Intel ifort. The problem is that on the server I try to run it for mpif90 the gnu compiler is set as default:
mpif90 --showme
gfortran -I/usr/lib/openmpi/include -pthread -I/usr/lib/openmpi/lib -L/usr//lib -L/usr/lib/openmpi/lib -lmpi_f90 -lmpi_f77 -lmpi -ldl -lhwloc
I have no idea what flags I have to include with ifort. I tried it like that:
ifort -openmp test_mpi.f -I/usr/local/openmpi-1.8.4-intel/include -I/usr/local/openmpi-1.8.4-intel/lib -L/usr/local/openmpi-1.8.4-intel/lib -lmpi_f90 -lmpi_f77 -lmpi
Which gives me to output:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib//libmpi_f77.so: undefined reference to `opal_uses_threads'
Than I tried using not the Intel OpenMpi but the /usr/lib/openmpi/, than the program compiles but when executing it I get:
./a.out: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory
Which is wired because looking up echo $LD_LIBRARY_PATH:
/opt/intel/composer_xe_2013.5.192/compiler/lib/intel64:/opt/intel/composer_xe_2013.5.192/mpirt/lib/intel64:/opt/intel/composer_xe_2013.5.192/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2013.5.192/ipp/lib/intel64:/opt/intel/composer_xe_2013.5.192/compiler/lib/intel64:/opt/intel/composer_xe_2013.5.192/mkl/lib/intel64:/opt/intel/composer_xe_2013.5.192/tbb/lib/intel64/gcc4.4
and in /opt/intel/composer_xe_2013.5.192/compiler/lib/intel64 there is "libiomp5.so".
Has anyone an idea how to fix my compiler flags?
#HighPerformanceMark:
I did that now with:
ifort -openmp test_mpi.f -I/opt/intel/mpi-rt/4.1.0/include -I/opt/intel/mpi-rt/4.1.0/lib -L/opt/intel/mpi-rt/4.1.0/lib -lmpi_f90 -lmpi_f77 -lmpi
which gave me:
ld: skipping incompatible /opt/intel/mpi-rt/4.1.0/lib/libmpi.so when searching for -lmpi ld: skipping incompatible /opt/intel/mpi-rt/4.1.0/lib/libmpi.a when searching for -lmpi
By skipping -lmpi the error:
include -I/opt/intel/mpi-rt/4.1.0/lib -L/opt/intel/mpi-rt/4.1.0/lib -lmpi_f90 -lmpi_f77 ld: /tmp/ifort41PQRn.o: undefined reference to symbol 'mpi_null_delete_fn_' ld: note: 'mpi_null_delete_fn_' is defined in DSO /usr/lib/libmpi.so.1 so try adding it to the linker command line /usr/lib/libmpi.so.1: could not read symbols: Invalid operation
appeared!
Related
I am using WSL Ubuntu. And use GCC to compile my C++ code.
I am trying to use OpenACC to parallelize my code. I heard that I can use OpenACC with GCC.
So after I install Ubuntu, I installed GCC.
And then I typed as follows:
$ g++ -fopenacc -o t testfile.cpp
As far as I know, -fopenacc should enable me to use OpenACC inside my code.
However, I got an message saying:
lto-wrapper: fatal error: could not find accel/nvptx-none/mkoffload in /usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/9/:/usr/lib/gcc/x86_64-linux-gnu/ (consider using ‘-B’)
So I guess I missed something.
Does anyone know how to use OpenACC with GCC?
Edited:
I tried:
sudo apt-get install gcc-9-offload-nvptx
And then the error message is now changed to:
lto1: error: ‘-fcf-protection=full’ is not supported for this target
mkoffload: fatal error: x86_64-linux-gnu-accel-nvptx-none-gcc-9 returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: /usr/lib/gcc/x86_64-linux-gnu/9//accel/nvptx-none/mkoffload returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
I got one step further with:
gcc-10 -O2 -ffast-math -fopenacc -fopt-info-all-omp -fcf-protection=none -foffload=nvptx laplace2dkernels.c
but just to find the next problem:
gcc-10: fatal error: GCC is not configured to support nvptx as offload target
compilation terminated
So it seems they only compiled it for AMD GCN.
If you use
gcc-10 -O2 -ffast-math -fopenacc -fopt-info-all-omp -fcf-protection=none -foffload=nvptx-none laplace2dkernels.c
>laplace2dkernels.c:74:9: optimized: assigned OpenACC seq loop parallelism
>/usr/bin/ld: /tmp/ccYd0cZe.crtoffloadtable.o: warning: relocation against >`__offload_vars_end' in read-only section `.rodata'
It compiles but then when running it misses:
libgomp: while loading libgomp-plugin-gcn.so.1: libgomp-plugin-gcn.so.1: cannot open shared object file: No such file or directory
I do not need to install those libraries because I want to get it to run with my Nvidia card.
With the PGI compilers everything worked fine.
NOTE: I am also using WSL and special NVIDIA drivers to allow for GPU passthrough.
Here's what worked for me for a Tiny C++ stencil code with OpenACC directives, after installing gcc-10-offload-nvptx:
g++ -c -g -O -fopenacc -foffload=nvptx-none -fcf-protection=none -foffload=-misa=sm_35 -fno-stack-protector stencil_acc.cxx
g++ -o stencil_acc -g -O -fopenacc -foffload=nvptx-none -fcf-protection=none -foffload=-misa=sm_35 -fno-stack-protector util.o stencil_acc.o
I have been using gtests for unit testing a personal project. Last week I upgraded to the LTS version of Linux Mint. Unfortunately, after that event, I haven't been able to compile my project due to gtests linking problems.
The following error is being issued:
/usr/bin/x86_64-linux-gnu-ld: build/tests/policies/roundrobin_tests.o: undefined reference to symbol '_ZN7testing4TestC2Ev'
/home/myuser/Documents/googletest-release-1.8.0/googletest/libgtest.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I have generated both libgtest.so and libgtest_main.so through CMake 3.10.2. The gtest version is the release-1.8.0, the same I used to have before.
Those libraries are located in /usr/lib and the corresponding include folder has also been copied to /usr/include. I made sure that this location is in my ld path and that is not the problem.
My compiler is g++ v7.3.0 and the command Im using to compile the testes is:
g++ -std=c++14 -Wall -O3 -Iinclude build/tests/policies/roundrobin_tests.o -lgtest_main -pthread -o bin/policies/roundrobin_tests
I have tried altering the order of the elements in the command, explicitly adding -L/usr/lib and -I/usr/include without luck. A funny fact is that if I take off the -pthread flag, the error is still the same.
The same command was used before and the only difference is the compiler version I am using now as I used g++ 5.4.0 before. Any insights on how to solve this?
edit: Just tested the same process with g++ 5.4.0 and CMake 3.5 and the same problems ocurred.
I'm trying to get a port of our product to AIX that someone did 9 years ago working again, so I'm using gcc 4.3.6 on AIX 7.1 - the code builds without errors, and runs until we first throw an exception, but then the catch block that should catch it (and does on Linux) never gets called, and the execution terminates due to the uncaught exception. I've added test code where the throw and the catch are in the same function, so that it's not trying to cross any module boundaries or do any stack unwinding, and even that doesn't work:
try {
throw std::runtime_error("Just testing throw-catch");
} catch (std::runtime_error& e) {
// We don't get here
So it seems like something is very sick in our libstdc++ exception handling. The gcc & libstdc++ 4.3.6 we're using are from RPMs downloaded from the www.perzl.org/aix repository, so they should be built correctly, and looking at the autoconf log from setting up our makefiles for AIX they seem to have been located correctly. So I'm guessing it must be something in our environment or the linking process for my executable. We're using the preinstalled (on a VM provided by IBM) AIX native linker ld, rather than the gnu linker, which I gather is the correct thing to do on AIX. I've confirmed that the libstdc++.a library archive that we're using contains a .so library, so I believe we're linking libstdc++ dynamically. If it's relevant, here's some gory details of build flags etc:
/usr/local/tools/powerpc_AIX71/gcc-4.3.6/bin/g++ -DHAVE_CONFIG_H -I. -I../.. -I/usr/nimbus/nimbus/agent/util/tests -I/usr/local/tools/powerpc_AIX71/cppunit/include -I/usr/nimbus/nimbus/agent -I/usr/local/tools/powerpc_AIX71/boost-1.33.1/include -DECVERSION='"7.2.0.0"' -I/usr/local/tools/powerpc_AIX71/openssl-0.9.8y/include -I/usr/nimbus/nimbus/agent -I/usr/local/tools/powerpc_AIX71/boost-1.33.1/include -DECVERSION='"7.2.0.0"' -DUSE_PROFILING -DUSE_LOGGING -DHAVE_UNIX -DHAVE_AIX -g -O2 -c -o testrunner-TestSystem-unix.o `test -f 'unix/TestSystem-unix.cpp' || echo '/usr/nimbus/nimbus/agent/util/tests/'`unix/TestSystem-unix.cpp
rm -f buildinfo.cpp; echo '#include <util/buildinfo.h>' >buildinfo.cpp; echo >>buildinfo.cpp; echo 'const char *BuildInfo = "u0016760__0_OPT_2017.02.08_10:38:05";' >>buildinfo.cpp; /usr/local/tools/powerpc_AIX71/gcc-4.3.6/bin/g++ -DHAVE_CONFIG_H -I. -I../.. -I/usr/nimbus/nimbus/agent/util/tests -I/usr/nimbus/nimbus/agent -I/usr/local/tools/powerpc_AIX71/boost-1.33.1/include -DECVERSION='"7.2.0.0"' -DUSE_PROFILING -DUSE_LOGGING -DHAVE_UNIX -DHAVE_AIX -g -O2 -c buildinfo.cpp; /opt/freeware/bin/bash ../../libtool --tag=CXX --mode=link /usr/local/tools/powerpc_AIX71/gcc-4.3.6/bin/g++ -DUSE_PROFILING -DUSE_LOGGING -DHAVE_UNIX -DHAVE_AIX -g -O2 -static-libgcc -L../.. -o testrunner buildinfo.o testrunner-TestAtomicValue.o testrunner-TestCondition.o testrunner-TestCounter.o testrunner-TestECVersion.o testrunner-TestExec.o testrunner-TestExecTimeProfiler.o testrunner-TestExpirableStack.o testrunner-TestFileAttributes.o testrunner-TestGetOpt.o testrunner-TestHTTPStream.o testrunner-TestLock.o testrunner-TestLogger.o testrunner-TestMutex.o testrunner-TestNamedTimer.o testrunner-TestRBList.o testrunner-TestRange.o testrunner-TestRefCount.o testrunner-TestServerSocket.o testrunner-TestSlidingWindow.o testrunner-TestSSLSocket.o testrunner-TestSSLSocketFactory.o testrunner-TestSingleton.o testrunner-TestStringKey.o testrunner-TestStringUtilities.o testrunner-TestSubString.o testrunner-TestSystem.o testrunner-TestTCPRawStream.o testrunner-TestTCPSocket.o testrunner-TestTCPStream.o testrunner-TestThreadPool.o testrunner-TestTSDVar.o testrunner-TestTask.o testrunner-TestThread.o testrunner-TestTicks.o testrunner-TestTime.o testrunner-TestTimer.o testrunner-TestWinEnv.o testrunner-Testfilefun.o testrunner-TinyHTTP.o testrunner-Testpathfun.o testrunner-utiltestutil.o testrunner-TestDouble.o testrunner-TestLockedFile-unix.o testrunner-TestSystem-unix.o ../../testmain/libtestmain.a -L/usr/local/tools/powerpc_AIX71/cppunit/lib -lcppunit ../../util/libutil.a -lpthread -L/usr/local/tools/powerpc_AIX71/openssl-0.9.8y/lib -lssl -lcrypto
libtool: link: warning: library `/usr/local/tools/powerpc_AIX71/cppunit/lib/libcppunit.la' was moved.
libtool: link: warning: library `/usr/local/tools/powerpc_AIX71/cppunit/lib/libcppunit.la' was moved.
/usr/local/tools/powerpc_AIX71/gcc-4.3.6/bin/g++ -DUSE_PROFILING -DUSE_LOGGING -DHAVE_UNIX -DHAVE_AIX -g -O2 -static-libgcc -o testrunner buildinfo.o testrunner-TestAtomicValue.o testrunner-TestCondition.o testrunner-TestCounter.o testrunner-TestECVersion.o testrunner-TestExec.o testrunner-TestExecTimeProfiler.o testrunner-TestExpirableStack.o testrunner-TestFileAttributes.o testrunner-TestGetOpt.o testrunner-TestHTTPStream.o testrunner-TestLock.o testrunner-TestLogger.o testrunner-TestMutex.o testrunner-TestNamedTimer.o testrunner-TestRBList.o testrunner-TestRange.o testrunner-TestRefCount.o testrunner-TestServerSocket.o testrunner-TestSlidingWindow.o testrunner-TestSSLSocket.o testrunner-TestSSLSocketFactory.o testrunner-TestSingleton.o testrunner-TestStringKey.o testrunner-TestStringUtilities.o testrunner-TestSubString.o testrunner-TestSystem.o testrunner-TestTCPRawStream.o testrunner-TestTCPSocket.o testrunner-TestTCPStream.o testrunner-TestThreadPool.o testrunner-TestTSDVar.o testrunner-TestTask.o testrunner-TestThread.o testrunner-TestTicks.o testrunner-TestTime.o testrunner-TestTimer.o testrunner-TestWinEnv.o testrunner-Testfilefun.o testrunner-TinyHTTP.o testrunner-Testpathfun.o testrunner-utiltestutil.o testrunner-TestDouble.o testrunner-TestLockedFile-unix.o testrunner-TestSystem-unix.o -L/usr/nimbus/out/powerpc_AIX71/nimbus/agent ../../testmain/libtestmain.a -L/usr/local/tools/powerpc_AIX71/cppunit/lib /usr/local/tools/powerpc_AIX71/cppunit/lib/libcppunit.a ../../util/libutil.a -lpthread -L/usr/local/tools/powerpc_AIX71/openssl-0.9.8y/lib -lssl -lcrypto
ld: 0711-224 WARNING: Duplicate symbol: .bcopy
ld: 0711-224 WARNING: Duplicate symbol: .virtual thunk to CppUnit::OStringStream::~OStringStream()
ld: 0711-224 WARNING: Duplicate symbol: .virtual thunk to CppUnit::OStringStream::~OStringStream()
ld: 0711-224 WARNING: Duplicate symbol: virtual thunk to CppUnit::OStringStream::~OStringStream()
ld: 0711-224 WARNING: Duplicate symbol: virtual thunk to CppUnit::OStringStream::~OStringStream()
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
The various warnings look unrelated to me. Does anyone have any suggestions of what to check next?
I read V8 hello world example, and follow the steps in the document to build v8 successfully.
But when I compile the example code, link error occured. Here comes my computer detail and error prompts.
OS Ubuntu 13.10 amd64
GCC (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
Compile command:
g++ -Iinclude hello_world.cc -o hello_world -Wl,--start-group out/native/obj.target/{tools/gyp/libv8_{base.x64,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt
Error prompts
/usr/bin/ld: /home/leon/Documents/v8/v8/out/native/obj.target/v8_base.x64/src/platform/mutex.o: undefined reference to symbol 'pthread_mutexattr_settype##GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
The error suggests that you need to add the pthread library to your link command. Just append -lpthread.
(It's a bit odd that it identifies exactly which library you need, then tells you it refuses to use it because you didn't list it on the command-line...)
I'm trying to build a specific program on Ubuntu 12.04 64 bit.
The program needs to be compiled 32 bits.
I installed the ia32-libs and gcc-multilib packages.
I managed to compile it on 3 different computers, but on this one, it fails with a weird error.
for some reason, libm.so is not picked up correctly, or something is wrong with the library.
This is the actual compilation line that fails as it was extracted from the Makefile.
gcc -o x86_32_obj/foo x86_32_obj/foomain.o -m32 -fPIC -fno-stack-protector -lc -lgcc -lm -lpthread -lrt -lstdc++ ../libfoo/lib/./libfii.x86_32.a
This is the output
/usr/bin/ld: ../libfoo/lib/./libfoo.x86_32.a(NK_Meas.o): undefined reference to symbol 'expf##GLIBC_2.0'
/usr/bin/ld: note: 'expf##GLIBC_2.0' is defined in DSO /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib32/libm.so so try adding it to the linker command line
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib32/libm.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[1]: *** [foo] Error 2
make: *** [foo] Error 2
I have seen errors such as this in relation to the linking order. It may be possible to address the error by placing the libm linking directive at the very end of your linking configuration.
These interdependencies are very much system dependent, which is probably why the same command works on other systems.
Found the problem.
Apparently, the library file I was linking against was compiled using a different version of GCC.
I don't know how exactly it's related, but once I replaced the gcc compiler to the one used with the library it worked.