Getting Eclipse CDT to use relative include paths in generated Makefiles

前端 未结 4 775
难免孤独
难免孤独 2020-12-17 16:56

I am using the Eclipse CDT. I have configured the \"external Builder\" and I am generating the Makefiles automatically. Unfortunately, the generated Makefiles contain the ab

相关标签:
4条回答
  • 2020-12-17 17:26

    The relative paths you add in "Project > Properties > C/C++ General > Paths and Symbols > Includes" tab are relative to your project folder.

    The ones that appear in the generated makefiles are relative to the main Makefile location.

    0 讨论(0)
  • 2020-12-17 17:38

    I found this question asked long time ago. I'm trying to setup GitLab CI with Eclipse CDT, the easiest way suggested is to use the existing makefile the CDT generated. But, I was unable to easily config the Eclipse CDT to generate the makefile in my project with relative path easily, I can see I can get "include" settings changed, but there are other files referenced in the makefile using absolute path in the make files too. So I just used a PowerShell script to update all the absolute path into relative path. Check the PWD for the absolute path, then count the ../ to back out to the root of the project. Mine was 5 folder deep.

    ls *.mk -rec | %{ $f=$_; (gc $f.PSPath) | %{ $_ -replace "c:/absolute path", "../../../../.." } | sc $f.PSPath }
    
    0 讨论(0)
  • 2020-12-17 17:39

    There is a better way to do this: "Project > Properties > C/C++ Build > Settings > Tool Settings > Cross G++ [or GCC] Compiler > Includes". Click plus button, then write:

    "${ProjDirPath}/../../../somefolder1/somefolder2"

    This approach allows you to specify any external folder by relative path to your project folder, even if it is located in parent subfolders.

    0 讨论(0)
  • 2020-12-17 17:42

    If you use relative path in the 'include paths' (instead of ${workspace_loc}), then the makefile (and .mk files it uses) will include relative paths as well.

    0 讨论(0)
提交回复
热议问题