From: John Stone (johns_at_ks.uiuc.edu)
Date: Fri Mar 18 2011 - 10:13:20 CDT

Susana,
  Actually, I don't see any errors from your "make" results. If you
didn't get any, then it presumably linked the code correctly.
Did you try running your fortran code?

Regarding the C++ link error for "empty.cxx":
  The error you get about main not being defined when you tried to compile
the "empty.cxx" is expected, since you compiled an empty source file.
You would have to have the file contain at least "int main() { return 0; }"
for it not to complain.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Fri, Mar 18, 2011 at 01:55:33PM +0000, Susana Tomasio wrote:
> Hi,
>
> Since using a macosx has been a complete nightmare, I got a linux machine
> and I've been trying to compile the fortran bindings on it.
> This is my Makefile:
> ########################################################################
> ARCH = LINUXAMD64
> ARCHDIR = /home/tomasio/plugins/LINUX/molfile
> FC = gfortran
> #FC = g77 #-fno-second-underscore
> CC = gcc
> LD = $(FC)
> OPT = -O2 -Wall
> CPPFLAGS = -I/home/tomasio/plugins/include
> -I/home/tomasio/plugins/LINUX/ # -D_F77_F2C_UNDERSCORE
> CFLAGS = -c $(CPPFLAGS) $(OPT)
> FFLAGS = -c $(OPT)
> NETCDFLIB = -L/home/tomasio/local/lib/
> NETCDFLDFLAGS = -lnetcdf
> TCLLIB = -L/usr/local/lib/
> TCLLDFLAGS = -ltcl8.5
> LDFLAGS = -L$(ARCHDIR) $(TCLLIB) $(NETCDFLIB)
> LDLIBS = -lmolfile_plugin $(NETCDFLDFLAGS) $(TCLLDFLAGS)
> -L/usr/share/doc -lstdc++ -ldl
> ########################################################################
>
> When I type "make" this is what appears on the screen (which is not very
> helpful):
> gfortran -c -O2 -Wall tester.f -o tester.o
>
> "gcc -c -I/home/tomasio/plugins/include -I/home/tomasio/plugins/LINUX/
> -O2 -Wall f77_molfile.c -o f77_molfile.o
> gfortran -o tester -L/home/tomasio/plugins/LINUX/molfile
> -L/usr/local/lib/ -L/home/tomasio/local/lib/ tester.o f77_molfile.o
> -lmolfile_plugin -lnetcdf -ltcl8.5 -L/usr/share/doc -lstdc++ -ldl"
>
> I tried the following:
> touch empty.cxx
> g++ -v empty.cxx
>
> And the output is:
>
> Using built-in specs.
> Target: i486-linux-gnu
> Configured with: ../src/configure -v
> --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
> --enable-shared --with-system-zlib --libexecdir=/usr/lib
> --without-included-gettext --enable-threads=posix --enable-nls
> --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-mpfr --enable-checking=release
> i486-linux-gnu
> Thread model: posix
> gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
> /usr/lib/gcc/i486-linux-gnu/4.1.2/cc1plus -quiet -v -D_GNU_SOURCE
> empty.cxx -quiet -dumpbase empty.cxx -mtune=generic -auxbase empty
> -version -fstack-protector -fstack-protector -o /tmp/cckcOsxg.s
> ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
> ignoring nonexistent directory
> "/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../i486-linux-gnu/include"
> ignoring nonexistent directory "/usr/include/i486-linux-gnu"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/i486-linux-gnu
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward
> /usr/local/include
> /usr/lib/gcc/i486-linux-gnu/4.1.2/include
> /usr/include
> End of search list.
> GNU C++ version 4.1.2 (Ubuntu 4.1.2-0ubuntu4) (i486-linux-gnu)
> compiled by GNU C version 4.1.2 (Ubuntu 4.1.2-0ubuntu4).
> GGC heuristics: --param ggc-min-expand=97 --param ggc-min-heapsize=125504
> Compiler executable checksum: 706aaa0fd1a32f25246d6a043b4a10ca
> as -V -Qy -o /tmp/ccmwjn5H.o /tmp/cckcOsxg.s
> GNU assembler version 2.17.50 (i486-linux-gnu) using BFD version 2.17.50
> 20070103 Ubuntu
> /usr/lib/gcc/i486-linux-gnu/4.1.2/collect2 --eh-frame-hdr -m elf_i386
> --hash-style=both -dynamic-linker /lib/ld-linux.so.2
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crti.o
> /usr/lib/gcc/i486-linux-gnu/4.1.2/crtbegin.o
> -L/usr/lib/gcc/i486-linux-gnu/4.1.2 -L/usr/lib/gcc/i486-linux-gnu/4.1.2
> -L/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib -L/lib/../lib
> -L/usr/lib/../lib /tmp/ccmwjn5H.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s
> -lgcc /usr/lib/gcc/i486-linux-gnu/4.1.2/crtend.o
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crtn.o
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function
> `_start':
> (.text+0x18): undefined reference to `main'
> collect2: ld returned 1 exit status
>
> I think it is a problem with the -L flags but I don't know
> how to fix it.
>
> If anyone has any suggestions I'd be grateful.
>
> Thank you,
>
> Susana
>
> On Mon, Mar 14, 2011 at 11:08 PM, Axel Kohlmeyer <akohlmey_at_gmail.com>
> wrote:
>
> On Mon, Mar 14, 2011 at 5:49 PM, Susana Tomasio <susietomasio_at_gmail.com>
> wrote:
> > Hi John,
> >
> > I see what you mean, but when I add the space between "-ltc8.5"
> > and "-L/usr/lib/" it gives me the previous error:
> >
> > ld: library not found for -lstdc++
> > collect2: ld returned 1 exit status
>
> so you have to find where your c++ library is located.
>
> i don't know much about macosx and it is doing
> a lot of things different from other operating systems.
> what you can try for example is to do the following:
>
> touch empty.cxx
> g++ -v empty.cxx
>
> that will stop with an error, but thanks to the '-v' it will
> print the full command line at each step. on my linux
> box this is:
>
> Using built-in specs.
> Target: x86_64-redhat-linux
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info
> --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
> --enable-shared --enable-threads=posix --enable-checking=release
> --with-system-zlib --enable-__cxa_atexit
> --disable-libunwind-exceptions --enable-gnu-unique-object
> --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
> --enable-java-awt=gtk --disable-dssi --enable-plugin
> --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
> --enable-libgcj-multifile --enable-java-maintainer-mode
> --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
> --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic
> --with-arch_32=i686 --build=x86_64-redhat-linux
> Thread model: posix
> gcc version 4.4.4 20100630 (Red Hat 4.4.4-10) (GCC)
> COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
> /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/cc1plus -quiet -v
> -D_GNU_SOURCE empty.cxx -quiet -dumpbase empty.cxx -mtune=generic
> -auxbase empty -version -o /tmp/cckHewnV.s
> ignoring nonexistent directory
> "/usr/lib/gcc/x86_64-redhat-linux/4.4.4/include-fixed"
> ignoring nonexistent directory
> "/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../x86_64-redhat-linux/include"
> #include "..." search starts here:
> #include <...> search starts here:
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/x86_64-redhat-linux
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/backward
> /usr/local/include
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/include
> /usr/include
> End of search list.
> GNU C++ (GCC) version 4.4.4 20100630 (Red Hat 4.4.4-10)
> (x86_64-redhat-linux)
> compiled by GNU C version 4.4.4 20100630 (Red Hat 4.4.4-10), GMP
> version 4.3.1, MPFR version 2.4.1.
> GGC heuristics: --param ggc-min-expand=100 --param
> ggc-min-heapsize=131072
> Compiler executable checksum: 921aa223d38d78a20e67c4037f50d7c9
> COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
> as -V -Qy -o /tmp/ccY7JKAw.o /tmp/cckHewnV.s
> GNU assembler version 2.19.51.0.14 (x86_64-redhat-linux) using BFD
> version version 2.19.51.0.14-37.fc12 20090722
> COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/4.4.4/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.4/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.4/:/usr/lib/gcc/x86_64-redhat-linux/:/usr/libexec/gcc/x86_64-redhat-linux/4.4.4/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/4.4.4/:/usr/lib/gcc/x86_64-redhat-linux/
> LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.4/:/usr/lib/gcc/x86_64-redhat-linux/4.4.4/:/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../:/lib/:/usr/lib/
> COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
> /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/collect2 --eh-frame-hdr
> --build-id -m elf_x86_64 --hash-style=gnu -dynamic-linker
> /lib64/ld-linux-x86-64.so.2
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crt1.o
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crti.o
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/crtbegin.o
> -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4
> -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4
> -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64
> -L/lib/../lib64 -L/usr/lib/../lib64
> -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../.. /tmp/ccY7JKAw.o
> -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/crtend.o
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crtn.o
> /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../lib64/crt1.o: In
> function `_start':
> (.text+0x20): undefined reference to `main'
> collect2: ld returned 1 exit status
>
> the last step is the linking and there you see all the -L flags that are
> added
> when linking a c++ code. now you can add the -v flag when linking with
> gfortran and you can compare.
>
> cheers,
> axel.
> > Thank you,
> >
> > Susana
> >
> >
> > On Mon, Mar 14, 2011 at 9:22 PM, John Stone <johns_at_ks.uiuc.edu> wrote:
> >>
> >> Susana,
> >> You need a space between "-ltcl8.5" and "-L/usr/lib/", they are
> >> separate command parameters. You may need to edit your makefile
> >> to add spaces where necessary.
> >>
> >> Cheers,
> >> John
> >>
> >> On Mon, Mar 14, 2011 at 09:04:51PM +0000, Susana Tomasio wrote:
> >> > Hi Axel,
> >> >
> >> > Thank you for your reply.
> >> > Your are right it doesn't complain about -lstdc++. But now it
> >> > complains
> >> > about -ltcl8.5:
> >> >
> >> > ld: library not found for -ltcl8.5-L/usr/lib/
> >> > collect2: ld returned 1 exit status
> >> > make: *** [tester] Error 1
> >> >
> >> > Is it also related with the space between the words?
> >> > (Sorry I don't have experience with this sort of thing).
> >> >
> >> > Thank you,
> >> >
> >> > Susana
> >> >
> >> > On Mon, Mar 14, 2011 at 6:43 PM, Axel Kohlmeyer
> <akohlmey_at_gmail.com>
> >> > wrote:
> >> >
> >> > On Mon, Mar 14, 2011 at 12:52 PM, Susana Tomasio
> >> > <susietomasio_at_gmail.com> wrote:
> >> > > Hi all,
> >> > >
> >> > > I'm compiling the fortran bindings for the VMD molfile
> plugins
> >> > from
> >> > Axel
> >> > > Kohlmeyer.
> >> > >
> >> > > I've compiled the molfile plugins but I am having a linkage
> >> > problem
> >> > when
> >> > > compliling the
> >> > > fortran bindings. I am using a MacOSX Snow Leopard.
> >> >
> >> > [...]
> >> > > ld: library not found for -ltcl8.5-L/usr/lib/-lstdc++
> >> >
> >> > have a look at this error message.
> >> > it doesn't look right as a library name, or does it?
> >> > > collect2: ld returned 1 exit status
> >> > > make: *** [tester] Error 1
> >> > >
> >> > > And this is the edit section of my Makefile:
> >> > >
> >> > > ARCH = MACOSX86-64
> >> > > ARCHDIR = /Users/tomasio/plugins/MACOSXX86/molfile
> >> > > FC = g77
> >> > > #FC = g77
> >> > > #-fno-second-underscore
> >> > > CC = gcc
> >> > > LD = $(FC)
> >> > > OPT = -O2 -Wall
> >> > > CPPFLAGS = -I/Users/tomasio/plugins/include/
> >> > > -I/Users/tomasio/plugins/MACOSXX86 #
> >> > > -D_F77_F2C_UNDERSCORE
> >> > > CFLAGS = -c $(CPPFLAGS) $(OPT)
> >> > > FFLAGS = -c $(OPT)
> >> > > NETCDFLIB =
> >> > >
> >> >
> >> >
> -L/opt/local/var/macports/software/netcdf/4.1.1_4+dap+netcdf4/opt/local/lib/
> >> > > #/usr/lib64/netcdf-3
> >> > > NETCDFLDFLAGS = -lnetcdf
> >> > > TCLLIB =
> >> > /opt/local/var/macports/software/tcl/8.5.9_0/opt/local/lib/
> >> > > TCLLDFLAGS = -ltcl8.5
> >> > > LDFLAGS = -L$(ARCHDIR) $(TCLLIB) $(NETCDFLIB)
> >> > > LDLIBS = -lmolfile_plugin $(NETCDFLDFLAGS)
> >> > > $(TCLLDFLAGS)-L/usr/lib/-lstdc++ -ldl
> >> >
> >> > here is the problem. there have to be blanks between the
> "words",
> >> > i.e.
> >> > try:
> >> > $(TCLLDFLAGS) -L/usr/lib/ -lstdc++ -ldl
> >> >
> >> > cheers,
> >> > axel.
> >> > >
> >> > > I tried with gfortran and got the same error.
> >> > > I would be grateful if anyone could help me with this.
> >> > >
> >> > > Thank you,
> >> > >
> >> > > Susana
> >> > >
> >> >
> >> > --
> >> > Dr. Axel Kohlmeyer
> >> > akohlmey_at_gmail.com http://goo.gl/1wk0
> >> >
> >> > Institute for Computational Molecular Science
> >> > Temple University, Philadelphia PA, USA.
> >>
> >> --
> >> NIH Resource for Macromolecular Modeling and Bioinformatics
> >> Beckman Institute for Advanced Science and Technology
> >> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> >> Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
> >> WWW: http://www.ks.uiuc.edu/~johns/ Fax: 217-244-6078
> >
> >
>
> --
> Dr. Axel Kohlmeyer
> akohlmey_at_gmail.com http://goo.gl/1wk0
>
> Institute for Computational Molecular Science
> Temple University, Philadelphia PA, USA.

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078