With Eclipse: How to add include paths and libraries for all your C/C++ project

后端 未结 8 1895
闹比i
闹比i 2020-12-17 09:33

Is it possible to add include paths and libraries to all C/C++ projects? In others words: How can I make them global or copy one C/C++ project build setting to another one?<

相关标签:
8条回答
  • 2020-12-17 10:00

    Semi-automagically, it can be done using this perl script:

    #!/usr/bin/perl
    
    # pipe the (gcc) compile command into this script
    # It emits listOptionValue lines to paste into .cproject
    #
    # To easily find the paste location, set the include path as usual to a string 
    # that is easily recognizable in the .cproject, e.g. to "MARKER_INCLUDE_PATH".
    #
    # Make sure eclipse is not running while you do these sorts of hacks and backup 
    # your .cproject before.
    # -----------------------------------------------------------------------------------------
    # sample line: <listOptionValue builtIn="false" value="/usr/include/gdk-pixbuf-2.0"/>
    
    while (<>) {
        @include_options = m#-I *(.*?) #g;
        print join ("\n", @include_options) . "\n";
        print join ('"/>' ."\n" . '                                 <listOptionValue builtIn="false" value="', @include_options);
        print '"/>' . "\n";
    }
    
    0 讨论(0)
  • 2020-12-17 10:02

    For Eclipse Indigo: There is no possibility to define globally include paths and libraries. But you can export and import them from one project to another.

    Go to Project > Properties > C/C++ General > Paths and Symbols Then click Export Settings... to save the include paths and/or symbol definitions to a file. In your other project, you can then use Import Settings...

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