I've tried to figure out what the linker is smoking in AIX to no avail...so I'm trying to find a little information to see why it's being inconsistent.
I have the following code in a shared library, it doesn't do anything useful, it's just there to exercise functions in a few system libraries:
It is built as follows:
Now, I have a very simple main application:
Built as follows:
I expect that ldd would say that main needs pthread, curses, and the math library in addition to sh at this point, but it doesn't. What ldd says is:
Ok...fine, but when I run it, even though I asked it to link main to curses, it did not. Therefore, I get a run time error from rtld that the symbols (initsrc and endwin) aren't found and libsh.o needs them.
Interesting...so, for grins I modify main to use something from curses:
Build it the same way, and now ldd picks up the curses library requirement on main. It also runs now. That's pretty...interesting...but I suppose the linker is being smarter than me...or is it.
Let's go back to the first main, without the call to endwin. We'll link him a few ways, here's the results:
Build 1:
Build 2:
Interesting, I change nothing in the main source, I don't use anything from pthreads in main, but the linker does put a dependency on pthreads when I ask it to during the second build. As expected it doesn't run.
Now we'll go back to the second version of main where it uses something from curses and build him a few ways:
Build 1:
Expected, I'm trying to use endwin...let's link him; build 2:
Ok...getting closer, since we use endwin, it decides it is needed and, as such, pulls it in. But, I still didn't link math, so there's no sin and it won't run. That's all well and good, but I don't use anything from math in mainsrc.c, so if you follow the same logic that was needed to get curses to link, you'd think I'd need to use something...but, build 3:
And it works. The funny thing is, there is NO CHANGE to the output of ldd between the two versions. One works, one doesn't....same ldd output, and I didn't need to put anything in main to pick up the math library.
So...this isn't consistent, if fact it's downright mind boggling. I'm wondering if anyone can shed some light on why this is happening.
I also want to note that I can fix all this stupidity by changing the way I link the library. If I link the library to the pthreads, curses, and math library as follows:
Then I can build mainsrc.c as follows:
And it works fine and the ldd output is almost identical (just with the order switched) to the working version above. I realize that this is probably the "best" way to link this stuff together so that the library states its dependencies, but I can't always have control over how the library was built (we don't build them all) and so I'm running into these oddities.
Sorry for the long post...but this AIX linker is driving me nuts!
P.S. None of this stupidity happens in Linux. In Linux, the minute I try to build main linking to sh without any of the required libraries (pthread, math, ncurses) it complains and won't build.
I link it the way I expect to work in AIX:
And it works without a hitch. Seems like Linux's linker has its act a little better together, or it's just AIX's stupid "shared archive" vs. "shared library" crap that's messing with me. I don't know...but that's why I'm posting here...maybe someone familiar with AIX will.
Thanks all!
Last edited by DreamWarrior; 01-26-2011 at 04:34 PM..
hai
I have installed Linux 7.0 on my system and i have an doubt the
linker
i ran simple hello.c program with gcc compiler
gcc -c hello.c
i want linker to produce the output
so i put on the command line as
ld first.o -lc
but it is not running ver properly
but there is an... (1 Reply)
I have recently set up a connection b/t a sun ultra 60 running solaris 8 and a regular old pc running XP. Unfortunately I only know a little bit about networking thanks to Winblows plug and play mentality. Can anyone tell me why my connection from PC to sun is intermittant? The IP is always... (2 Replies)
Hi All
Could anyone help in giving a little background to the following runtime error.
/usr/lib/pa20_64/dld.sl: Mmap failed due to errno: 13.
Seen when executing a 64-bit ELF executable.
Thanks
Ed (3 Replies)
Hi All,
I m new to this group.
I m facing one problem during my linking of CPP code at Linux env.
after compliation i m getting error
"undefined reference to ....."
Please anyone help me to resolve this error.
Regards,
ASR
make: Leaving directory /fwk'
echo g++ -o server ... (1 Reply)
Hi,
The necessary symbols in a shared library can be exported to the application using linker option --version-script in Linux. The same can be done in Hp-ux using linker option +e. This can also be done by listing all the global symbols with +e in a file with linker option ld -c filename in... (0 Replies)
Hi,
I do not use the default linker, and instead us another one and pass this argument -Wl,--dynamic-linker=<path to linker> to gcc when compiling. However, what happens if the linker is not under /lib and /lib64 and I am not able to create a symlink to the linker in /lib or /lib64 due to no... (2 Replies)
Hai,
I have two (Pgm1.c and Pgm2.c) simple programs, which is compiled using gcc. Now we have two exe's (Pgm1 and Pgm2). When i executed the nm Pgm1 and nm Pgm2, in the listed symbols the address of main is same for both programs (08048344 T main) at run time also.
Doubt:
1) What is this... (3 Replies)
Hey guys
I have a solaris 10 OS, with a zone configured. In that zone, I am trying to install an Oracle Client. However, when I run the oracle installer, I get the following error:
ld.so.1: java: fatal: libexpat.so.0: open failed: No such file or directory
ld.so.1: java: fatal:... (2 Replies)
Hello all,
I am releatively new to Solaris and I am the System administrator for my branch at the FAA. This is the first time I can say I have really messed something up thankfully. My issue came up after installing and uninstalling Oracle Secure Backup which i felt I needed to do a clean... (7 Replies)