Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ compiler cannot create executables #738

Closed
thw1021 opened this issue Jul 22, 2019 · 17 comments
Closed

C++ compiler cannot create executables #738

thw1021 opened this issue Jul 22, 2019 · 17 comments

Comments

@thw1021
Copy link

thw1021 commented Jul 22, 2019

Dear developers,
I am trying to install SU2 in docker ubuntu 18.04 container so that I can easily share with partner. But I failed to compile the code with following errors:

(base) root@a5502ebdff64:/home/SU2# ./configure --prefix=/home/SU2/SU2_Install CXXFLAGS="-O3" --enable-mpi --with-cc=/usr/bin/mpicc --with-cxx=/usr/bin/mpicxx
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for style of include used by make... GNU
checking whether the C++ compiler works... no
configure: error: in `/home/SU2':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

I am sure that I have installed gcc/g++ successfully. You can see

(base) root@a5502ebdff64:/home# gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(base) root@a5502ebdff64:/home# g++ -o hello hello.cc
(base) root@a5502ebdff64:/home# ./hello 
Hello, World!

I have uploaded the config.log file. Could you give me some suggestions, please?
config.log

@davetaflin
Copy link
Contributor

davetaflin commented Jul 22, 2019 via email

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

Yes. I did have installed g++.

(base) root@a5502ebdff64:/home# g++ --version
g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
(base) root@a5502ebdff64:/home/SU2# apt-get install gcc g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version (4:7.4.0-1ubuntu2.3).
gcc is already the newest version (4:7.4.0-1ubuntu2.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

@vdweide
Copy link
Contributor

vdweide commented Jul 22, 2019

What about mpicc and mpicxx? You are trying to build a parallel executable, so is MPI installed?

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

I install OpenMPI following the instructions with commands:

root@d929b0ec33cb:/home# apt-get update
root@d929b0ec33cb:/home# apt-get install openmpi-bin

and I can see the version

root@d929b0ec33cb:/home# mpirun --version
mpirun (Open MPI) 2.1.1

Report bugs to http://www.open-mpi.org/community/help/

@vdweide
Copy link
Contributor

vdweide commented Jul 22, 2019

Are the compiler wrappers, mpicc and mpicxx, also installed? When I look in your log file it mentions
./configure: line 3362: /usr/bin/mpicxx: No such file or directory

@talbring
Copy link
Member

Below you can find the steps I used to build a singularity container using ubuntu 19.04. For pure docker and ubuntu 18.04 the steps should be the same I guess.

apt-get -y update
apt-get -y install python3 git build-essential autoconf python-dev libopenmpi3 openmpi-common
git clone --depth=1 https://github.com/su2code/SU2
cd SU2
autoreconf -i
export CXXFLAGS="-O3"
python3 preconfigure.py --enable-mpi --prefix=$PWD
make install -j20
make clean

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

Sorry. Do you mean that although I have installed OpenMPI, I still have to install mpicc and mpicxx ? I am not familiar with such problems.
When I run which mpicc and which mpicxx in the container, there is no outputs. But on the host machine, I can see /usr/bin/mpicc and /usr/bin/mpicxx. Maybe this the reason.

@davetaflin
Copy link
Contributor

davetaflin commented Jul 22, 2019 via email

@davetaflin
Copy link
Contributor

davetaflin commented Jul 22, 2019 via email

@talbring
Copy link
Member

And btw in case you want to really use MPI with containers, you should use singularity (https://sylabs.io/) as it is exactly designed for this.

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

Yes. Thank you all. I installed libopenmpi-dev and openmpi-common. I don't know which one is the key but I can see SU2_RUN and SU2_HOME environment variables displayed at the conclusion of configure.

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

Thank you. I will close this issue after I make sure that I have installed successfully.

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

@talbring
Could you give me more instructions about parallel computing in docker container, please ? I can commit the container to an image, so is there any difference ?

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

Thank you all.
When I run the tutorial case with mpirun, there are some warnings:

(base) root@a5502ebdff64:/home/SU2_RUN/QuickStart# mpirun -n 24 SU2_CFD inv_NACA0012.cfg 
--------------------------------------------------------------------------
mpirun has detected an attempt to run as root.
Running at root is *strongly* discouraged as any mistake (e.g., in
defining TMPDIR) or bug can result in catastrophic damage to the OS
file system, leaving your system in an unusable state.

You can override this protection by adding the --allow-run-as-root
option to your cmd line. However, we reiterate our strong advice
against doing so - please do so at your own risk.

Should I directly ignore such warnings ? Any suggestion would be grateful.

@talbring
Copy link
Member

OpenMPI is not officially supported when using a docker container. See my comment above and open-mpi/ompi#3625 (comment)

@talbring
Copy link
Member

Here is the full definition file for singularity:

 Bootstrap: docker
 From: ubuntu:19.04
   
 %post
     apt-get -y update
     apt-get -y install python3 git build-essential autoconf python-dev libopenmpi3 openmpi-common
     git clone --depth=1 https://github.com/su2code/SU2
     cd SU2
     autoreconf -i
     export CXXFLAGS="-O3"
     python3 preconfigure.py --enable-mpi --prefix=$PWD
     make install -j20
     make clean
  
 %runscript
      exec /SU2/bin/$1 $2                              

Store it in file called su2.defand run

sudo singularity build su2.sif su2.def

You can then run it like that:

mpirun -n 24 su2.sif SU2_CFD inv_NACA0012.cfg

The only thing to note is that the OpenMPI version you use inside the container and on the machine you want to run it should be similar. I tried it with OpenMPI v3 in the container and OpenMPI v4 outside and it worked.

@thw1021
Copy link
Author

thw1021 commented Jul 22, 2019

OK. I will try as you suggested. Thanks for your kind help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants