static and shared library options for aCC (368 Views)
Reply
Occasional Visitor
Ram Regar
Posts: 5
Registered: ‎11-10-2009
Message 1 of 8 (368 Views)
Accepted Solution

static and shared library options for aCC

Hi,
I have

module1 should be built as static library.
module2 should be a shared library and it should like module1 statically.

module3 is an executable which dynamically links to module2 library.

I am looking for aCC command options to achieve this goal.

It should work on 64 and 32 bit OS.

Thanks,
Ram
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,962
Registered: ‎03-06-2006
Message 2 of 8 (368 Views)

Re: static and shared library options for aCC

>module1 should be built as static library.

(The correct HP-UX terminology is archive lib.)
What OS and architecture are you using?

>I am looking for aCC command options to achieve this goal.

aCC -c foo1.c foo2.c
ar -rv libmod1.a foo1.o foo2.o

aCC -c +z foo3.c foo4.c
aCC -b o libmod2.so foo3.o foo4.o -L . -lmod1

aCC -c foo5.c foo6.c
aCC -o module3 foo5.o foo6.o -L . -lmod2

For Integrity see:
http://docs.hp.com/en/14487/libs.htm
Please use plain text.
Occasional Visitor
Ram Regar
Posts: 5
Registered: ‎11-10-2009
Message 3 of 8 (368 Views)

Re: static and shared library options for aCC

Thank you for ur response.

I have this box.
-bash-3.2$ uname -a
HP-UX ramregar-hp11i B.11.23 U ia64 1869050062 unlimited-user license
-bash-3.2$

I want to build 32-bit and 64-bit builds on the same box.
Thanks,
Ram
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,962
Registered: ‎03-06-2006
Message 4 of 8 (368 Views)

Re: static and shared library options for aCC

>I want to build 32-bit and 64-bit builds on the same box.

The default is 32 bit or you can use +DD32.
And +DD64 for 64 bit.
Please use plain text.
Occasional Visitor
Ram Regar
Posts: 5
Registered: ‎11-10-2009
Message 5 of 8 (368 Views)

Re: static and shared library options for aCC


Thank you so much for your support so far. Please do continue until I finish this.

Module1 a static library.
aCC -O -g0 -O2 +Oopenmp +z +DD64 -b -Wl,-ashared -D_HPUX -D__LP64__ -DPIC -I/build/jdk/include -lunalign -o/build/rel/lib/static/libmodule1.a *.cpp *.c

Module2 a dynamic library which statically links the Module1
aCC -O -g0 -O2 +Oopenmp +z +DD64 -b -n -v -D_HPUX -D__LP64__ -I/build/jdk/include -Wl,-L/build/rel/lib/static/ -lmodule1 -o/build/rel/lib/libmodule.so *.cpp *.c

Module3 a dynamic library which statically links the module1
aCC -O -g -O2 +Oopenmp +z +DD64 -b -v -ashared -D_HPUX -D__LP64__ -L/build/rel/lib/static/ -lmodule1 -o/build/rel/lib/libmodule3.so *.cpp

Module4 an executable which dynamically links module2. Module2 loads Module3 at runtime.
aCC +DD64 +Oopenmp -I/build/clients/include -L/build/rel/lib/ -lmodule2 -lrt -lunalign -o/build/bin/module4 *.cpp


aCC version:
aCC: HP C/aC++ B3910B A.06.23 [May 18, 2009]


Problem:
When I run module4
/usr/lib/hpux64/dld.so: Unsatisfied data symbol '_ZTV14MyListener' in load module '../lib/libmodule2.so'.
Killed

I looked in library with nm command. Here is the output.

build@hp16 /build/rel/lib $ nm -D libmodule2.so | grep MyListener
[4825] | 4611686018430846112| 288|FUNC |GLOB |0| .text|_Z17createNewListenerP14MyListenerPP9_listenerPFvP12_space_eventPvES6_
[4748] | 4611686018431064384| 416|FUNC |GLOB |0| .text|_ZN6CSpace5startEP14MyListenerP11CBrowserDef
[2880] | 0| 0|OBJT |GLOB |0| UNDEF|_ZTV14MyListener
[1065] | 4611686018431074480| 112|FUNC |LOCAL|0| .text|__sinit_MyListener_cpp_
[1064] | 0| 0|FILE |LOCAL|0| ABS|MyListener.cpp
build@hp16 /build/rel/lib $

I would appreciate your help. Please do review compiler options and suggest me the changes.

Regards,
Ram Regar
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,962
Registered: ‎03-06-2006
Message 6 of 8 (368 Views)

Re: static and shared library options for aCC

>module1 a static library.

Again, please use the correct terminology. There are only archive and shared libs.
In this case, this is a shared lib since you used -b and not ar(1).

>aCC -O -g0 -O2 +Oopenmp +z +DD64 -b -Wl,-ashared -D__LP64__ -lunalign -o /build/rel/lib/static/libmodule1.a *.cpp *.c

There is no need for both -O and +O2. There is no need to define -D__LP64__ or -Wl,-ashared, they are set by the driver or the default. Also, why bother with +Oopenmp?
Also, you should NOT use -b with libmodule1.a. Rename it to libmodule1.so.

>module2 a dynamic library which statically links the module1
>aCC -O -g0 -O2 +Oopenmp +z +DD64 -b -n -v -Wl,-L/build/rel/lib/static/ -lmodule1 -o /build/rel/lib/libmodule.so *.cpp *.c

The output should be libmodule2.so
Remove useless -n. Also remove "-Wl," before -L.

>module4 an executable which dynamically links module2. module2 loads module3 at runtime.
>aCC +DD64 +Oopenmp -lmodule2 -lrt -lunalign -o/build/bin/module4 *.cpp

And also has module1 as a dependent shlib.

dld.so: Unsatisfied data symbol _ZTV14MyListener load module ../lib/libmodule2.so
>I looked in library with nm command.

Where should it be defined? Where have you defined the class MyListener and the first non-inline virtual function?
Please use plain text.
Occasional Visitor
Ram Regar
Posts: 5
Registered: ‎11-10-2009
Message 7 of 8 (368 Views)

Re: static and shared library options for aCC

Thank you Dennis Handly I appreciate your help. Your quick help has been very helpful to me. Thank you.
Please use plain text.
Occasional Visitor
Ram Regar
Posts: 5
Registered: ‎11-10-2009
Message 8 of 8 (368 Views)

Re: static and shared library options for aCC

Dennis Handly is a great help. He definitely deserve 100/100.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation