gpt4 book ai didi

c++ - 无法理解 kern.osversion ‘14.5.0

转载 作者:可可西里 更新时间:2023-11-01 15:26:22 24 4
gpt4 key购买 nike

在尝试查看系统上的 gcc 版本时,我收到以下消息

gcc --version
gcc: warning: couldn’t understand kern.osversion ‘14.5.0
gcc (GCC) 4.9.0
Copyright (C) 2014 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

which -a gcc
/usr/local/bin/gcc
/usr/local/bin/gcc
/usr/bin/gcc

然后我用一些代码尝试了 Xcode 和 Sublime text,但在尝试构建时遇到了更多错误。

在 sublime text 上:

#include <stdio.h>

int main (void)

{

/*Define variables*/

float num1, num2, num3, media;

printf("Insert some number:");

scanf("%f",&num1);

}

error message: clang: error: no input files [Finished in 0.9s with exit code 1]

在 Xcode 上:

#include <stdio.h>

int main ()

{

int num;

printf("Write a number:");

scanf("%d",&num);

getchar();

}

error message: 2 duplicate symbols for architecture x86_64 Linker command failed with exit code 1

ld /Users/*****/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzzfdaav/Build/Products/Debug/C++\
Programming normal x86_64
cd "/Users/*****/Desktop/C++/C++ Programming"
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-L/Users/*******/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzzfdaa/Build/Products/Debug
-F/Users/******/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzzfda/Build/Products/Debug
-filelist /Users/****/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqr/Build/Intermediates/C++\
Programming.build/Debug/C++\
Programming.build/Objects-normal/x86_64/C++\ Programming.LinkFileList
-mmacosx-version-min=10.10 -stdlib=libc++ -Xlinker -dependency_info -Xlinker /Users/****/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzzf/Build/Intermediates/C++\
Programming.build/Debug/C++\
Programming.build/Objects-normal/x86_64/C++\
Programming_dependency_info.dat -o
/Users/***/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzzfdBuild/Products/Debug/C++\
Programming

duplicate symbol _main in: /Users/*******/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzz/Build/Intermediates/C++ Programming.build/Debug/C++ Programming.build/Objects-normal/x86_64/Add.o /Users/******/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpz/Build/Intermediates/C++ Programming.build/Debug/C++ Programming.build/Objects-normal/x86_64/main.o duplicate symbol _main in: /Users/*****/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqr/Build/Intermediates/C++ Programming.build/Debug/C++ Programming.build/Objects-normal/x86_64/Add.o /Users/******/Library/Developer/Xcode/DerivedData/C++_Programming-gsftvvhqrpzz/Build/Intermediates/C++ Programming.build/Debug/C++ Programming.build/Objects-normal/x86_64/C++.o ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

关于如何修复这个错误的任何建议

谢谢

最佳答案

您可能已经升级了您的系统。由于默认情况下未安装 gcc,操作系统升级可能不会删除或替换 gcc 和其他 XCode 命令行工具。

您显然可以重命名它们(或将它们移动到备份子目录中),以便它们不在您的 PATH 中。这样,自制软件就不会找到它们并使用更新的编译器(clang)。您的系统(XCode、brew)很可能会照常运行,因为它们会使用在您的系统上找到的 clang。

您看到的错误“无法理解 kern.osversion '14.5.0'”,可能是因为此 gcc 是针对较旧版本编译的OS X 内核版本,当前版本与该版本向后不兼容。

关于c++ - 无法理解 kern.osversion ‘14.5.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32373692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com