Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Build output directory in Eclipse - c++

I have a program which consists of multiple projects in eclipse (working under ubuntu and the projects being in c++), these projects consist of a main executable file, and other shared objects files and static libs.

I want all these projects when built to output their files to one common binary folder, instead of their respective debug folders. This is to make linking easier with the main executable. If there are better solutions please also feel free to share.

like image 400
Shervanator Avatar asked Feb 03 '11 02:02

Shervanator


2 Answers

Try Project->Properties

Under C/C++ Build->Settings you have a tab called Build Artifact.

Under there you have Artifact name. This defaults as ${ProjName}.

Modify this to specify a relative directory path to where you actually want the final file to end up. So could be ../../lib/${ProjName}

The intermediate files (.o and .d) will still build to the sub-directory (Debug or Release) but I guess it's better off if they are there anyway and it is only the finally built library for which you want to change the build path.

If you find it inconvenient typing the relative path like this, I use Environment to create environment variables with relative paths taking me back to a "root". One of this I have is ${LIBDIR} and this is a relative path from where the project gets built. It is usually used for linking in other libraries, but can also be used as a target. Then you would set Artifact Name to ${LIBDIR}/${ProjName} which works well if you use different directories for debug and release builds.

like image 117
CashCow Avatar answered Nov 07 '22 07:11

CashCow


Go to

Project Properties -> C/C++ Build -> Settings -> (tab) GCC C++ Linker

The command line pattern is shown on the right side

${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

Put in front of ${OUTPUT}

${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX} ${ProjDirPath}/bin/${OUTPUT} ${INPUTS}

or

${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX} MyMainProject/path/bin/ ${INPUTS}

From https://www.eclipse.org/forums/index.php?t=msg&th=207500&goto=665566&#msg_665566

like image 23
kyb Avatar answered Nov 07 '22 08:11

kyb