PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Link problems
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
jwillemsen



Joined: 27 Sep 2004
Posts: 10

PostPosted: Sun Oct 24, 2004 5:36 am    Post subject: Link problems Reply with quote

Hi,

I am trying to build an EXE that links with some own build shared libararies on linux (suse 91). I now get unresolved externals on everything I use of my own shared libraries. Any ideas of options I can test

Some output:

pgCC -O3 -g -D_REENTRANT -DACE_HAS_AIO_CALLS -I/home/build/ACE/PG/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I../../.. -I../../../Kokyu -c -o .obj/MIF.o MIF.cpp
pgCC -O3 -g -D_REENTRANT -DACE_HAS_AIO_CALLS -I/home/build/ACE/PG/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I../../.. -I../../../Kokyu -L/home/build/ACE/PG/ACE_wrappers/ace -L./ -L../../../lib -o MIF .obj/MIF.o -lKokyu -lACE -ldl -lpthread -lrt
.obj/MIF.o(.text+0x130): In function `main':
/home/build/ACE/PG/ACE_wrappers/Kokyu/tests/DSRT_MIF/MIF.cpp:130: undefined reference to `_Q2_5Kokyu26DSRT_Dispatcher<>::create_DSRT_dispatcher__Q2_5Kokyu54DSRT_Dispatcher_Factory__tm__23_20mif_scheduler_traitsSFRCQ2_5Kokyu15DSRT_ConfigInfo_Q2_3std54auto_ptr__tm(void)'
.obj/MIF.o(.text+0x73b):/home/build/ACE/PG/ACE_wrappers/Kokyu/tests/DSRT_MIF/MIF.cpp:180: undefined reference to `Kokyu::DSRT_Dispatcher<mif_scheduler_traits>::shutdown(int (void))'
.obj/MIF.o(.text+0xa56): In function `MyTask':
/home/build/ACE/PG/ACE_wrappers/Kokyu/tests/DSRT_MIF/MIF.cpp:60: undefined reference to `__pp__41ACE_Atomic_Op__tm__20_16ACE_Thread_MutexlFv_Z2Z'
.obj/MIF.o(.text+0xc29): In function `svc':
/home/build/ACE/PG/ACE_wrappers/Kokyu/tests/DSRT_MIF/MIF.cpp:78: undefined reference to `schedule__Q2_5Kokyu46DSRT_Dispatcher__tm__23_20mif_scheduler_traitsFQ2_Z1Z6Guid_tRCQ2_Z1Z15QoSDescriptor_t_i'
.obj/MIF.o(.text+0xe2f):/home/build/ACE/PG/ACE_wrappers/Kokyu/tests/DSRT_MIF/MIF.cpp:115: undefined reference to `cancel_schedule__Q2_5Kokyu46DSRT_Dispatcher__tm__23_20mif_scheduler_traitsFQ2_Z1Z6Guid_t_i'

The full log is online at
http://www.dre.vanderbilt.edu/~remedynl/SuSE_x86_64_pgi/
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Mon Oct 25, 2004 9:45 am    Post subject: Reply with quote

Hi Johnny,


Using templates in libraries is a bit tricky since template instantiation occurs at link time. Since your library objects have not been linked, the instantiated object does not exist and is why your getting link errors.

Chapter 11 of the PGI user guide details C++ template instantiation. In particular, section 11.5 gives the steps needed to create libraries that include templates. Although the example uses a static library, the same steps are needed for dynamic libraries.

The basic steps are as follows:
    1. You'll need to add the flag "--one_instantiation_per_object" to the compilation of each library object.
    2. Next link the objects with the flags "--one_instantiation_per_object --prelink_objects" to instantiate the templates to an object file (located in the "Template.dir" directory).
    3. Finally, create the dynamic library as normal, but include all the Template directory's object files on the link line.


- Mat
Back to top
View user's profile
jwillemsen



Joined: 27 Sep 2004
Posts: 10

PostPosted: Tue Oct 26, 2004 12:06 am    Post subject: Reply with quote

Ok, I will try this, one thing already. Templates are really standard in C++, a lot of them are used. What I find strange that because I use templates I have to add some compiler options, but also that I can't use debug builds anymore, this is not real handy.

pgCC --one_instantiation_per_object -O3 -g -D_REENTRANT -DACE_HAS_AIO_CALLS -I/home/build/ACE/PG/ACE_wrappers -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -DACE_HAS_ACE_TOKEN -DACE_HAS_ACE_SVCCONF -DACE_BUILD_DLL -c -fPIC -o .shobj/Naming_Context.o Naming_Context.cpp
Warning: --one_instantiation and debug not yet supported
PGCC-W-0000-Internal compiler error. read_debug_info: unable to read debug file 0 (Naming_Context.cpp)
pgCC-Fatal-/usr/pgi/linux86-64/5.2/bin/pgcpp2 TERMINATED by signal 11
Arguments to /usr/pgi/linux86-64/5.2/bin/pgcpp2
Back to top
View user's profile
jwillemsen



Joined: 27 Sep 2004
Posts: 10

PostPosted: Tue Oct 26, 2004 12:35 am    Post subject: Reply with quote

Ok, I now got further. I use now the following command to build an exe that used the shared libs. No link error, but I can't find an ACE_Init_Test on disk, I expect it in the current directory, any hints?

pgCC --one_instantiation_per_object --prelink_objects -Wc,-tused -O3 -D_REENTRANT -DACE_HAS_AIO_CALLS -I/home/build/ACE/PG/ACE_wrappers -DACE_NDEBUG -DACE_USE_RCSID=0 -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -DACE_AS_STATIC_LIBS -c -o .obj/ACE_Init_Test.o ACE_Init_Test.cpp
pgCC --one_instantiation_per_object --prelink_objects -Wc,-tused -O3 -D_REENTRANT -DACE_HAS_AIO_CALLS -I/home/build/ACE/PG/ACE_wrappers -DACE_NDEBUG -DACE_USE_RCSID=0 -DACE_HAS_EXCEPTIONS -DACE_NO_INLINE -I.. -DACE_AS_STATIC_LIBS -L/home/build/ACE/PG/ACE_wrappers/ace -L./ -L../lib -o ACE_Init_Test .obj/Main.o .obj/ACE_Init_Test.o -lTest_Output -lACE -ldl -lpthread -lrt
make[1]: Leaving directory `/home/build/ACE/PG/ACE_wrappers/tests'
make[1]: Entering directory `/home/build/ACE/PG/ACE_wrappers/tests'
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Tue Oct 26, 2004 8:12 am    Post subject: Reply with quote

You only want to use "--one_instantiation_per_object --prelink_objects" to pre-link the library. You shouldn't use it when compiling your application since "--prelink_objects" causes pgCC to stop after the prelink step and no executable will be created.

I'll need to get back to you with the details as to why "-g" doesn't work with "--one_instantiation" since I don't know off hand.

- Mat
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