본문 바로가기

OpenFOAM

GCC Version

GCC (GNU Compiler Collection)은 여러 컴파일러의 집합체이다. 지속적으로 업데이트가 되는데, 이 글을 쓰는 시점 (23.8)에서의 최신버전은

gcc --version
gcc (Ubuntu 12.2.0-3ubuntu1) 12.2.0
Copyright (C) 2022 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.

CFD-DEM에 사용하려고 하는 OpenFOAM 5.x는 gcc5 시대에 개발된 코드로 당시의 gcc에 맞추어 컴파일을 해야 한다.

뜬금없이 reddit.com에 solution이 나와 있는데, gcc7이 되는 모양이다.

 

https://www.reddit.com/r/OpenFOAM/comments/111wg70/failed_to_compile_openfoam_5_on_ubuntu_22_is/?rdt=40990 

 

From the OpenFOAM community on Reddit

Explore this post and more from the OpenFOAM community

www.reddit.com

 

그럼 gcc를 일단 다운그레이드 해야되는데, 여러 사이트에서 repository를 등록하고 apt 또는 apt-get으로 설치하라고 하는데, package를 잘 못찾는다. 그래서 노가다로 아래의 사이트에서 일일이 dependency를 체크하며, 할려고 했더니 이게 보통일이 아니다.

dpkg -i <---.deb>

https://packages.ubuntu.com/focal/gcc-7

 

Ubuntu – Details of package gcc-7 in focal

[  focal  ] Package: gcc-7 (7.5.0-6ubuntu2) [universe] Other Packages Related to gcc-7 dep: binutils (>= 2.34) GNU assembler, linker and binary utilities dep: cpp-7 (= 7.5.0-6ubuntu2) GNU C preprocessor dep: gcc-7-base (= 7.5.0-6ubuntu2) GCC, the GNU Com

packages.ubuntu.com

 

그래서, 좀 더 알아보니 우분투에서는 패키지 관리를 sources.list와 sources.list.d에서 하며, gcc-7은 내가 현재 사용하는 Ubuntu22와는 호환성 문제가 있어서 기본 repository에 올라가있지 않다. 그러면 추가해야 하는데, 추가해야할 사이트는 위에 있는 링크이다.

 

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu focal main universe"
sudo apt update
sudo apt install gcc-7

이렇게 하니 의존성 문제가 해결되긴 했다. (최신 버전을 날리고...)

 

dpkg -l | grep gcc
ii  gcc                                        4:12.2.0-1ubuntu1                        amd64        GNU C compiler
ii  gcc-11-base:amd64                          11.3.0-6ubuntu1                          amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-12                                     12.2.0-3ubuntu1                          amd64        GNU C compiler
ii  gcc-12-base:amd64                          12.2.0-3ubuntu1                          amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-12-base:i386                           12.2.0-3ubuntu1                          i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-7                                      7.5.0-6ubuntu2                           amd64        GNU C compiler
ii  gcc-7-base:amd64                           7.5.0-6ubuntu2                           amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-8-base:amd64                           8.4.0-3ubuntu2                           amd64        GCC, the GNU Compiler Collection (base package)
ii  libgcc-12-dev:amd64                        12.2.0-3ubuntu1                          amd64        GCC support library (development files)
ii  libgcc-7-dev:amd64                         7.5.0-6ubuntu2                           amd64        GCC support library (development files)
ii  libgcc-s1:amd64                            12.2.0-3ubuntu1                          amd64        GCC support library
ii  libgcc-s1:i386                             12.2.0-3ubuntu1                          i386         GCC support library

현재는 gcc 7, 11, 12버전이 깔려 있다. 이제 gcc 7을 선택해서 OpenFOAM을 컴파일 해보자. (힘들다)

'OpenFOAM' 카테고리의 다른 글