codeblocks cbp 转 makefile

codeblocks是一个跨平台的C/C++的IDE,页面简单好用,在写C/C++工程的时候其才采用自有的工程文件(.cbp)来组织相关源码,但是有时候需要在Linux环境下运行,需要把编译工程转成makefile,codeblocks有一个自动将cbp工程文件转换为makefile的工具---cbp2make,下面我介绍如何使用cbp2make

1,下载工具:

https://sourceforge.net/projects/cbp2make/

2,解压工具,并把

cbp2makefile\cbp2make-stl-rev147-all\bin\cbp2make.linux 放到Linux环境下,更改权限和可执行属性(chomd +x),比如更改为

cbp2make,放到执行目录或环境变量目录下 /usr/local/bin

3,执行转换命令

     cbp2make -in test.cbp -out makefile (单独)

工程make file:

generate makefile for CodeBlocks core:
$ cbp2mak -C cb/src CodeBlocks.cbp
generate makefile for CodeBlocks contrib:
$ cbp2mak -C cb/src ContribPlugins.workspace

build:
$ make -C cb/src -f CodeBlocks.cbp.mak
$ make -C cb/src -f ContribPlugins.workspace.mak

如果需要更改编译,需要编译的,方法如下:

首先下载cbp2make,下载的包后缀名是.tar.gz。Linux里双击该下载文件,解压缩。解压缩之后里面的有cbp2make.cbp,在codeblock中打开它,然后编译build。

Linux环境下的马克file

1,生成默认配置:C:\Users\gchen\.cbp2make\cbp2make.cfg

需要手动生成C:\Users\gchen\.cbp2make目录,win32 无法生成,需要Linux 命令生成(目前不知道怎么配置该路径)

cbp2make  --config  (默认目录)

cbp2make --local --config      (cbp2make.cfg 在当前目录)

2,配置cbp toolchain 的“testcompiler” config

<Project>
          ***************
        <Option compiler="testcompiler" />
        <Build>
            <Target title="Release">
                *************************
                <Option compiler="testcompiler" />
                <Option createDefFile="1" />

配置增加testcompiler,

cbp2make --local --config toolchain --add -unix -chain testcompiler

cbp2make --local --config tool --add -unix -chain testcompiler -tool tool (参数太多,建议复制一个默认的进行配置)

<toolchain platform="Unix" alias="testcompiler">
            <option generic_switch="-" />
            <option define_switch="-D" />
            <option include_dir_switch="-I" />
            <option library_dir_switch="-L" />
            <option link_library_switch="-l" />
            <tool type="compiler" alias="mipsel-linux-gcc">
                <option description="GNU C Compiler" />
                <option program="mipsel-linux-gcc" />
                <option make_variable="CC" />
                <option command_template="$compiler $options $includes -c $file -o $object" />
                <option source_extensions="c cc" />
                <option target_extension="o" />
                <option generic_switch="-" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option include_dir_switch="-I" />
                <option define_switch="-D" />
            </tool>
            <tool type="compiler" alias="mipsel-linux-g++">
                <option description="GNU C++ Compiler" />
                <option program="mipsel-linux-g++" />

2,自动生成makefile

cbp2make -in test.cbp -unix  -cfg cbp2make.cfg -out testMakefile(单个cbp)

cbp2make.exe -in test.workspace -unix -cfg cbp2make.cfg -out test/Makefile(多个cbp工程)


 

猜你喜欢

转载自blog.csdn.net/chengf223/article/details/85046127
CBP
今日推荐