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

Problem to compile #38

Open
mateuslattari opened this issue Dec 15, 2022 · 11 comments
Open

Problem to compile #38

mateuslattari opened this issue Dec 15, 2022 · 11 comments

Comments

@mateuslattari
Copy link

mateuslattari commented Dec 15, 2022

Hi, I am trying to use AmgXwrapper for the first time, but I am not being able to compile it:

/usr/bin/ld: CMakeFiles/amgxwrapper.dir/src/setA.cpp.o: in function AmgXSolver::setA(int, int, int, int const*, int const*, double const*, int const*)': setA.cpp:(.text+0x1c38): undefined reference to AMGX_matrix_upload_all_global_32'
/usr/bin/ld: setA.cpp:(.text+0x1d5a): undefined reference to `AMGX_matrix_upload_all_global_32'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/amgxwrapper.dir/build.make:182: libamgxwrapper.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: CMakeFiles/amgxwrapper.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Did anyone have a similar issue?

I appreciate a lot any response!

@piyueh
Copy link
Member

piyueh commented Dec 15, 2022

Seems the linker did not include the AmgX library. Some questions:

  • Is your AmgX library a static or shared library?
  • Could you provide the steps of how you build AmgXWrapper?
  • If you can save the full logs (from both CMake and Make) to a text file and upload them here (GitHub supports uploading files to an issue/comment), it may be clearer what happened.
  • If possible, please also upload the resulting CMakeCache.txt.

Thank you!

@mateuslattari
Copy link
Author

Hey pihueh, thanks a lot for your fast reply. I followed straightly the documentation. I am using as a static library, but my plain is to used the wrapper for OpenFOAM with petsc4foam. I use this command:

cmake -D CMAKE_INSTALL_PREFIX="/home/mateus/AmgXWrapper" -D PETSC_DIR=${PETSC_DIR} -D PETSC_ARCH=${PETSC_ARCH} -D CUDA_DIR="opt/cuda" -D AMGX_DIR="/home/mateus/AMGX-2.3.0/core" ../
(I created all the locations with enviroment variables in bash).
Then I executed:

$make -j 12

CMakeCache.txt

@piyueh
Copy link
Member

piyueh commented Dec 16, 2022

Seems CMake had no problems finding AmgX (stored as AMGX_INCLUDE_DIRS and AMGX_LIBRARIES in CMakeCache.txt), though it used the shared library (libamgxsh.so) rather than the static one (which is fine and should not cause any problem).

Do you have log files from the stdout of CMake and Make? (If possible, replace $ make -j 12 with $ make VERBOSE=1 so the message will be clearer.) Let me know if you need commands that record stdout into files.

Other files that may be helpful for debugging is CMakeError.log and CMakeOutput.log under the folder build/CMakeFiles.

@mateuslattari
Copy link
Author

For some reason , cmake is not creating the error file, only CMakeOutput.log. That I am sending, also I am including a bash script, containing the exact command I typed for building:

export HOME=$(pwd)
rm --rf build
mkdir ${HOME}/build
cd ${HOME}/build

export PATH_TO_WHERE_YOU_WANT_TO_INSTALL_AmgXWrapper="/home/mateus/AmgXWrapper"
export PATH_TO_PETSC="/home/mateus/petsc-3.16.2"
export THE_BUILD_OF_PETSC_YOU_WANT_TO_USE="arch-linux-c-debug"
export PATH_TO_CUDA="opt/cuda"
export PATH_TO_AMGX="/home/mateus/AMGX-2.3.0/base"
export PATH_TO_AmgXWrapper_SOURCE="/home/mateus/AmgXWrapper"

cmake -D CMAKE_INSTALL_PREFIX=${PATH_TO_WHERE_YOU_WANT_TO_INSTALL_AmgXWrapper} -D PETSC_DIR=${PATH_TO_PETSC} -D PETSC_ARCH=${THE_BUILD_OF_PETSC_YOU_WANT_TO_USE} -D CUDA_DIR=${PATH_TO_CUDA} -D AMGX_DIR=${PATH_TO_AMGX} ${PATH_TO_AmgXWrapper_SOURCE}

make VERBSOE=1

CMakeOutput.log

@piyueh
Copy link
Member

piyueh commented Dec 16, 2022

I still need the stdout logs from CMake and Make. If you are not sure how to obtain them, put the following content into a file at /home/mateus/run.sh:

#! /bin/sh

rm -rf /home/mateus/AmgXWrapper/build
mkdir /home/mateus/AmgXWrapper/build
cd /home/mateus/AmgXWrapper/build

export PATH_TO_WHERE_YOU_WANT_TO_INSTALL_AmgXWrapper="/home/mateus/AmgXWrapper"
export PATH_TO_PETSC="/home/mateus/petsc-3.16.2"
export THE_BUILD_OF_PETSC_YOU_WANT_TO_USE="arch-linux-c-debug"
export PATH_TO_CUDA="/opt/cuda"
export PATH_TO_AMGX="/home/mateus/AMGX-2.3.0/base"
export PATH_TO_AmgXWrapper_SOURCE="/home/mateus/AmgXWrapper"

cmake \
        -D CMAKE_INSTALL_PREFIX=${PATH_TO_WHERE_YOU_WANT_TO_INSTALL_AmgXWrapper} \
        -D PETSC_DIR=${PATH_TO_PETSC} \
        -D PETSC_ARCH=${THE_BUILD_OF_PETSC_YOU_WANT_TO_USE} \
        -D CUDA_DIR=${PATH_TO_CUDA} \
        -D AMGX_DIR=${PATH_TO_AMGX} \
        ${PATH_TO_AmgXWrapper_SOURCE} \
        2>&1 | tee cmake.log

make VERBOSE=1 2>&1 | tee make.log

Then cd /home/mateus, and then sh run.sh.

I changed your CUDA path to /opt/cuda because opt/cuda seems to be a typo. Also, VERBSOE=1 has a typo, and I changed it to VERBOSE=1. --rf also seems to be a typo, which has an extra dash. Furthermore, when you used export HOME=$(pwd), you were messing up the HOME environment variable, which is not recommended. So I just use the absolute path.

Once the execution of run.sh is done, there should be two files: cmake.log and make.log under /home/mateus/AmgXWrapper/build. Upload them here. They are the stdout from CMake and Make.

@mateuslattari
Copy link
Author

Ohh sorry about the typos, hahha
I am sending the files now:
[make.log](https://github.com/barbagroup/Amg
cmake.log
XWrapper/files/10250268/make.log)

Thanks a lot for the help!

@mateuslattari
Copy link
Author

cmake.log
make.log

@piyueh
Copy link
Member

piyueh commented Dec 19, 2022

Your CMake system behaved differently. There are two things unusual in make.log:

  1. The source files in the example folders are not separated from the source files of libamgxwrapper.so. That's why there are error messages like multiple definition of xxxxx in make.log. The examples and libamgxwrapper.so are supposed to be built independently and separately. Not sure why. I've never seen something like this.
  2. The undefined reference error. This may related to the first error. So we may need to fix the first error.

Do you have the tree command on your system? If so, can you run tree /home/mateus/AmgXWrapper 2>&1 | tee tree_result.log and upload the tree_result.log here? If you do not have tree, then simply do ls /home/mateus/AmgXWrapper/src/ 2>&1 | tee ls_result.log and upload ls_result.log.

@piyueh
Copy link
Member

piyueh commented Dec 19, 2022

Also, if you can find it, upload /home/mateus/AmgXWrapper/build/CMakeFiles/VerifyGlobs.cmake. Thank you

@mateuslattari
Copy link
Author

VerifyGlobs.cmake.log

Thanks a lot for all the points. I have a lot of experience on docker. So, I can try out inside a container. Would you mind sending to me all the version of your CMAKE and dependencies?

@piyueh
Copy link
Member

piyueh commented Dec 20, 2022

Can you check the files under the folder /home/mateus/AmgXWrapper/src? There are extra files in that folder, and that's why we saw the error of multiple definition of xxxxx.

Based on the log, I saw you have these files under /home/mateus/AmgXWrapper/src:

"/home/mateus/AmgXWrapper/src/AmgXSolver.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/StructArgs.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/createKSP.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/factories.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/fixSingularMat.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/io.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/main.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/petscToCSR.cpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/solve.cpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/StructArgs.cpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/createKSP.cpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/io.cpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/main.cpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/solve.cpp"
"/home/mateus/AmgXWrapper/src/init.cpp"
"/home/mateus/AmgXWrapper/src/misc.cpp"
"/home/mateus/AmgXWrapper/src/setA.cpp"
"/home/mateus/AmgXWrapper/src/solve.cpp"
"/home/mateus/AmgXWrapper/src/AmgXSolver.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/StructArgs.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/createKSP.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/factories.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/fixSingularMat.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/io.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/petscToCSR.hpp"
"/home/mateus/AmgXWrapper/src/example/poisson/src/solve.hpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/StructArgs.hpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/createKSP.hpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/headers.hpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/io.hpp"
"/home/mateus/AmgXWrapper/src/example/solveFromFiles/src/solve.hpp"

These are wrong. There should be no example folder under src. As you can see from here, there should be only 7 files under src. Probably at some point, you copied extra files and folders to src by mistake. It's possible that other files are also corrupt. To make things easier, you can try to remove /home/mateus/AmgXWrapper, re-download AmgXWrapper, and then compile/build AmgXWrapper again. If you're using the git version, make sure the current status is clean.

If you want to use Docker, for your reference, here are the Docker files we used: https://github.com/barbagroup/petibm-recipes/tree/master/docker. The README file describes the versions of the dependencies. (You can ignore PetIBM, which is our another software.) The CMake version in the latest Docker files is v3.23.1

And here are Docker images that were created using those files: https://hub.docker.com/repository/docker/barbagroup/petibm/tags?page=1&ordering=last_updated.

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

2 participants