boocs / ue4-intellisense-fixes

Automatically fixes VSCode/Unreal Engine Intellisense Config bugs on startup
MIT License
162 stars 9 forks source link

Issues on Linux with UE5 #24

Closed ReazerDev closed 10 months ago

ReazerDev commented 1 year ago

Hi, I'm getting these errors in a new project (I don't have any existing projects, as I'm just getting started with UE5 development).

Searching for *.uproject file...
Searching with fast-glob found nothing. (Sometimes isn't bug)
*.uproject file was found!

Extension "UE Intellisense Fixes" 3.4.0 is now active!

Found Unreal Engine v5.0.3

** Error **: 0: Couldn't create compileCommands from /home/sandro/Documents/Unreal Projects/MyProject/.vscode/compileCommands_Default.json with key:MAIN! (not an error with UE 4.25.#)

** Error **: Did not create any compile commands with keyMAIN! (not an error with UE 4.25.#)

** Error **: Error in loadCompileCommandsFromWorkspace!

** Error **: This fixable project hasn't been initialized properly and is invalid.

** Error **: Couldn't create file watchers!

*** Number of error messages: 5
*** Number of warning messages: 0
If you get any errors you can try restarting VSCode to check if they've been fixed.

Extension is done.

My compileCommands_Default.json contains an empty array. My c_cpp_properties.json looks like this:

{
    "configurations": [
        {
            "name": "Linux",
            "intelliSenseMode": "clang-x64",
            "compileCommands": "/home/sandro/Documents/Unreal Projects/MyProject/.vscode/compileCommands_Default.json",
            "cStandard": "c17",
            "cppStandard": "c++14"
        }
    ],
    "version": 4
}

My settings look like this: image Enabling Optional Fixes, doesn't change anything

boocs commented 1 year ago

The first error could be because the compile command file is blank for some reason? Can you check the file in this path?

/home/sandro/Documents/Unreal Projects/MyProject/.vscode/compileCommands_Default.json
  1. Do you have any project source files created yet? Could be why the compile commands file is blank.
  2. Try I project reset to fix. Right click the project's *.uproject file and choose Generate Project Files (or something similar)

Your compiler should be clang++ and version 13.0.1 for linux. Check your clang version in the terminal with usr/bin/clang++ -v


Your Cpp Standard should be c++17 for UE5. Of course you can experiment with c++20 once you got the default to work. I'm sure it will.

ReazerDev commented 1 year ago

I did regenerate a few times already, but it didn't help. My clang++ version is 14.0.6.

Compilation etc. works, even through VSC, but I still get IntelliSense errors.

ReazerDev commented 1 year ago

Ok, so I've been able to resolve some issues (not with the extension, but with IntelliSense not working), by adding "defines": ["UBT_COMPILED_PLATFORM=Linux"], to my c_cpp_properties.json. The last issue I seem to have is that the *.generated.h Header files are not being found. Is that something the Extension is able to fix? If not, do you happen to know, how to fix it?

ReazerDev commented 1 year ago

Actually, could you just send me the contents of your defines array in c_cpp_properties.json? I've added "${workspaceFolder}/Intermediate/Build/Linux/B4D820EA/UnrealEditor/Inc/MyProject" to my includePath and it now finds the .generated.h files.

The only issue I get now is image Adding TCHAR= to defines in c_cpp_properties.json get's rid of this error, but I'm getting a few other type errors now: image image

(Oh and sorry for spamming this issue with so many comments, I'm kinda documenting my progress)

This is currently what is in my defines array. I've copied it from some forum, but it's for UE4, so I hope you have an up-to-date one for UE5?^^

"IS_PROGRAM=0",
              "UE_EDITOR=1",
              "WITH_DEV_AUTOMATION_TESTS=1",
              "WITH_PERF_AUTOMATION_TESTS=1",
              "UNICODE",
              "_UNICODE",
              "__UNREAL__",
              "IS_MONOLITHIC=0",
              "WITH_ENGINE=1",
              "WITH_UNREAL_DEVELOPER_TOOLS=1",
              "WITH_COREUOBJECT=1",
              "USE_STATS_WITHOUT_ENGINE=0",
              "WITH_PLUGIN_SUPPORT=0",
              "WITH_PERFCOUNTERS=1",
              "USE_LOGGING_IN_SHIPPING=0",
              "WITH_LOGGING_TO_MEMORY=0",
              "USE_CACHE_FREED_OS_ALLOCS=1",
              "USE_CHECKS_IN_SHIPPING=0",
              "UE_BUILD_MINIMAL=0",
              "WITH_EDITOR=1",
              "WITH_SERVER_CODE=1",
              "WITH_CEF3=1",
              "WITH_XGE_CONTROLLER=1",
              "UBT_COMPILED_PLATFORM=Linux",
              "UBT_COMPILED_TARGET=Editor",
              "DEPTH_32_BIT_CONVERSION=0",
              "NDEBUG=1",
              "UE_BUILD_DEVELOPMENT=1",
              "ORIGINAL_FILE_NAME='UEEditor-MyProject.dll'",
              "UE_IS_ENGINE_MODULE=0",
              "UE_BUILD_DEVELOPMENT_WITH_DEBUGGAME=0",
              "UE_PROJECT_NAME=NewTest",
              "DEPRECATED_FORGAME=DEPRECATED",
              "NEWTEST_API=",
              "UE_ENABLE_ICU=1",
              "WITH_VS_PERF_PROFILER=0",
              "WITH_DIRECTXMATH=0",
              "CORE_API=",
              "COREUOBJECT_API=",
              "WITH_PHYSX=1",
              "WITH_APEX=1",
              "WITH_APEX_CLOTHING=1",
              "WITH_CLOTH_COLLISION_DETECTION=1",
              "WITH_PHYSX_COOKING=1",
              "WITH_NVCLOTH=1",
              "WITH_RECAST=1",
              "ENGINE_API=",
              "APPLICATIONCORE_API=",
              "RHI_API=",
              "JSON_API=",
              "SLATE_DEFERRED_DESIRED_SIZE=0",
              "WITH_FREETYPE=1",
              "SLATECORE_API=",
              "INPUTCORE_API=",
              "SLATE_API=",
              "WITH_UNREALPNG=1",
              "WITH_UNREALJPEG=1",
              "WITH_UNREALEXR=1",
              "IMAGEWRAPPER_API=",
              "MESSAGINGCOMMON_API=",
              "MESSAGING_API=",
              "RENDERCORE_API=",
              "SHADERCORE_API=",
              "UTILITYSHADERS_API=",
              "ASSETREGISTRY_API=",
              "ENGINEMESSAGES_API=",
              "ENGINESETTINGS_API=",
              "SYNTHBENCHMARK_API=",
              "RENDERER_API=",
              "GAMEPLAYTAGS_API=",
              "WITH_GAMEPLAY_DEBUGGER=1",
              "AIMODULE_API=",
              "GAMEPLAYTASKS_API=",
              "DATABASESUPPORT_API=",
              "PACKETHANDLER_API=",
              "RELIABILITYHANDLERCOMPONENT_API=",
              "HARDWARESURVEY_API=",
              "UNREALED_API=",
              "BSPMODE_API=",
              "DIRECTORYWATCHER_API=",
              "DOCUMENTATION_API=",
              "LOAD_PLUGINS_FOR_TARGET_PLATFORMS=1",
              "PROJECTS_API=",
              "SANDBOXFILE_API=",
              "EDITORSTYLE_API=",
              "SOURCE_CONTROL_WITH_SLATE=1",
              "SOURCECONTROL_API=",
              "UNREALEDMESSAGES_API=",
              "GAMEPLAYDEBUGGER_API=",
              "BLUEPRINTGRAPH_API=",
              "HTTP_PACKAGE=1",
              "HTTP_API=",
              "UNREALAUDIO_API=",
              "FUNCTIONALTESTING_API=",
              "AUTOMATIONCONTROLLER_API=",
              "LOCALIZATION_API=",
              "AUDIOEDITOR_API=",
              "LEVELEDITOR_API=",
              "SETTINGS_API=",
              "INTROTUTORIALS_API=",
              "HEADMOUNTEDDISPLAY_API=",
              "VREDITOR_API=",
              "LANDSCAPE_API=",
              "PROPERTYEDITOR_API=",
              "ACTORPICKERMODE_API=",
              "SCENEDEPTHPICKERMODE_API=",
              "DETAILCUSTOMIZATIONS_API=",
              "CLASSVIEWER_API=",
              "GRAPHEDITOR_API=",
              "CONTENTBROWSER_API=",
              "ENABLE_HTTP_FOR_NFS=1",
              "NETWORKFILESYSTEM_API=",
              "SOCKETS_PACKAGE=1",
              "SOCKETS_API=",
              "UMG_API=",
              "MOVIESCENE_API=",
              "MOVIESCENETRACKS_API=",
              "WITH_OGGVORBIS=1",
              "XAUDIO2_API=",
              "AUDIOMIXERXAUDIO2_API=",
              "COLLECTIONMANAGER_API=",
              "ADDCONTENTDIALOG_API=",
              "USE_EMBREE=1",
              "MESHUTILITIES_API=",
              "MESHMERGEUTILITIES_API=",
              "HIERARCHICALLODUTILITIES_API=",
              "MESHREDUCTIONINTERFACE_API=",
              "ASSETTOOLS_API=",
              "KISMETCOMPILER_API=",
              "KISMET_API=",
              "CLOTHINGSYSTEMRUNTIMEINTERFACE_API=",
              "NETWORKREPLAYSTREAMING_API=",
              "AUDIOMIXER_API="
boocs commented 1 year ago

You're trying to do the old way of doing Intellisense which ended with 4.25.#. This is beyond the scope of this extension.

There is a better manual solution if you can't figure out why project creation is broken. Unreal Build Tool has the ability to create a clang database file(complete compile commands file) for your project. You can then use this file for the Microsoft C++ extension or setup and use it with the ClangD extension. Here's the VSCode(launch.json) way to do it but you can do it from the terminal as well. Note: Win64 should be changed to Linux and ClangDTest is my project name The database will be created in the UE5 folder Search Unreal GenerateClangDataBase on google for more info.

{
            "name": "Generate Clang Database",
            "type": "coreclr",
            "request": "launch",
            "program": "J:\\Program Files\\Epic Games\\UE_5.0\\Engine\\Binaries\\DotNET\\UnrealBuildTool\\UnrealBuildTool",
            "args": [
                "Development",
                "Win64",
                "ClangDTest",
                "K:\\ME\\Documents\\Unreal Projects\\ClangDTest\\ClangDTest.uproject",
                "-mode=GenerateClangDataBase"
            ],
            "console": "externalTerminal",
            "stopAtEntry": false,
            "cwd": "J:\\Program Files\\Epic Games\\UE_5.0"
        }
ReazerDev commented 1 year ago

Seems to have been an issue with the Binary provided by Epic games. I built UE5 from source, and now the extension works. My compileCommands files are filled and IntelliSense works.