|
|
 |
 |
 |
 |
Fortran Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
compile/linking problem, undefined symbol
Hi to all: Say, I thought I had a homogeneous multi-platform setup in that I am able to compile everything in the same way in Windows, Linux and Solaris...at least so far. Now, though, I have run into a program that compiles for windows and linux but not for solaris. Here is the error message: %%%%%%%%%%%%%%%%%%%%%% make f g95 -I/home/salazag/libraries/include -O2 -i4 -r8 -fzero -fstatic - ffixed-line-length-132 -ftrace=full -fbounds-check -Wall -fno- underscoring -c testF_sun.F g95 -s -static -L/home/salazag/libraries/lib -o testF_sun testF_sun.o -lhdgf_sun Undefined first referenced symbol in file _dlopen /lib///libc.a(nss_deffinder.o) _dlsym /lib///libc.a(nss_deffinder.o) _dlclose /lib///libc.a(nss_deffinder.o) ld: fatal: Symbol referencing errors. No output written to testF_sun make: *** [f] Error 1 %%%%%%%%%%%%%%%%%%%%%% Any ideas as to what could be? Like I said, the same program compiles and runs correctly in Linux and Windows, so I am thinking that somehow I don't have a complete installation in Solaris? although I thought I had done the same for both Linux and Solaris, back when I installed g95. If I add -lgcc, the same thing happends...I have libgcc.a somewhere under the libraries/lib/gcc sugdirectory, but I guess g95 is looking for libc, which is nowhere to be found under my libraries/lib. If I add -L/usr/lib (there is a libc.a, there) and -lc, the list of undefined symbols does not change, but the name of the "referenced in file" goes from /lib///libc.a, to /usr/lib/libc.a By the way, all the program does is use a few subroutines from the library; the library in turn, all it does is read from standard input and write to standard output. Any pointers? gsal
gsal wrote: > Now, though, I have run into a program that compiles for windows and > linux but not for solaris. Here is the error message: > %%%%%%%%%%%%%%%%%%%%%% > make f > g95 -I/home/salazag/libraries/include -O2 -i4 -r8 -fzero -fstatic - > ffixed-line-length-132 -ftrace=full -fbounds-check -Wall -fno- > underscoring -c testF_sun.F > g95 -s -static -L/home/salazag/libraries/lib -o testF_sun > testF_sun.o > -lhdgf_sun > Undefined first referenced > symbol in file > _dlopen /lib///libc.a(nss_deffinder.o) > _dlsym /lib///libc.a(nss_deffinder.o) > _dlclose /lib///libc.a(nss_deffinder.o) > ld: fatal: Symbol referencing errors. No output written to testF_sun > make: *** [f] Error 1 > %%%%%%%%%%%%%%%%%%%%%% > Any ideas as to what could be? Like I said, the same program > compiles > and runs correctly in Linux and Windows, so I am thinking that > somehow > I don't have a complete installation in Solaris? although I thought I > had done the same for both Linux and Solaris, back when I installed > g95.
Doesn't g95 have an option, similar to gfortran -v, to show which libraries are linked? Did you even try looking to see which Solaris library would define those symbols? Is your copy of g95 set up for your specific Solaris version?
> Undefined first referenced > symbol in file > _dlopen /lib///libc.a(nss_deffinder.o) > _dlsym /lib///libc.a(nss_deffinder.o) > _dlclose /lib///libc.a(nss_deffinder.o)
What about adding -ldl to your compiler options? -- FX
gsal wrote: > Hi to all: > Say, I thought I had a homogeneous multi-platform setup in that I am > able to compile everything in the same way in Windows, Linux and > Solaris...at least so far. > Now, though, I have run into a program that compiles for windows and > linux but not for solaris. Here is the error message: > %%%%%%%%%%%%%%%%%%%%%% > make f > g95 -I/home/salazag/libraries/include -O2 -i4 -r8 -fzero -fstatic - > ffixed-line-length-132 -ftrace=full -fbounds-check -Wall -fno- > underscoring -c testF_sun.F > g95 -s -static -L/home/salazag/libraries/lib -o testF_sun > testF_sun.o > -lhdgf_sun > Undefined first referenced > symbol in file > _dlopen /lib///libc.a(nss_deffinder.o) > _dlsym /lib///libc.a(nss_deffinder.o) > _dlclose /lib///libc.a(nss_deffinder.o) > ld: fatal: Symbol referencing errors. No output written to testF_sun > make: *** [f] Error 1 > %%%%%%%%%%%%%%%%%%%%%% > Any ideas as to what could be? Like I said, the same program > compiles > and runs correctly in Linux and Windows, so I am thinking that > somehow > I don't have a complete installation in Solaris? although I thought I > had done the same for both Linux and Solaris, back when I installed > g95. > If I add -lgcc, the same thing happends...I have libgcc.a somewhere > under the libraries/lib/gcc sugdirectory, but I guess g95 is looking > for libc, which is nowhere to be found under my libraries/lib. > If I add -L/usr/lib (there is a libc.a, there) and -lc, the list of > undefined symbols does not change, but the name of the "referenced in > file" goes from /lib///libc.a, to /usr/lib/libc.a > By the way, all the program does is use a few subroutines from the > library; the library in turn, all it does is read from standard input > and write to standard output. > Any pointers?
Out of curiosity, why are you linking -static? That might be part of the problem. Another poster suggested adding -ldl to your link command; that will work with -static if your distribution includes libdl.a, but apparently not all do. (I did a Google search for libdl.a, and found some things that you might find useful.) Louis
Louis Krupp wrote: > Out of curiosity, why are you linking -static? That might be part of > the problem. > Another poster suggested adding -ldl to your link command; that will > work with -static if your distribution includes libdl.a, but apparently > not all do. (I did a Google search for libdl.a, and found some things > that you might find useful.)
One or another of these answers pertain to certain versions of linux, and not to others. A quick inquiry of Google will show in a similar way that current Solaris no longer uses libdl the same way as previous versions. So, OP leaves us stuck, even those more expert in Solaris, by failing to give sufficient information. It is common for Fortran compilers to include -ldl as a default part of the link command, when installed on an OS version where that is appropriate. Hence the advice to quote the link command, and look to see which libraries (static or dynamic) may contain the symbols. All this would be pretty much FAQ material, if we knew of an applicaable FAQ.
Well, you are all correct. I looked for the dl library and discovered that my linux distribution does include shared and static instances of dl, whereas my Solaris distribution only includes the sahred one. Simply removing -static resolved my problem in Solaris. I went ahead and google for libdl.a as suggested and I did find that SunOS stopped including libdl.a sometime ago; then again, there are a few workarounds offered, even one from Sun itself...I will explore my options. Thank you very much to all. gsal
|
 |
 |
 |
 |
|