0201
尝试在本机安装Geant4的四种碰壁方式:
1)wsl1 ubuntu20.04安装(Geant4-v11.1.2和v10.7.3)报错(https://geant4-forum.web.cern.ch/t/error-running-example-b1-qt-qpa-xcb-could-not-connect-to-display/11113/17),尝试升级到ubuntu22.04,在重启系统时报错System has not been booted with systemd as init system (PID 1). Can't operate.
2)Win10+Geant4-v11.2.0+Cmake3.27.9+Qt6.6.1
参照(https://zhuanlan.zhihu.com/p/181715788),使用Cmake能顺利 Generate,但执行cmake --build . --config Release --target install后报错(全部输出error.txt),同时install文件夹内为空。
考虑可能是C++标准的默认设置需要更改,参考(https://blog.csdn.net/qq_30795779/article/details/121207472)修改后无效果。
参考(如何修改VS2017、VS2019、VS2022中C++默认版本_vs2017的c++版本-CSDN博客)(VS2019或VS2017没有Microsoft.Cpp.x64.user/找不到Debug|Win32等_vs中debugx64属性下无.user-CSDN博客)添加MSBuild并修改后,在VS中新打开的项目默认c++标准已经变为cpp17,但是重新编译和安装Geant4仍然报之前一样的错误。
发现原来犯了一个很低级的错误,安装Qt时应该选择msvc2019,而我一开始选了mingw。更改Qt组件之后重新编译和安装,这回报错少了两种,如图,但install文件夹还是空的。
3)其他不变,下载了Qt5.15.12的源码zip(没有.exe安装程序),解压之后找不到Cmake需要的lib
4)其他不变,下载了Qt5.12.12的.exe程序,但是其只支持VS2015和2017,本机安装的是VS2019
只安装了MSVC 2017 64-bit,编译和安装中途报同样的错(未中断):
D:\geant4\geant4-v11.2.0\source\global\management\src\G4PhysicsModelCatalog.cc(684,112): error C2445: 条件表达式的 result 类型有
歧义: 类型“_Ty”和“const char [10]”可转换为多个常见类型 [D:\geant4\geant4-v11.2.0_build\source\G4global.vcxproj]
with
[
_Ty=G4String
]
D:\geant4\geant4-v11.2.0\source\global\management\src\G4PhysicsModelCatalog.cc(684,112): message : 可能是“_Ty” [D:\geant4\
geant4-v11.2.0_build\source\G4global.vcxproj]
with
[
_Ty=G4String
]
D:\geant4\geant4-v11.2.0\source\global\management\src\G4PhysicsModelCatalog.cc(684,112): message : 或 “const char * ”
[D:\geant4\geant4-v11.2.0_build\source\G4global.vcxproj]
同时install文件夹仍然为空,无法按照官网(Postinstall Setup — Geant4 Installation Guide 11.2 documentation)提示设置环境变量。
尝试安装Geant4-10.6.3 ,编译安装时出现类似报错,同时install文件夹仍为空。
D:\geant4\geant4-v10.6.3\source\geometry\navigation\src\G4Navigator.cc(1053,72): error C2445: 条件表达式的 result 类型有歧义: 类型“c
onst G4String”和“const char [1]”可转换为多个常见类型 [D:\geant4\geant4-build\source\geometry\G4geometry.vcxproj]
D:\geant4\geant4-v10.6.3\source\geometry\navigation\src\G4Navigator.cc(1053,72): message : 可能是“const G4String” [D:\gean
t4\geant4-build\source\geometry\G4geometry.vcxproj]
D:\geant4\geant4-v10.6.3\source\geometry\navigation\src\G4Navigator.cc(1053,72): message : 或 “const char *” [D:\gean
t4\geant4-build\source\geometry\G4geometry.vcxproj]
按照大佬抛给我的解决方案能够修复单个文件的歧义问题,但是在编译和安装过程中同类型报错不可胜数,逐个修改不现实。
手动修改了好几个文件之后,又出现了新的报错,看到报错之后就Ctrl+C中止了。
d:\geant4\geant4-v11.2.0-build>cmake --build . --config Release
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Auto build dll exports
G4clhep.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bin
\G4clhep.dll
Auto build dll exports
ptl-shared.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\
bin\G4ptl.dll
Auto build dll exports
G4global.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bi
n\G4global.dll
Auto build dll exports
G4intercoms.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release
\bin\G4intercoms.dll
Auto build dll exports
G4graphics_reps.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Rel
ease\bin\G4graphics_reps.dll
Auto build dll exports
G4zlib.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bin\
G4zlib.dll
Auto build dll exports
G4materials.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release
\bin\G4materials.dll
Auto build dll exports
G4geometry.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\
bin\G4geometry.dll
Auto build dll exports
G4particles.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release
\bin\G4particles.dll
Auto build dll exports
G4track.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bin
\G4track.dll
Auto build dll exports
G4digits_hits.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Relea
se\bin\G4digits_hits.dll
Auto build dll exports
G4expat.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bin
\G4expat.dll
Auto build dll exports
G4analysis.vcxproj -> D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\
bin\G4analysis.dll
G4LatticeManager.cc
G4LatticeReader.cc
G4PhononDownconversion.cc
G4PhononPolarization.cc
G4PhononReflection.cc
G4PhononScattering.cc
G4PhononTrackMap.cc
G4VPhononProcess.cc
??????...
G4ChannelingTrackData.cc
G4ChannelingOptrMultiParticleChangeCrossSection.cc
G4ChannelingOptrChangeCrossSection.cc
G4ChannelingMaterialData.cc
G4Channeling.cc
G4ChannelingECHARM.cc
??????...
G4FastSimHitMaker.cc
G4FastSimulationHelper.cc
G4FastSimulationManager.cc
G4FastSimulationManagerProcess.cc
G4FastSimulationMessenger.cc
G4FastStep.cc
G4FastTrack.cc
G4GlobalFastSimulationManager.cc
G4VFastSimulationModel.cc
??????...
G4EnergySplitter.cc
G4ParallelWorldProcess.cc
G4ParallelWorldProcessStore.cc
G4ParallelWorldScoringProcess.cc
G4ScoreSplittingProcess.cc
??????...
G4CoupledTransportation.cc
G4NeutronKiller.cc
G4NeutronKillerMessenger.cc
G4StepLimiter.cc
G4Transportation.cc
G4TransportationParameters.cc
G4TransportationLogger.cc
G4VTrackTerminator.cc
??????...
Auto build dll exports
G4MoleculeGunMessenger.obj : error LNK2005: "public: virtual void __cdecl TG4
MoleculeShoot<class G4Track>::Shoot(class G4MoleculeGun *)" (?Shoot@?$TG4Mole
culeShoot@VG4Track@@@@UEAAXPEAVG4MoleculeGun@@@Z) ??? G4MoleculeGun.obj ??? [
D:\geant4\geant4-v11.2.0-build\source\G4processes.vcxproj]
????? D:/geant4/geant4-v11.2.0-build/BuildProducts/Release/lib/G4processe
s.lib ??? D:/geant4/geant4-v11.2.0-build/BuildProducts/Release/lib/G4proces
ses.exp
D:\geant4\geant4-v11.2.0-build\BuildProducts\Release\bin\G4processes.dll : fa
tal error LNK1169: ?????????????? [D:\geant4\geant4-v11.2.0-build\source\G4pr
ocesses.vcxproj]
Building Custom Rule D:/geant4/geant4-v11.2.0/source/CMakeLists.txt
G4InteractorMessenger.cc
G4UIArrayString.cc
G4UIcsh.cc
????????...
^C
d:\geant4\geant4-v11.2.0-build>