From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Mon Mar 14 2011 - 18:08:53 CDT

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.