解决“CMake Error: CMake can not determine linker language for target”

问题描述 投票:0回答:0

这里是错误信息:

CMake Error: CMake can not determine linker language for target: substring_match

CMake Generate step failed. Build files cannot be regenerated correctly.

任何解决方案?

尝试在 src/file_name.h 周围引用——它失败了。

制作文件:

cmake_minimum_required(VERSION 3.24) project(substring_match)

set(CMAKE_CXX_STANDARD 14)

add_executable(substring_match src/cop3530_1_3.h)

新错误消息(在 src 文件夹中添加 main.cpp 并具有 add_executable(substring_match src/main.cpp src/cop3530_1_3.h):

FAILED: substring_match 
: && /Library/Developer/CommandLineTools/usr/bin/c++ -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/substring_match.dir/src/main.cpp.o -o substring_match   && :
Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
    ```

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
c++ cmake linker-errors clion
© www.soinside.com 2019 - 2024. All rights reserved.