Re: Compiling with Eclipse



El mié, 11-07-2012 a las 17:58 +0200, martu escribió:
> I think he means the project-properties->C/C++ Build->Setting->Tool settings and there the includes for the C++ compiler and libraries for the linker.
> 
> As for cmake. If you want to distibute the source I would also recommend cmake as it makes it easier for others to build your project. But integrating cmake with Eclipse (so you see the errors and warnings in the source code) is kinda difficult.
> 
> I don't know any complete good tutorial for this right now so I'll write here how I do this.
> 
> First the cmake files here is a good tutorial for cmake with gtkmm:
> https://live.gnome.org/gtkmm/UsingCMake
> 
> For integrating cmake with eclipse with an out-of-source-build (recommended)
> create a new build-directory in the project root.
> An in the build directory other for the specific configurations (Release, Debug and so on)
> 

It's actually quite easy. Once you have your CMakeLists.txt set up and
running, run a:

$> cmake -G "Eclipse CDT4 - Unix Makefiles" .

This will set up an eclipse project for you. Then, in your eclipse
workspace, do an "Import -> already existing projects". This will import
all your make targets. I believe build types are not handled correctly,
but I always switch them through ccmake rather than eclipse.

> Then in eclipse right-click on the project->Make Targets->Create
> For the target name enter something like cmake_Release.
> Untick the "Same as target name" and "Use builder settings" options.
> Leave the Make target name empty. And use this build command
> "cmake -E chdir Release/ cmake ../../ -DCMAKE_BUILD_TYPE:STRING=Release"
> 
> The "cmake -E chdir Release/" will go to the Release directory and execute the following command: "cmake ../../ -DCMAKE_BUILD_TYPE:STRING=Release"
> Which executes cmake and tell it to use the Release configuration for building and use the CMakeLists.txt in the project-root directory (remember this command is executed in project-root/build/Release/)
> 
> Do this for every target (propably Release and Debug) and execute them (right-click on the project->Make Targets->build choose configuration and build)
> 
> This will only generate the build system eclipse is finally going to use, so nothing is being build now.
> 
> For the actual building part go to project-properties->C/C++ build in the Builder Settings tab untick "Generate Makefiles automatically" and "Use default build command". As the Build command use "make -C ${workspace_loc:/__PROJECT_NAME__/build/Release}" For the Release configuration or with ".../build/Debug" for the Debug configuration. As the build directory use "make -C ${workspace_loc:/__PROJECT_NAME__/build/Release}" for Release (analog for Debug configuration).
> 
> In the Behaviour Tab tick "Build (incremental build)" and set it to "all".
> Also tick the "Clean" option and set it to "clean".
> 
> For all of these setting don't forget to change the configuration which is selectable above the Tabs.
> 
> After all this you should be able use the normal "Build-button" in eclipse and have the errors and warnings directly displayed in the code. The cmake build-system (the stuff with the "Make Targets") only needs to be regenerated when you change the CMakeLists.txt files or (not sure about this) when you add/remove source files.
> 
> The Execute button in eclipse will (propably) not work as it doesn't know where the resulting binaries are. But for this just navigate in eclipse to the directory with the binaries, right-click then and choose "Run as".

Fernando.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]