1832592 Members
2739 Online
110043 Solutions
New Discussion

Re: Makefiles

 
Adityavikram
Occasional Contributor

Makefiles

How do I compile a C++ program so that it links to different shared libraries and gives me a binary (executable)? What are the options ? I am able to compile it and when I run the binary C++ , it core dumps ! Gives me bus error ! Any inputs would be appreciated .

Sample of my makefile.
aCC -v +Z -c +DAportable -DTRUE -DFALSE -DRW_NO_BOOL -DRW_MULTI_THREAD -D_REENTRANT -DRW_THR_OS_VERSION_HPUX=0x1020 -DRWSTD_MULTI_TH
READ -D_THREAD_SAFE -o TH1.o TH1.C -I. -I/kernel/kif -I/general/sms -I/opt/rw_990128/workspaces/HPUX1020/ACC115/12d -I/general/commo
n -I/general/clientserver -I/general/smci -I/iod/common/utils -I/iod/common/pda -I/iod/common/ncast -I/iod/common/services

aCC -v -o TH1 TH1.o -Wl,-a,shared -L. -L/opt/rw_990128/workspaces/HPUX1020/ACC115/12d/lib -ltls12d -lstd12d -L/general/smci -lsmci -
L/general/common -lcommon -L/general/clientserver -lclientserver -L/general/smci -lsmci -L/iod/common/utils -lutils -L/iod/common/pd
a -lpda -L/iod/common/ncast -L/iod/common/services -lservices1 -lncast
5 REPLIES 5
Steven Gillard_2
Honored Contributor

Re: Makefiles

You should not use the +Z flag if you are not creating a shared library out of your .o file. Remove the +Z flag from your Makefile and try again.

Please have a good read of the HPUX Linker and Libraries guide, its an excellent reference for information about creating & using shared libraries.

You can find it at:
http://docs.hp.com/hpux/onlinedocs/B2355-90654/B2355-90654.html

Regards,
Steve
Deepak Extross
Honored Contributor

Re: Makefiles

Why do you suspect your compiler options? Core Dumps due to Bus Error typically spring from incorrect use of pointers, array/buffer overflows, using uninitialized memory or other such memory corruption (read abuse).
Try to use a debugger to backtrace the core and figure out where the problem lies.
Santosh Nair_1
Honored Contributor

Re: Makefiles

I would agree with Deepak. Also look at using tusc to trace system calls. You can get tusc from the HP porting center and you can get WDB from HP. This will help you find out where the program crashes. Remember a debugger is your friend.
Life is what's happening while you're busy making other plans
Adityavikram
Occasional Contributor

Re: Makefiles

Steven - thanks for ur input but unfortunately it does not seem to work .

Deepak and Santosh, as for your query why I think the problem is with makefile options is because, the program runs if I use static libraries instead of shared libraries!
Deepak Extross
Honored Contributor

Re: Makefiles

Hi,

You may want to verify that the shared libraries in the runtime environment are identical to those in your compilation environment.

Do a 'chatr +s disable ', and then run the exe on the same machine where you have compiled. This will force it to use the same libraries used at compile-time.