New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #27223 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

PETSc doesn't compile

Reported by: mkr@… Owned by: mmoll@…
Priority: Normal Milestone:
Component: ports Version: 1.9.2
Keywords: Cc:
Port: petsc

Description

PETSc doesn't compile on MacOSX 10.6 due to some linking problem with mixed C++ and Fortran objects (full logs are attached):

...
          Pushing language FC
sh: gfortran -c -o conftest.o  -PIC -Wall -Wno-unused-variable -g   conftest.F 
Executing: gfortran -c -o conftest.o  -PIC -Wall -Wno-unused-variable -g   conftest.F 
sh: 
                  Pushing language FC
                  Popping language FC
sh: gfortran  -o conftest  -Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress -Wl,-commons,use_dylibs -Wl,-search_paths_first  -PIC -Wall -Wno-unused-variable -g   conftest.o cxxobj.o  confc.o    -ldl -lsz
Executing: gfortran  -o conftest  -Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress -Wl,-commons,use_dylibs -Wl,-search_paths_first  -PIC -Wall -Wno-unused-variable -g   conftest.o cxxobj.o  confc.o    -ldl -lsz
sh: 
Possible ERROR while running linker: Undefined symbols:
  "___gxx_personality_v0", referenced from:
      foo()    in cxxobj.o
      CIE in cxxobj.o
      _d1chk_ in confc.o
      CIE in confc.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
 output: ret = 256
error message = {Undefined symbols:
  "___gxx_personality_v0", referenced from:
      foo()    in cxxobj.o
      CIE in cxxobj.o
      _d1chk_ in confc.o
      CIE in confc.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
}
                      Pushing language FC
                      Popping language FC
 in gfortran  -o conftest  -Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress -Wl,-commons,use_dylibs -Wl,-search_paths_first  -PIC -Wall -Wno-unused-variable -g   conftest.o cxxobj.o  confc.o    -ldl -lsz
Source:
      program main
       call d1chk()

      end
          Popping language FC
*******************************************************************************
         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):
-------------------------------------------------------------------------------
Fortran could not successfully link C++ objects
*******************************************************************************

I tried to install via

sudo port install petsc +hdf5 +triangle +debug

Attachments

configure.log (223.7 KB) - added by mkr@… 3 years ago.
main.log (61.6 KB) - added by mkr@… 3 years ago.

Change History

Changed 3 years ago by mkr@…

Changed 3 years ago by mkr@…

comment:1 Changed 3 years ago by ryandesign@…

  • Keywords petsc removed
  • Cc mkr@… removed
  • Owner changed from macports-tickets@… to mmoll@…

comment:2 Changed 3 years ago by mmoll@…

It seems like the triangle variant is broken; without the triangle variant the port builds just fine. I am not sure, but perhaps the triangle port itself is broken. The triangle port doesn't actually contain any libraries:

> port contents triangle
Port triangle contains:
  /opt/local/bin/showme
  /opt/local/bin/triangle
  /opt/local/share/doc/triangle/A.poly
  /opt/local/share/doc/triangle/README

comment:3 follow-up: ↓ 4 Changed 3 years ago by mkr@…

For me it also doesn't build without triangle. I get the very same error...

comment:4 in reply to: ↑ 3 Changed 3 years ago by hugo.strand@…

Replying to mkr@…:

For me it also doesn't build without triangle. I get the very same error...

I have the same problem with Fortran C++ linking. adding

--LDFLAGS=-lstdc++

to configure.args in the Portfile makes the error go away.. but I've still got problems linking and running the PETSc examples on their homepage.

comment:5 Changed 3 years ago by mmoll@…

Can you try again with the latest version of the port? I disabled the shared libraries, because this was causing link problems.

hugo.strand@…: why is there any Fortran C++ linking going on? I don't think Fortran is enabled by default. What problems do you have with linking and running the PETSc examples?

comment:6 Changed 3 years ago by arne.schmitz@…

Just tried updating my outdated ports, and ran into the same problem. Adding the ldflags seems to help. At least petsc builds now.

comment:7 follow-up: ↓ 8 Changed 3 years ago by mkr@…

I'm sorry for losing track of this issue. Fortunately, Arne's comment brought my attention back to it...

I tried the latest version of the port with the usual result. It doesn't work and gives me the same old error.

Also adding '--LDFLAGS=-lstdc++' to configure.args in the Portfile didn't help. If I look at the log file, I see that configure gets called with the additional argument, but strangely it doesn't have any effect.

If we get this issue solved somehow, it would also be nice to have options to activate Fortran and NetCDF support. This should be easy, but one thing at a time...

comment:8 in reply to: ↑ 7 Changed 3 years ago by jonimpel@…

I have the same problem. Is there any workaround yet?

comment:9 follow-up: ↓ 10 Changed 3 years ago by jonimpel@…

I don't know the first thing about port files, but while playing around i found the working directory and the port status file. When I run "port install petsc" it always stops in the configure phase. So I tried to do the configuring manually within the working directory. To do so, I just had to add the correct PETSC_DIR (the working directory) to the environment variables and add the "--with-fc=/opt/local/bin/openmpif90" option to the configure command. Then, I used the same command as in the configuring procedure of the port file (shown when starting port -v install petsc). And it works without errors. In just adding in the state variable the configure state to be completed and running "port install petsc" again it runs perfectly through till the end. All test of petsc run also without problems. So there shouldn't be any error, it works theoretically. But when I add "--with-fc=${prefix}/bin/openmpif90" to the configure.args in the port file, the error in the configuring phase remains. Strange, but as I said, I'm a totally noob about writing a Portfile. However, perhaps my experiences with that could help a little bit.

The configure command that worked perfectly was: ./configure --prefix=/opt/local --with-python --with-debugging=0 --with-c-support=1 --with-c+-support=1 --with-pic=fPIC --with-shared=0 --PETSC_ARCH=darwin --prefix=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_petsc/work/destroot/opt/local/lib/petsc --with-cc=/opt/local/bin/openmpicc --with-cxx=/opt/local/bin/openmpicxx --with-fc=/opt/local/bin/openmpif90 --with-mpiexec=/opt/local/bin/openmpiexec

comment:10 in reply to: ↑ 9 Changed 3 years ago by abenpst@…

I want to confirm that what jonimpel suggested worked for me.

I tried to install PETSc using "port install petsc" without changing the Portfile. It stopped at the configure stage with the "Fortran could not successfully link C++" error

I included --with-fc=/opt/local/bin.openmpif90 in the Portfile and then using "port install petsc." Same error.

I included --LDFLAGS=-lstdc++ to the Portfile and then using "port install petsc". Same error.

Finally, I did:

cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_petsc/petsc/work/petsc-3.1-p7
export PETSC_DIR=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_petsc/petsc/work/petsc-3.1-p7
sudo ./configure --prefix=/opt/local --with-python --with-debugging=0 --with-c-support=1 --with-c++-support=1 --with-pic=fPIC --with-shared=0 --PETSC_ARCH=darwin --prefix=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_petsc/petsc/work/destroot/opt/local/lib/petsc --with-cc=/opt/local/bin/openmpicc --with-cxx=/opt/local/bin/openmpicxx --with-mpiexec=/opt/local/bin/openmpiexec --with-fc=/opt/local/bin/openmpif90 

Everything worked this time. I then had to do some "make" commands, just following what it told me to do.

PETSc seems to be up and running.

comment:12 Changed 3 years ago by mmoll@…

I have committed a possible fix in r83091. Please confirm whether this fixes the problem.

comment:13 Changed 3 years ago by mkr@…

For me it indeed does configure and compile now (+debug +hdf5; Lion, Xcode 4.1), only the +triangle variant doesn't work.

main.log says:

  UNABLE to CONFIGURE with GIVEN OPTIONS
  --with-triangle-dir=/opt/local did not work

configure.log says:

  Possible ERROR while running linker: ld: library not found for -ltriangle
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
   output: ret = 256
  error message = {ld: library not found for -ltriangle
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Which indeed is not there. There's just a triangle in /opt/local/bin. So I guess that's not a problem of petsc...

comment:14 Changed 3 years ago by mmoll@…

But does the regular version (without triangle variant) compile?

comment:15 Changed 3 years ago by mkr@…

Yes, on Lion with Xcode 4.1, petsc +debug +hdf5 configures without problems and also does compile (actually versions 3.1-p7_1 as well as 3.1-p8_0, hadn't tried it lately).

I overlooked that the problem with triangle was recognised already. But either should this variant be removed or the triangle port should be repaired to also build a library.

comment:16 follow-up: ↓ 17 Changed 3 years ago by mmoll@…

  • Status changed from new to closed
  • Resolution set to fixed

Thanks. I removed the broken triangle variant in r83152.

comment:17 in reply to: ↑ 16 Changed 3 years ago by abenpst@…

Replying to mmoll@…:

I can confirm that petsc 3.1-p8 installed perfectly using "port install petsc" using Xcode 4.1 on OSX 10.7.1

comment:18 Changed 3 years ago by longfei.li86@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

Portfile 83152 petsc version 3.1-p8 is still not working

using "port install petsc" with Xcode Version 3.2.6 on OSX 10.6.8

Same errors Fortran could not successfully link C++ objects occurs

comment:19 follow-up: ↓ 20 Changed 3 years ago by mmoll@…

I bumped the version in r84869. The build system seems to have changed slightly. Can someone check if this fixes things for people with Xcode 3.2.6 on 10.6.8? It installs without any problems for me on 10.7 with Xcode 4.

comment:20 in reply to: ↑ 19 Changed 3 years ago by longfei.li86@…

Replying to mmoll@…:

I bumped the version in r84869. The build system seems to have changed slightly. Can someone check if this fixes things for people with Xcode 3.2.6 on 10.6.8? It installs without any problems for me on 10.7 with Xcode 4.

Hi, I have tried again, still not working for Xcode 3.2.6 on 10.6.8.

Thanks.

comment:21 Changed 3 years ago by jmr@…

Xcode 3.2.x doesn't appear to install /usr/lib/libstdc++.dylib, it only has /usr/lib/libstdc++.6.dylib and /usr/lib/libstdc++.6.0.9.dylib. This is also the case with Xcode 3.1.4 on Leopard (though it's 6.0.4 there). There is only a libstdc++.dylib in a gcc version- and arch-dependent location, for example /usr/lib/gcc/i686-apple-darwin10/4.2.1.

comment:22 follow-ups: ↓ 23 ↓ 24 Changed 3 years ago by mmoll@…

So what's the fix for Xcode 3.x? Remove "-lstdc++" from the Portfile or replace it with "-lstdc++.6"? Can someone with Xcode 3.x try this?

comment:23 in reply to: ↑ 22 Changed 2 years ago by ryandesign@…

Replying to mmoll@…:

So what's the fix for Xcode 3.x? Remove "-lstdc++" from the Portfile or replace it with "-lstdc++.6"? Can someone with Xcode 3.x try this?

You could commit whatever fix you think is most likely, then see if the buildbot succeeds in building it; the buildbot runs 10.6, AFAIK with Xcode 3, and so far, it seems to be experiencing the failure reported in this ticket.

comment:24 in reply to: ↑ 22 Changed 2 years ago by dangerski@…

Replying to mmoll@…:

So what's the fix for Xcode 3.x? Remove "-lstdc++" from the Portfile or replace it with "-lstdc++.6"? Can someone with Xcode 3.x try this?

I created a local Portfile for this and tested it with "-lstdc++.6" and "-lstdc++.6.0.9" and it didn't fix the problem with Xcode Version 3.2.6 on OSX 10.6.8. If I run the configure command from the command line like abenpst and jonimpel did above (with out the -lstdc++ and had to change --with-shared=0 to --with-shared-libraries=0), then it works. It still doesn't work from the port command. When I try to install slepc it tries to install petsc and doesn't find the version I made from the command line so I can't install slepc. Any ideas why it works from the command line and not from the port command? The command line does export PETSC_DIR=... is that the only difference?

comment:25 Changed 2 years ago by dangerski@…

Found the fix for this bug. Using Xcode Version 3.2.6 on OSX 10.6.8. You need to change --LDFLAGS=-lstdc++ to --LIBS=-lstdc++ in the Portfile. Done. (Have not tested on 10.7 with Xcode 4)

comment:26 Changed 2 years ago by mmoll@…

Changing --LDFLAGS=-lstdc++ to --LIBS=-lstdc++ doesn't seem to break anything on 10.7 with Xcode 4. Can someone else verify independently? I used to get emails from the buildbot after every commit, but I am no longer getting those... Commit in r87338.

comment:27 Changed 2 years ago by mmoll@…

  • Status changed from reopened to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.