microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.45k stars 1.53k forks source link

IntelliSense throws #include errors with valid include paths #5012

Closed RATIU5-zz closed 3 years ago

RATIU5-zz commented 4 years ago

Type: LanguageService

Describe the bug

I loaded an empty OpenFrameworks project which generated the vscode files. I modified the c_cpp_properties.json so all the paths for my Win32 build were correct. When I opened a .cpp or .h file, the red squiggles appeared under many of the #include statements. The error says: #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Developer\openframeworks\14_vscode\src\ofApp.cpp).C/C++(1696) cannot open source file "cairo.h" (dependency of "ofApp.h")C/C++(1696) The last part says that one of the libraries I included includes a library called cario.h that could not be found (unless I'm mistaken, I checked the file and it could not find cario.h'. My project does not need cario.h or any other errors from OpenFramework files. My project can compile and execute just fine when I use MinGW32 to call the makefile. As far as I'm aware, the C/C++ extensions doesn't have to be scanning all my include files to verify they are all perfect as well...

To Reproduce

  1. Update the c_cpp_properties.json to mine
  2. Install OpenFrameworks
  3. Activate the C/C++ Extension
  4. See error in any .cpp file

Expected behavior

C/C++ should automatically recognize the paths and only the files in my current directory to be valid. I don't think the extension should be looking through all the files in my include directories to make sure they are all valid...

Screenshots

image (Both includes have the same error about cario.h...)

Additional context

Colengms commented 4 years ago

Hi @Akidus . In order to provide IntelliSense, it's necessary to do a 'first pass' compilation (parse) of the source file, including resolving all #include'd headers and parsing/compiling them as well. If we cannot find a header, we cannot provide accurate IntelliSense for files that include it. It's necessary to either use c_cpp_properties.json to configure the C/C++ Extension with all of the same paths and defines as used by your build environment, or use a 'custom configuration provider' extension to automatically ingest that information from your build system.

Can you provide the contents of your c_cpp_properties.json, as well as the path to the missing file? Given that a missing header was identified, we would had seen a #include of it while parsing. Perhaps also check that you have added any define's from your build system to c_cpp_properties.json, if there are defines that may influence which headers are included.

RATIU5-zz commented 4 years ago

The file lies in this directory: C:\Developer\of_v0.11.0_vs2017_release\libs\cairo\include\cairo (this is currently not linked to the directory because this was built for vs and I'm using the mingw32 compiler which does not include a cairo.h), as well in C:\msys64\mingw32\include\cairo. Here is also the c_cpp_properties.json:

`{ "env": { "ofPath": "C:/Developer/of_v0.11.0_vs2017_release" },

"configurations": [
    {
        "name": "Mac",
        "includePath": [
            "/usr/include",
            "/usr/local/include",
            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/",
            "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1",
            "${workspaceRoot}/../../../libs/openFrameworks",
            "${workspaceRoot}/../../../libs/openFrameworks/3d",
            "${workspaceRoot}/../../../libs/openFrameworks/app",
            "${workspaceRoot}/../../../libs/openFrameworks/communication",
            "${workspaceRoot}/../../../libs/openFrameworks/events",
            "${workspaceRoot}/../../../libs/openFrameworks/gl",
            "${workspaceRoot}/../../../libs/openFrameworks/graphics",
            "${workspaceRoot}/../../../libs/openFrameworks/math",
            "${workspaceRoot}/../../../libs/openFrameworks/sound",
            "${workspaceRoot}/../../../libs/openFrameworks/types",
            "${workspaceRoot}/../../../libs/openFrameworks/utils",
            "${workspaceRoot}/../../../libs/openFrameworks/video",
            "${workspaceRoot}/../../../libs/boost/include",
            "${workspaceRoot}/../../../libs/cairo/include",
            "${workspaceRoot}/../../../libs/curl/include",
            "${workspaceRoot}/../../../libs/fmodex/include",
            "${workspaceRoot}/../../../libs/FreeImage/include",
            "${workspaceRoot}/../../../libs/freetype/include",
            "${workspaceRoot}/../../../libs/glew/include",
            "${workspaceRoot}/../../../libs/glfw/include",
            "${workspaceRoot}/../../../libs/glm/include",
            "${workspaceRoot}/../../../libs/json/include",
            "${workspaceRoot}/../../../libs/pugixml/include",
            "${workspaceRoot}/../../../libs/rtAudio/include",
            "${workspaceRoot}/../../../libs/tess2/include",
            "${workspaceRoot}/../../../libs/uriparser/include",
            "${workspaceRoot}/../../../libs/utf8/include"
        ],
        "browse": {
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": "${workspaceRoot}/.vscode/browse.db",
            "path": [
                "/usr/include",
                "/usr/local/include",
                "/System/Library/Frameworks",
                "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/",
                "${workspaceRoot}/../../../libs",
                "${workspaceRoot}/../../../addons",
                "${workspaceRoot}/../../../libs/openFrameworks"
            ]
        },
        "intelliSenseMode": "clang-x64",
        "macFrameworkPath": [
            "/System/Library/Frameworks",
            "/Library/Frameworks"
        ],
        "compilerPath": "/usr/local/bin/gcc-8",
        "cStandard": "c11",
        "cppStandard": "c++17"
    },
    {
        "name": "Linux",
        "includePath": [
            "/usr/include",
            "/usr/local/include",
            "/usr/include/c++/5",
            "/usr/include/c++/5/backward",
            "/usr/lib/gcc/x86_64-linux-gnu/5/include",
            "/usr/lib/x86_64-linux-gnu/glib-2.0/include",
            "/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include",
            "/usr/local/include",
            "/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
            "/usr/include/x86_64-linux-gnu",
            "${workspaceRoot}/../../../libs/openFrameworks",
            "${workspaceRoot}/../../../libs/openFrameworks/3d",
            "${workspaceRoot}/../../../libs/openFrameworks/app",
            "${workspaceRoot}/../../../libs/openFrameworks/communication",
            "${workspaceRoot}/../../../libs/openFrameworks/events",
            "${workspaceRoot}/../../../libs/openFrameworks/gl",
            "${workspaceRoot}/../../../libs/openFrameworks/graphics",
            "${workspaceRoot}/../../../libs/openFrameworks/math",
            "${workspaceRoot}/../../../libs/openFrameworks/sound",
            "${workspaceRoot}/../../../libs/openFrameworks/types",
            "${workspaceRoot}/../../../libs/openFrameworks/utils",
            "${workspaceRoot}/../../../libs/openFrameworks/video",
            "${workspaceRoot}/../../../libs/boost/include",
            "${workspaceRoot}/../../../libs/cairo/include",
            "${workspaceRoot}/../../../libs/curl/include",
            "${workspaceRoot}/../../../libs/fmodex/include",
            "${workspaceRoot}/../../../libs/FreeImage/include",
            "${workspaceRoot}/../../../libs/freetype/include",
            "${workspaceRoot}/../../../libs/glew/include",
            "${workspaceRoot}/../../../libs/glfw/include",
            "${workspaceRoot}/../../../libs/glm/include",
            "${workspaceRoot}/../../../libs/json/include",
            "${workspaceRoot}/../../../libs/pugixml/include",
            "${workspaceRoot}/../../../libs/rtAudio/include",
            "${workspaceRoot}/../../../libs/tess2/include",
            "${workspaceRoot}/../../../libs/uriparser/include",
            "${workspaceRoot}/../../../libs/utf8/include",
            "${workspaceRoot}/../../../libs/poco/include",
            "${workspaceRoot}/../../../libs/kiss/include",
            "/usr/include/x86_64-linux-gnu/c++/5",
            "/usr/include/pulse",
            "/usr/include/cairo",
            "/usr/include/gstreamer-1.0",
            "/usr/include/glib-2.0",
            "${workspaceRoot}"
        ],
        "browse": {
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": "",
            "path": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}/../../../libs",
                "${workspaceRoot}/../../../addons",
                "${workspaceRoot}/../../../libs/openFrameworks"
            ]
        },
        "intelliSenseMode": "clang-x64",
        "compilerPath": "/usr/local/bin/gcc-8",
        "cStandard": "c11",
        "cppStandard": "c++17"
    },
    {
        "name": "Win32",
        "includePath": [
            "C:/msys64/mingw32/include/c++/9.2.0",
            "C:/msys64/mingw32/i686-w64-mingw32/include",
            "${ofPath}/libs",
            "${ofPath}/addons",
            "${ofPath}/libs/openFrameworks",
            "${ofPath}/libs/openFrameworks/3d",
            "${ofPath}/libs/openFrameworks/app",
            "${ofPath}/libs/openFrameworks/communication",
            "${ofPath}/libs/openFrameworks/events",
            "${ofPath}/libs/openFrameworks/gl",
            "${ofPath}/libs/openFrameworks/graphics",
            "${ofPath}/libs/openFrameworks/math",
            "${ofPath}/libs/openFrameworks/sound",
            "${ofPath}/libs/openFrameworks/types",
            "${ofPath}/libs/openFrameworks/utils",
            "${ofPath}/libs/openFrameworks/video",
            "${ofPath}/libs/boost/include",
            "${ofPath}/libs/cairo/include",
            "${ofPath}/libs/curl/include",
            "${ofPath}/libs/fmodex/include",
            "${ofPath}/libs/FreeImage/include",
            "${ofPath}/libs/freetype/include",
            "${ofPath}/libs/glew/include",
            "${ofPath}/libs/glfw/include",
            "${ofPath}/libs/glm/include",
            "${ofPath}/libs/json/include",
            "${ofPath}/libs/pugixml/include",
            "${ofPath}/libs/rtAudio/include",
            "${ofPath}/libs/tess2/include",
            "${ofPath}/libs/uriparser/include",
            "${ofPath}/libs/utf8/include"
        ],
        "browse": {
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": "",
            "path": [
                "${ofPath}/libs",
                "${ofPath}/addons",
                "${ofPath}/libs/openFrameworks"    
            ]
        },
        "intelliSenseMode": "clang-x64",
        "compilerPath": "C:/msys64/mingw32/bin/g++.exe",
        "cStandard": "c11",
        "cppStandard": "c++17"
    }
],
"version": 4

}`

Colengms commented 4 years ago

Hi @Akidus . Your configurations do not include "defines" sections. Is it possible that defines are being generated by the build system to control whether or not cairo should be used? If so, those will need to be added to your configuration(s).

RATIU5-zz commented 4 years ago

@Colengms thanks for your reply. I have not used "defines" before and am not sure how to configure them/how to use them. That could be the solution; what would I need to add in the "defines" section?

Colengms commented 4 years ago

@johnratius For information on adding defines to your c_cpp_properties.json, we have documentation here. But, determining what defines you need requires some knowledge of your build system (contents of your makefile). I see from the image you posted that you also have a vcxproj file. You might try opening the vcxproj in VS, getting properties on the project, and looking at C/C++ -> Preprocessor -> Preprocessor Definitions, to see what defines it has set there. If you don't have VS, you could open the vcxproj as a text file (it's XML), and look for "PreprocessorDefinitions" section. Or, if this is an open source project, you might try to get support from others familiar with the project.

Unfortunately, the only custom configuration provider we have currently is for CMake. We are working on more.

RATIU5-zz commented 4 years ago

I looked at the Preprocessor Definitions and I found these only:

WIN32
_DEBUG
_CONSOLE
POCO_STATIC
CAIRO_WIN32_STATIC_BUILD
DISABLE_SOME_FLOATING_POINT
_UNICODE
UNICODE

I will try adding these and edit in the results.

Same error occurred. I decided to add the cario.h path to the includes, but another error came up saying that another library, videoInput.h, cannot be found.

The makefile that is being included by the one in my current directory is this:

.DEFAULT_GOAL=Release

# define the OF_SHARED_MAKEFILES location
OF_SHARED_MAKEFILES_PATH=$(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon

# if APPNAME is not defined, set it to the project dir name
ifndef APPNAME
    APPNAME = $(shell basename `pwd`)
endif

include $(OF_SHARED_MAKEFILES_PATH)/config.shared.mk

# Name TARGET
ifeq ($(findstring Debug,$(MAKECMDGOALS)),Debug)
    TARGET_NAME = Debug

    ifndef RUN_TARGET
        RUN_TARGET = RunDebug
    endif

    ifndef PLATFORM_PROJECT_DEBUG_TARGET
        TARGET = bin/$(APPNAME)_debug
    else
        TARGET = $(PLATFORM_PROJECT_DEBUG_TARGET)
    endif

    ifndef PLATFORM_PROJECT_DEBUG_BIN_NAME
        BIN_NAME = $(APPNAME)_debug
    else
        BIN_NAME = $(PLATFORM_PROJECT_DEBUG_BIN_NAME)
    endif
else ifeq ($(findstring Release,$(MAKECMDGOALS)),Release)
    TARGET_NAME = Release

    ifndef RUN_TARGET
        RUN_TARGET = RunRelease
    endif

    ifndef PLATFORM_PROJECT_RELEASE_TARGET
        TARGET = bin/$(APPNAME)
    else
        TARGET = $(PLATFORM_PROJECT_RELEASE_TARGET)
    endif

    ifndef PLATFORM_PROJECT_RELEASE_BIN_NAME
        BIN_NAME = $(APPNAME)
    else
        BIN_NAME = $(PLATFORM_PROJECT_RELEASE_BIN_NAME)
    endif

else ifeq ($(MAKECMDGOALS),run)
    TARGET_NAME = Release
    ifndef PLATFORM_PROJECT_RELEASE_TARGET
        TARGET = bin/$(APPNAME)
    else
        TARGET = $(PLATFORM_PROJECT_RELEASE_TARGET)
    endif
    ifndef PLATFORM_PROJECT_RELEASE_BIN_NAME
        BIN_NAME = $(APPNAME)
    else
        BIN_NAME = $(PLATFORM_PROJECT_RELEASE_BIN_NAME)
    endif

else ifeq ($(MAKECMDGOALS),)
    TARGET_NAME = Release

    ifndef RUN_TARGET
        RUN_TARGET = run
    endif

    ifndef PLATFORM_PROJECT_RELEASE_TARGET
        TARGET = bin/$(APPNAME)
    else
        TARGET = $(PLATFORM_PROJECT_RELEASE_TARGET)
    endif

    ifndef PLATFORM_PROJECT_RELEASE_BIN_NAME
        BIN_NAME = $(APPNAME)
    else
        BIN_NAME = $(PLATFORM_PROJECT_RELEASE_BIN_NAME)
    endif
endif

ABIS_TO_COMPILE =

ifeq ($(findstring Release,$(TARGET_NAME)),Release)
    ifdef ABIS_TO_COMPILE_RELEASE
        ABIS_TO_COMPILE += $(ABIS_TO_COMPILE_RELEASE)
    endif
endif

ifeq ($(findstring Debug,$(TARGET_NAME)),Debug)
    ifdef ABIS_TO_COMPILE_DEBUG
        ifeq ($(findstring Release,$(TARGET_NAME)),Release)
            ifdef ABIS_TO_COMPILE_RELEASE
                ABIS_TO_COMPILE = $(filter-out $(ABIS_TO_COMPILE_DEBUG),$(ABIS_TO_COMPILE_RELEASE))
            endif
        endif
        ABIS_TO_COMPILE += $(ABIS_TO_COMPILE_DEBUG)
    endif
endif

ifeq ($(MAKECMDGOALS),clean)
    TARGET = bin/$(APPNAME)_debug bin/$(APPNAME)
    TARGET_NAME = Release
endif

# we only get a CLEAN_TARGET if a TARGET_NAME has been defined
# Like TARGET, this must be defined above or in a platform file.
ifdef TARGET_NAME
    CLEANTARGET = $(addprefix Clean,$(TARGET_NAME))
endif

ifeq ($(findstring ABI,$(MAKECMDGOALS)),ABI)
    include $(OF_SHARED_MAKEFILES_PATH)/config.project.mk
    -include $(OF_PROJECT_DEPENDENCY_FILES)
endif

.PHONY: all Debug Release after clean CleanDebug CleanRelease help force

Release:
    @echo Compiling OF library for Release
    @$(MAKE) -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Release PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_RELEASE="$(ABIS_TO_COMPILE_RELEASE)"
    @echo
    @echo
    @echo Compiling $(APPNAME) for Release
ifndef ABIS_TO_COMPILE_RELEASE
    @$(MAKE) ReleaseABI
else
    @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) ReleaseABI ABI=$(abi) &&) echo
endif

Debug:
    @echo Compiling OF library for Debug
    $(MAKE) -C $(OF_ROOT)/libs/openFrameworksCompiled/project/ Debug PLATFORM_OS=$(PLATFORM_OS) ABIS_TO_COMPILE_DEBUG="$(ABIS_TO_COMPILE_DEBUG)"
    @echo
    @echo
    @echo Compiling $(APPNAME) for Debug
ifndef ABIS_TO_COMPILE_DEBUG
    @$(MAKE) DebugABI
else
    @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo
endif

ReleaseNoOF:
    @echo Compiling $(APPNAME) for Release
ifndef ABIS_TO_COMPILE_RELEASE
    @$(MAKE) ReleaseABI
else
    @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) ReleaseABI ABI=$(abi) &&) echo
endif

DebugNoOF:
    @echo Compiling $(APPNAME) for Debug
ifndef ABIS_TO_COMPILE_DEBUG
    @$(MAKE) DebugABI
else
    @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) DebugABI ABI=$(abi) &&) echo
endif

ReleaseABI: $(TARGET)
ifneq ($(strip $(PROJECT_ADDONS_DATA)),)
    @$(MAKE) copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)"
endif
    @$(MAKE) afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_RELEASE)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET)
    @$(PROJECT_AFTER)

DebugABI: $(TARGET)
ifneq ($(strip $(PROJECT_ADDONS_DATA)),)
    @$(MAKE) copyaddonsdata PROJECT_ADDONS_DATA="$(PROJECT_ADDONS_DATA)"
endif
    @$(MAKE) afterplatform BIN_NAME=$(BIN_NAME) ABIS_TO_COMPILE="$(ABIS_TO_COMPILE_DEBUG)" RUN_TARGET=$(RUN_TARGET) TARGET=$(TARGET)
    @$(PROJECT_AFTER)

all:
    $(MAKE) Debug

run:
ifeq ($(PLATFORM_RUN_COMMAND),)
    @cd bin;./$(BIN_NAME)
else
    @$(PLATFORM_RUN_COMMAND)
endif

RunRelease:
ifeq ($(PLATFORM_RUN_COMMAND),)
    @cd bin;./$(BIN_NAME)
else
    @$(PLATFORM_RUN_COMMAND)
endif

RunDebug:
ifeq ($(PLATFORM_RUN_COMMAND),)
    @cd bin;./$(BIN_NAME)
else
    @$(PLATFORM_RUN_COMMAND)
endif

$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags: force
    @mkdir -p $(OF_PROJECT_OBJ_OUTPUT_PATH)
    @if [ "$(strip $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) $(OPTIMIZATION_LDFLAGS) $(LDFLAGS))" != "$(strip $$(cat $@ 2>/dev/null))" ]; then echo $(strip $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) $(OPTIMIZATION_LDFLAGS) $(LDFLAGS)) > $@; fi

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags: force
    @mkdir -p $(OF_PROJECT_OBJ_OUTPUT_PATH)
    @mkdir -p $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)
    @if [ "$(strip $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS))" != "$(strip $$(cat $@ 2>/dev/null))" ]; then echo $(strip $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS)) > $@; fi

# Rules to compile the project sources
#$(OBJS): $(SOURCES)
$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.cpp $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.cxx $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.cc $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.m $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.mm $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.c $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_ROOT)/%.S $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS)  $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

#Rules to create and compile resource file to include icon
$(OF_PROJECT_OBJ_OUTPUT_PATH)%.res: $(ICON)
    @echo "Compiling Resource" $<
#Need to build an intermediate .rc file with Windows-like file path (C:/myproject/theIcon.ico)
    @echo MAINICON ICON \"$(shell cygpath -m $<)\" > $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.rc
    @$(RESOURCE_COMPILER) $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.rc -O coff -o $@

# Rules to compile the project external sources
$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.cpp $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.cxx $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    @$(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.cc $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.m $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.mm $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.c $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(PROJECT_EXTERNAL_SOURCE_PATHS)/%.S $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(PROJECT_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

#Rules to compile the addons sources when the addon path is specified explicitly
PROJECT_ADDONS_OBJ_PATH=$(realpath .)/$(OF_PROJECT_OBJ_OUTPUT_PATH)addons/
$(PROJECT_ADDONS_OBJ_PATH)%.o: %.cpp $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.cxx $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    @$(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.m $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.mm $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.cc $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.c $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

$(PROJECT_ADDONS_OBJ_PATH)%.o: %.S $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
ifdef PROJECT_ADDON_PATHS
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(PROJECT_ADDONS_OBJ_PATH)$*.d -MT $(PROJECT_ADDONS_OBJ_PATH)$*.o -o $@ -c $<
endif

#Rules to compile the standard addons sources
$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.cpp $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.cxx $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.cc $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.m $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.mm $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.c $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

$(OF_ADDONS_PATH)/addons/$(OF_PROJECT_OBJ_OUTPUT_PATH)%.o: $(OF_ADDONS_PATH)/%.S $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CC) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.d -MT $(OF_ADDONS_PATH)/$(OF_PROJECT_OBJ_OUTPUT_PATH)$*.o -o $@ -c $<

# Rules to compile the addons sources from the core
$(OF_PROJECT_OBJ_OUTPUT_PATH)libs/openFrameworks/%.o: $(OF_ROOT)/libs/openFrameworks/%.cpp $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo "Compiling" $<
    @mkdir -p $(@D)
    $(CXX) -c $(OPTIMIZATION_CFLAGS) $(CFLAGS) $(CXXFLAGS) $(OF_CORE_INCLUDES_CFLAGS) $(ADDON_INCLUDE_CFLAGS) -MMD -MP -MF $(OF_PROJECT_OBJ_OUTPUT_PATH)libs/openFrameworks/$*.d -MT $(OF_PROJECT_OBJ_OUTPUT_PATH)libs/openFrameworks/$*.o -o $@ -c $<

# Rules to link the project
$(TARGET): $(OF_PROJECT_OBJS) $(OF_PROJECT_RESOURCES) $(OF_PROJECT_ADDONS_OBJS) $(OF_PROJECT_LIBS) $(TARGET_LIBS) $(OF_PROJECT_OBJ_OUTPUT_PATH).compiler_flags
    @echo 'Linking $(TARGET) for $(ABI_LIB_SUBPATH)'
    @mkdir -p $(@D)
    $(CXX) -o $@ $(OPTIMIZATION_LDFLAGS) $(OF_PROJECT_OBJS) $(OF_PROJECT_RESOURCES) $(OF_PROJECT_ADDONS_OBJS) $(TARGET_LIBS) $(OF_PROJECT_LIBS) $(LDFLAGS) $(OF_CORE_LIBS)

clean:
    @$(MAKE) CleanDebug
    @$(MAKE) CleanRelease

$(CLEANTARGET)ABI:
ifneq ($(OF_PROJECT_ADDONS_OBJS),)
    rm -f $(OF_PROJECT_ADDONS_OBJS)
endif
    rm -rf $(OF_PROJECT_OBJ_OUTPUT_PATH)
    rm -f $(TARGET)
    rm -rf $(BIN_NAME)

$(CLEANTARGET):
ifndef ABIS_TO_COMPILE
    @$(MAKE) $(CLEANTARGET)ABI
else
ifeq ($(TARGET_NAME),Debug)
    @$(foreach abi,$(ABIS_TO_COMPILE_DEBUG),$(MAKE) $(CLEANTARGET)ABI ABI=$(abi) &&) echo done
else
    @$(foreach abi,$(ABIS_TO_COMPILE_RELEASE),$(MAKE) $(CLEANTARGET)ABI ABI=$(abi) &&) echo done
endif
endif
    @rm -rf bin/libs

after: $(TARGET_NAME)
    @if [ -e $(OF_LIBS_PATH)/*/lib/$(PLATFORM_LIB_SUBPATH)/*.$(SHARED_LIB_EXTENSION) ]; then cp $(OF_LIBS_PATH)/*/lib/$(PLATFORM_LIB_SUBPATH)/*.$(SHARED_LIB_EXTENSION) bin/; fi
    @echo
    @echo "     compiling done"
    @echo "     to launch the application"
    @echo
    @echo "     cd bin"
    @echo "     ./$(BIN_NAME)"
    @echo "     "
    @echo "     - or -"
    @echo "     "
    @echo "     $(MAKE) $(RUN_TARGET)"
    @echo

copyaddonsdata:
    @echo
    @echo "Copying addons data"
    @mkdir -p bin/data
    @cp -rf $(PROJECT_ADDONS_DATA) bin/data/

help:
    @echo
    @echo openFrameworks universal makefile
    @echo
    @echo "Targets:"
    @echo
    @echo "make Debug:      builds the library with debug symbols"
    @echo "make Release:        builds the library with optimizations"
    @echo "make:            = make Release"
    @echo "make all:        = make Release"
    @echo "make CleanDebug: cleans the Debug target"
    @echo "make CleanRelease:   cleans the Release target"
    @echo "make clean:      cleans everything"
    @echo "make help:       this help message"
    @echo
    @echo
    @echo this should work with any OF app, just copy any example
    @echo change the name of the folder and it should compile
    @echo "only .cpp support, don't use .c files"
    @echo it will look for files in any folder inside the application
    @echo folder except that in the EXCLUDE_FROM_SOURCE variable.
    @echo "it doesn't autodetect include paths yet"
    @echo "add the include paths editing the var USER_CFLAGS"
    @echo at the beginning of the makefile using the gcc syntax:
    @echo -Ipath
    @echo
    @echo to add addons to your application, edit the addons.make file
    @echo in this directory and add the names of the addons you want to
    @echo include
    @echo

#legacy targets
AndroidRelease:
    $(MAKE) Release PLATFORM_OS=Android

AndroidDebug:
    $(MAKE) Debug PLATFORM_OS=Android

CleanAndroid:
    $(MAKE) clean PLATFORM_OS=Android
github-actions[bot] commented 3 years ago

Hey @Colengms, this issue might need further attention.

@RATIU5, you can help us out by closing this issue if the problem no longer exists, or adding more information.

RATIU5-zz commented 3 years ago

I don't have time to look at this issue right now on my project, so I will close this for now.

sean-mcmanus commented 3 years ago

@Colengms Did you need more repro info still?