Hello, we are two undergrad students currently working on the parallelization of a program that’s performing calculations that involve searching through large ranges of integers, using nvc++ and OpenACC. We are using the Number Theory Library (NTL).
Our current workflow is compiling the library with g++ and statically linking it with our program, which we then compile using nvc++ and OpenACC.
After modifying the NTL header files with the necessary ‘#acc declare’ and ‘#acc routine seq’ directives, we encountered several “nvlink error: Undefined reference to …” errors, which appear to be related to the compiler not finding the necessary definitions of the NTL functions used in our code that are declared in the NTL header files.
As a demonstration of our problem, we have attached a small code example (test.c), a compile.sh to compile our example, and the build.sh we’re using to build NTL. When compiling this example, we encountered the following errors, which are representative of the errors we get when compiling our main program:
nvlink error : Undefined reference to ‘_ZN3NTL6randomERNS_5ZZ_pXEl’ in ‘/tmp/nvc++zSofl4tYMlby.o’
nvlink error : Undefined reference to ‘_ZN3NTL12BlockDestroyEPNS_4ZZ_pEl’ in ‘/tmp/nvc++zSofl4tYMlby.o’
nvlink error : Undefined reference to ‘_ZN3NTL9ZZ_pEInfoE’ in ‘/tmp/nvc++zSofl4tYMlby.o’
We were able to trace the _ZN3NTL9ZZ_pEInfoE error back to line 36 of ZZ_pE.h (it’s probably related to the missing definition of ZZ_pEInfo due to the use of “extern”). The _ZN3NTL12BlockDestroyEPNS_4ZZ_pEl error is probably related to the BlockDestroy-method in ZZ_p.h, line 553, whose definition in vec_ZZ_p.cpp cannot be found by the compiler.
Since we’re still new to OpenACC, we are unable to fix these errors without creating new ones. Are these problems related to the fact the we’re using different compilers for building the library and compiling our program? Or does the problem lie somewhere else? Thanks for your help in advance!
Small Example.zip (890 Bytes)