0

This problem is related to GCC and CMake.

My original CMakeLists.txt is

cmake_minimum_required (VERSION 3.22.1)
project (Transformation)

find_package(Eigen3 REQUIRED)
include_directories(EIGEN3_INCLUDE_DIR)

add_executable (Transformation main.cpp)

The error result is

[cmake] -- The C compiler identification is unknown
[cmake] -- The CXX compiler identification is AppleClang 13.0.0.13000029
[cmake] CMake Error at CMakeLists.txt:2 (project):
[cmake]   The CMAKE_C_COMPILER:
[cmake] 
[cmake]     /usr/local/bin/x86_64-apple-darwin20-gcc-11.1.0
[cmake] 
[cmake]   is not a full path to an existing compiler tool.
[cmake] 
[cmake]   Tell CMake where to find the compiler by setting either the environment
[cmake]   variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
[cmake]   the compiler, or to the compiler name if it is in the PATH.

I have to set the path by myself. Then It builds successfully.

set(CMAKE_C_COMPILER "/usr/local/bin/x86_64-apple-darwin21-gcc-11")

Why is the default compiler in original situation x86_64-apple-darwin20-gcc-11 .1.0? I don't have this file in /usr/local/bin. My gcc version is 11.2.0 and its name should be x86_64-apple-darwin21-gcc-11.

(I've checked the relevant problem on "The CMAKE_C_COMPILER is not a full path to an existing compiler tool" How to find compiler path automatically in cmake? but it seems not my situation)

This is my first time using CMake and gcc. I would be grateful if someone could help me(⑉꒦ິ^꒦ິ⑉). Many thanks!!!

VoldeNuit
  • 11
  • 4
  • Mac OS aliases are generally not recognised by command line tools. They are neither symbolic links, nor hard links. – n. m. could be an AI Dec 27 '21 at 18:34
  • Is it supposed to be `darwin21` instead of `darwin20`? – Ranoiaetep Dec 27 '21 at 20:47
  • @Ranoiaetep Oh my bad. I didn't notice this. I just copied the path from the error message and modified the suffix. Thank you!!! I've modified my problem. Could you have a look? (୨୧•͈ᴗ•͈)◞ᵗʱᵃᵑᵏઽ – VoldeNuit Dec 28 '21 at 00:45
  • @n. 1.8e9-where's-my-share m. Thank you a lot! I had a typo in the alias and just corrected it. It works now. Does this mean Mac OS aliases can be recognized by command line tools? And could you have a look at my modified problem? Thanks! – VoldeNuit Dec 28 '21 at 00:59
  • @VoideNuit It's hard to tell the exact reason without knowing more about your situation. Is it possible that you installed earlier versions of gcc before (maybe automatically installed as a dependency of another program), and the path wasn't set correctly when you installed the new version? Or maybe the gcc path was set somewhere in a submodule without you noticing it? – Ranoiaetep Dec 28 '21 at 03:32
  • @VoideNuit Also note that, currently you aren't building the project with the g++ you manually installed. Currently it says: `CXX compiler identification is AppleClang 13`, which means you are using the Apple Clang instead of g++. You would need to manually set it to the g++ location similar to the way you set your C compiler. – Ranoiaetep Dec 28 '21 at 03:35
  • @VoideNuit Also, it's often enough to use location like `/usr/local/bin/gcc-11` and `/usr/local/bin/g++-11`, or even `gcc-11` and `g++-11` as the path. – Ranoiaetep Dec 28 '21 at 03:37
  • @Ranoiaetep Thanks for your reminders. I knew nothing about makefile before and was just like a headless chicken. Thankfully, I've solved the problem by changing the kit. This is my first question posted on the Internet. I am grateful to have your patient answers. Many thanks!!! – VoldeNuit Dec 28 '21 at 07:07

0 Answers0