You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用GCC 5编译C++11程序时gccmakedep报错的解决方案求助

Fixing gccmakedep C++11 Support Error

It looks like you're hitting a limitation of gccmakedep—this is a legacy dependency generation tool that doesn't properly handle modern C++ compiler flags like -std=gnu++11. When you pass these flags to gccmakedep, it doesn't correctly forward them to the underlying compiler during dependency scanning, which leads to the C++11 support error you're seeing.

The good news is there's a much more reliable (and modern) alternative using GCC's built-in dependency generation features. Here's how to fix your Makefile:

Step 1: Replace gccmakedep with GCC's built-in flags

Instead of calling gccmakedep, modify your compile rules to include the -MMD and -MP flags. These flags tell GCC to generate dependency files automatically when compiling your source code.

For example, if your existing compile rule looks like this:

%.o: %.cpp
	gcc -std=gnu++11 -c $< -o $@

Update it to:

%.o: %.cpp
	gcc -std=gnu++11 -MMD -MP -c $< -o $@
  • -MMD: Generates a .d file for each source file, containing the header dependencies (excluding system headers).
  • -MP: Adds phony targets for each header in the dependency list, which prevents Make from throwing errors if a header file is deleted.

Step 2: Include the generated dependency files

Add this line at the end of your Makefile to include all the .d files that GCC generates:

-include $(SRCS:.cpp=.d)

The leading hyphen (-) ensures Make doesn't complain if the .d files don't exist yet (like on your first build).

Step 3: Remove the old gccmakedep command

You can now delete the line in your Makefile that calls gccmakedep—it's no longer needed.

This approach is better because it uses the exact same compiler flags for both compilation and dependency generation, so there's no mismatch in C++ standard support. Plus, it's a more maintainable solution since gccmakedep is deprecated in favor of these built-in GCC features.

内容的提问来源于stack exchange,提问作者mrmc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 23:42:52