PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Cross linking issue
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
naadir



Joined: 04 Apr 2014
Posts: 3

PostPosted: Sat Apr 05, 2014 6:46 pm    Post subject: Cross linking issue Reply with quote

I will be grateful if someone can answer my question.

I created a source file with a single function and built it using pgcpp on windows and generated an .obj file. When I use this function (with the generated .obj file) in my program (which is compiled using MSVC 2012), I always get LNK 2019: unresolved external symbol error. Does it mean that .obj files compiled using pgcpp are not linkable with .obj files compiled with MSVC? I just confirmed that the same issue exists with GCC on Linux.

If this is not possible, how should I call a function compiled using pgcpp from my program which is compiled using MSVC (or GCC on Linux)? In pgcpp, Is there a way to generate binary compatible object files with startard OS compilers?

I also tried putting the object files into a static link library and tried to link with that one. Unfortunately, I am still getting the same linker errors in both platforms.

Thanks,
Nadir
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Mon Apr 07, 2014 9:09 am    Post subject: Reply with quote

Hi Nadir,

I checked with our C++ developer, and object files generated by PGI C++ on Windows are not interoperable with object files generated by VS2010 C++. I believe the same is also true for Linux with GNU C++, due to differences in the C++ runtime libraries.

Best regards,

+chris
Back to top
View user's profile
naadir



Joined: 04 Apr 2014
Posts: 3

PostPosted: Wed Apr 09, 2014 4:17 am    Post subject: Reply with quote

Hi Chris,

Thanks for the answer. Is there any way to call the function inside the PGI compiled object file from the object file compiled with other compiler. When I try generating a static/dynamic link library and trying to call the function from there, I am getting the following linker errors:


undefined reference to `__pgi_uacc_dataenterdone'
undefined reference to `__pgi_uacc_dataona'
undefined reference to `__pgi_uacc_computestart'
undefined reference to `__pgi_uacc_enter'
......................
......................
......................

What might be the library file I need to link with to avoid those linker errors? I used recursive ldd to query the external dependencies, but those symbols are also not located in those libraries.
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Wed Apr 09, 2014 10:25 am    Post subject: Reply with quote

Hi Nadir,

Those symbols are defined in the PGI runtime. If you compile something with PGI C++, you will need to link in a series of runtime libraries to resolve internal references created by the C++ compiler.

If you pass -v to pgcpp, the driver should show you the steps involved in compiling and linking a C++ program. In particular, the link step will show you which libraries are needed for C++:

Code:

/usr/bin/ld /usr/lib64/crt1.o /usr/lib64/crti.o /proj/pgi/linux86-64/14.3/lib/trace_init.o /usr/lib/gcc/x86_64-redhat-linux/4.4.6/crtbegin.o /proj/pgi/linux86-64/14.3/lib/initmp.o -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /proj/pgi/linux86-64/14.3/lib/pgi.ld -L/proj/pgi/linux86-64/14.3/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.4.6 /tmp/pgcppvzgi-9Y4rxrl.o -rpath /proj/pgi/linux86-64/14.3/lib -o hello -lzceh -lgcc_eh --eh-frame-hdr -lstdz -lCz -lpgmp -lnuma -lpthread -lnspgc -lpgc -lm -lgcc -lc -lgcc /usr/lib/gcc/x86_64-redhat-linux/4.4.6/crtend.o /usr/lib64/crtn.o


Here, everything that starts with a "-l" indicates a runtime library.

Depending on which flags you are passing, you may need additional libraries. I notice that some of the undefined symbols you referenced here are actually defined in libaccg.a (pull in via -laccg).

Hopefully this helps.

Best regards,

+chris
Back to top
View user's profile
naadir



Joined: 04 Apr 2014
Posts: 3

PostPosted: Thu Apr 10, 2014 10:47 am    Post subject: Reply with quote

Hi Chris,

Thanks a lot for your helps. I am now able to link fine with the dynamic library built with PGI wth my GCC built executable. However, I am getting the runtime error:

Accelerator Fatal Error: No CUDA device code available

I am not getting that error when I run the same code using the PGI compiler only. I also couldn't find that error in the documentation. Could you also help me on this?

Best regards,
Nadir
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group