0

I trying to compile CMake from sources on Solaris 11 machine:

# uname -a
SunOS 5.11 11.3 sun4v sparc sun4v

Steps:

After few time next error occurs:

CMake 3.14.3, Copyright 2000-2019 Kitware, Inc. and Contributors
C compiler on this system is: gcc  -std=gnu11     
C++ compiler on this system is: g++          
Makefile processor on this system is: gmake
g++ has setenv
g++ has unsetenv
g++ does not have environ in stdlib.h
g++ has stl wstring
g++ has <ext/stdio_filebuf.h>
---------------------------------------------
g++               -I/opt/CMake/Bootstrap.cmk   -I/opt/CMake/Source   -I/opt/CMake/Source/LexerParser   -I/opt/CMake/Utilities  cmAddCustomCommandCommand.o cmAddCustomTargetCommand.o cmAddDefinitionsCommand.o cmAddDependenciesCommand.o cmAddExecutableCommand.o cmAddLibraryCommand.o cmAddSubDirectoryCommand.o cmAddTestCommand.o cmBreakCommand.o cmBuildCommand.o cmCMakeMinimumRequired.o cmCMakePolicyCommand.o cmCPackPropertiesGenerator.o cmCacheManager.o cmCommand.o cmCommandArgumentParserHelper.o cmCommandArgumentsHelper.o cmCommands.o cmCommonTargetGenerator.o cmComputeComponentGraph.o cmComputeLinkDepends.o cmComputeLinkInformation.o cmComputeTargetDepends.o cmConditionEvaluator.o cmConfigureFileCommand.o cmContinueCommand.o cmCoreTryCompile.o cmCreateTestSourceList.o cmCustomCommand.o cmCustomCommandGenerator.o cmDefinePropertyCommand.o cmDefinitions.o cmDepends.o cmDependsC.o cmDisallowedCommand.o cmDocumentationFormatter.o cmEnableLanguageCommand.o cmEnableTestingCommand.o cmExecProgramCommand.o cmExecuteProcessCommand.o cmExpandedCommandArgument.o cmExportBuildFileGenerator.o cmExportFileGenerator.o cmExportInstallFileGenerator.o cmExportSet.o cmExportSetMap.o cmExportTryCompileFileGenerator.o cmExprParserHelper.o cmExternalMakefileProjectGenerator.o cmFileCommand.o cmFileTimeComparison.o cmFindBase.o cmFindCommon.o cmFindFileCommand.o cmFindLibraryCommand.o cmFindPackageCommand.o cmFindPathCommand.o cmFindProgramCommand.o cmForEachCommand.o cmFunctionCommand.o cmFSPermissions.o cmGeneratedFileStream.o cmGeneratorExpression.o cmGeneratorExpressionContext.o cmGeneratorExpressionDAGChecker.o cmGeneratorExpressionEvaluationFile.o cmGeneratorExpressionEvaluator.o cmGeneratorExpressionLexer.o cmGeneratorExpressionNode.o cmGeneratorExpressionParser.o cmGeneratorTarget.o cmGetCMakePropertyCommand.o cmGetDirectoryPropertyCommand.o cmGetFilenameComponentCommand.o cmGetPropertyCommand.o cmGetSourceFilePropertyCommand.o cmGetTargetPropertyCommand.o cmGetTestPropertyCommand.o cmGlobalCommonGenerator.o cmGlobalGenerator.o cmGlobalUnixMakefileGenerator3.o cmGlobVerificationManager.o cmHexFileConverter.o cmIfCommand.o cmIncludeCommand.o cmIncludeGuardCommand.o cmIncludeDirectoryCommand.o cmIncludeRegularExpressionCommand.o cmInstallCommand.o cmInstallCommandArguments.o cmInstallDirectoryGenerator.o cmInstallExportGenerator.o cmInstallFilesCommand.o cmInstallFilesGenerator.o cmInstallGenerator.o cmInstallScriptGenerator.o cmInstallSubdirectoryGenerator.o cmInstallTargetGenerator.o cmInstallTargetsCommand.o cmInstalledFile.o cmLinkDirectoriesCommand.o cmLinkItem.o cmLinkLineComputer.o cmListCommand.o cmListFileCache.o cmLocalCommonGenerator.o cmLocalGenerator.o cmLocalUnixMakefileGenerator3.o cmMSVC60LinkLineComputer.o cmMacroCommand.o cmMakeDirectoryCommand.o cmMakefile.o cmMakefileExecutableTargetGenerator.o cmMakefileLibraryTargetGenerator.o cmMakefileTargetGenerator.o cmMakefileUtilityTargetGenerator.o cmMarkAsAdvancedCommand.o cmMathCommand.o cmMessageCommand.o cmMessenger.o cmNewLineStyle.o cmOSXBundleGenerator.o cmOptionCommand.o cmOrderDirectories.o cmOutputConverter.o cmParseArgumentsCommand.o cmPathLabel.o cmPolicies.o cmProcessOutput.o cmProjectCommand.o cmProperty.o cmPropertyDefinition.o cmPropertyDefinitionMap.o cmPropertyMap.o cmReturnCommand.o cmRulePlaceholderExpander.o cmScriptGenerator.o cmSearchPath.o cmSeparateArgumentsCommand.o cmSetCommand.o cmSetDirectoryPropertiesCommand.o cmSetPropertyCommand.o cmSetSourceFilesPropertiesCommand.o cmSetTargetPropertiesCommand.o cmSetTestsPropertiesCommand.o cmSiteNameCommand.o cmSourceFile.o cmSourceFileLocation.o cmState.o cmStateDirectory.o cmStateSnapshot.o cmStringReplaceHelper.o cmStringCommand.o cmSubdirCommand.o cmSystemTools.o cmTarget.o cmTargetCompileDefinitionsCommand.o cmTargetCompileFeaturesCommand.o cmTargetCompileOptionsCommand.o cmTargetIncludeDirectoriesCommand.o cmTargetLinkLibrariesCommand.o cmTargetPropCommandBase.o cmTargetPropertyComputer.o cmTargetSourcesCommand.o cmTest.o cmTestGenerator.o cmTimestamp.o cmTryCompileCommand.o cmTryRunCommand.o cmUnexpectedCommand.o cmUnsetCommand.o cmUVHandlePtr.o cmVersion.o cmWhileCommand.o cmWorkingDirectory.o cmake.o cmakemain.o cmcmd.o cm_string_view.o cmCommandArgumentLexer.o cmCommandArgumentParser.o cmExprLexer.o cmExprParser.o cmListFileLexer.o Directory.o EncodingCXX.o FStream.o Glob.o RegularExpression.o SystemTools.o EncodingC.o ProcessUNIX.o String.o System.o Terminal.o uv-src-strscpy.c.o uv-src-timer.c.o uv-src-uv-common.c.o uv-src-unix-cmake-bootstrap.c.o uv-src-unix-core.c.o uv-src-unix-fs.c.o uv-src-unix-loop.c.o uv-src-unix-loop-watcher.c.o uv-src-unix-no-fsevents.c.o uv-src-unix-pipe.c.o uv-src-unix-poll.c.o uv-src-unix-posix-hrtime.c.o uv-src-unix-posix-poll.c.o uv-src-unix-process.c.o uv-src-unix-signal.c.o uv-src-unix-stream.c.o  -lkstat -lnsl -lsendfile -lsocket -lrt -o cmake
ld: fatal: file cmListFileLexer.o: wrong ELF class: ELFCLASS32
ld: fatal: file EncodingC.o: wrong ELF class: ELFCLASS32
ld: fatal: file ProcessUNIX.o: wrong ELF class: ELFCLASS32
ld: fatal: file String.o: wrong ELF class: ELFCLASS32
ld: fatal: file System.o: wrong ELF class: ELFCLASS32
ld: fatal: file Terminal.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-strscpy.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-timer.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-uv-common.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-cmake-bootstrap.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-core.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-fs.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-loop.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-loop-watcher.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-no-fsevents.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-pipe.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-poll.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-posix-hrtime.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-posix-poll.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-process.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-signal.c.o: wrong ELF class: ELFCLASS32
ld: fatal: file uv-src-unix-stream.c.o: wrong ELF class: ELFCLASS32
collect2: error: ld returned 1 exit status
gmake: *** [cmake] Error 1
---------------------------------------------
Error when bootstrapping CMake:
Problem while running gmake
---------------------------------------------
Log of errors: /opt/CMake/Bootstrap.cmk/cmake_bootstrap.log

How to compile properly?

chs_voks
  • 35
  • 5
  • The error message is about object files obtained from C ones. Looks like your `gcc` generates 32-bit objects, but `g++` works with 64-bit ones. This is definitely wrong environment. – Tsyvarev Feb 09 '23 at 22:37
  • Ummm: tar -xzvf cmake-3.25.2-**linux**-x86_64.tar.gz – Andrew Henle Feb 11 '23 at 16:44

1 Answers1

0

EDIT: Bare in mind that the tarball cmake-3.25.2-linux-x86_64.tar.gz contains precompiled 64bit binaries.

As @Tsyvarev pointed out you are producing 32bit objects. Because you are building on solaris it might be related to the fact that Solaris provides libraries for different architectures. Due to this your linker is probably picking up the wrong binaries.


Possible fixes:

  • Make sure that the linker picks up only the right binaries (64bit)
  • Get CMake which is provided by the package manager of Solaris and build from source files. (official)
  • Use an unofficial CMake package [like this one here]

The official package might be outdated. The unofficial one is well, unofficial.

Milan Š.
  • 1,353
  • 1
  • 2
  • 11
  • Unfortunately opencsw is too old. I tried build from repository https://github.com/Kitware/CMake but still got same error – chs_voks Feb 09 '23 at 23:13
  • @chs_voks If even when you build completely from source (using an older version of CMake) and you still get 32bit binaries (ELF32), then there is no other way than that you have to make sure that the linker doesn't see the 32bit binaries. Refer to what Tsyvarev mentioned under your question. – Milan Š. Feb 10 '23 at 08:46