Is there a straightforward way to create a new C++ project that clones the settings of an existing project? When developing C++, I like to write many small tests and examples, but if my code depends on external libraries, as they often do, I have to set the includes, libraries, compiler settings, etc., up from scratch each time. Is there some sort of template mechanism?
I know about Export/Import of C/C++ Project Settings. However, this only appears to pick up include paths and #defines for the C++ compilation. The fact that it doesn't export the full slate of settings (compiler options, warning settings, linker options, libraries, library paths, ...) really limit its usefulness.
Also, you have to do it separately for each run configuration, though this is a minor inconvenience.
What I usually resort to is copying one test project and manually editing the .project and .cproject files and then nuking and replacing the files. But this seems like an error-prone hack.
Are there other approaches? Do I need to switch to a separate build system and generate the eclipse projects externally in order to have what seems like pretty basic functionality?
UPDATE
I've tried creating a Plug-in Project but the instructions leave more than a little to be desired if you haven't done this before. I definitely want to figure out how to do this.
I copied and modified the sample template in some very simple ways, just to get started, but the "How to register a project template with CDT" instructions lost me from the start: "1. Create an empty plug-in project from the Eclipse workbench without the source folders." I assume this requires installing the PDE, which I did, but then I'm lost. I tried "File / New / Plug-in Project", deselected "Create a Java Project" (I assumed this was what was meant by "Empty"). This creates a project that still has a lot of stuff in it. I then created the subdirectories as described in step 2, but can't figure out how to get these to show up in Eclipse, and as a result I can't browse to the template XML file in step 11. Also, in steps 9/10, I don't get a template 'literally named "(template)"' - instead it creates one with the full name of my template project.
CDT has a complete Templating mechanism for creating new projects.
Basically, you extend the org.eclipse.cdt.core.templates extension point and that points to a template.xml file that has a bunch of commands you can do. You don't need to write any Java code for this, but you do need to create a Plug-in project.
The kinds of things you can do:
Create folders
Add files to a project
Set Managed Build settings (this is the one most relevant because you can set compiler options and add libraries, etc)
Add extra pages to the New Project Wizard to prompt user for extra information
The Eclipse documentation has a special section giving a run down on how to do it here: http://help.eclipse.org/mars/topic/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/index.html
The Hello World project that comes with CDT has its template here: https://github.com/eclipse/cdt/blob/master/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/HelloWorldCAnsiProject/template.xml
A little note, if you initially create your plug-in to install as a non-packed plug-in, you can edit it in place, adding new templates or editing the one you have already done.
Going further, you can share this template plug-in project with your team and all benefit from having this feature.
Step-by-step
The step by step process to do this (tested on Eclipse Mars.1 with CDT and Plug-in development tools installed plus an XML editor for editing the template.xml)
Create a Plug-in project (File | New | Other... | Plug-in project)
Fill in a project name and press Next / Finish until done
You should now have files on your disk that looks like this in the project you created:
$ find . -type f
./.classpath
./bin/com/example/cdt/templates/Activator.class
./.project
./src/com/example/cdt/templates/Activator.java
./.settings/org.eclipse.jdt.core.prefs
./META-INF/MANIFEST.MF
./build.properties
Open the plug-in.xml and do the following
Select the Extensions tab
Press Add
Type the extension point org.eclipse.cdt.core.templates
Un-check the Show only extension points [...] checkbox
Select the org.eclipse.cdt.core.templates from the list
Press Finish
Say Yes to adding dependency
Add the required settings to the plugin.xml as shown in the screenshot and given in the plugin.xml code sample after.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.cdt.core.templates">
<template
filterPattern=".*gcc"
id="com.example.cdt.templates.template1"
location="template/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>
</plugin>
Now create the template.xml in the location specified in the plugin.xml (template/template.xml) with these contents:
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Stack Overflow"
revision="1.0" author="Jonah Graham" id="EXE" label="Stack Overflow Example"
description="An example for https://stackoverflow.com/questions/33092746/creating-a-new-c-project-in-eclipse-cdt-with-the-same-settings-as-another-proj."
help="help.html">
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
<simple name="name" value="$(projectName)" />
<simple name="artifactExtension" value="exe" />
<simple name="isCProject" value="true" />
</process>
<process type="org.eclipse.cdt.core.CreateSourceFolder">
<simple name="projectName" value="$(projectName)" />
<simple name="path" value="src" />
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)" />
<complex-array name="files">
<element>
<simple name="source" value="src/basename.c" />
<simple name="target" value="src/$(projectName).c" />
<simple name="replaceable" value="true" />
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.ui.OpenFiles">
<simple name="projectName" value="$(projectName)" />
<complex-array name="files">
<element>
<simple name="target" value="src/$(projectName).c" />
</element>
</complex-array>
</process>
<!-- Set -Wall by checking the checkbox in the settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.warnings\.extrawarn.*" />
<simple name="value" value="true" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
<!-- Set -Werror by adding textual build settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.misc\.other.*" />
<simple name="value" value="-c -fmessage-length=0 -Werror" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
<!-- Add -lmylibname to libraries to link -->
<process
type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*link\.option\.libs.*" />
<simple-array name="values">
<element value="mylibname" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
</template>
Add the source file listed in the template with any content you want in template/src/basename.c
You should now have a directory structure that looks like this:
$ find . -type f
./.classpath
./template/src/basename.c
./template/template.xml
./bin/com/example/cdt/templates/Activator.class
./.project
./src/com/example/cdt/templates/Activator.java
./.settings/org.eclipse.jdt.core.prefs
./META-INF/MANIFEST.MF
./plugin.xml
./build.properties
Launch the Eclipse Application to test (Run menu | Run As | Eclipse Application). You can also right-click on the project and choose Run As | Eclipse Application.
In the newly running Eclipse, start a new project wizard and select your new C project type:
Running a build shows the new settings (the error is expected as I don't actually have a library called mylibname):
Building file: ../src/hello2.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -Werror -MMD -MP -MF"src/hello2.d" -MT"src/hello2.o" -o "src/hello2.o" "../src/hello2.c"
Finished building: ../src/hello2.c
Building target: hello2
Invoking: GCC C Linker
gcc -o "hello2" ./src/hello2.o -lmylibname
/usr/bin/ld: cannot find -lmylibname
collect2: error: ld returned 1 exit status
make: *** [hello2] Error 1
The tricky part?
You may need to examine the .cproject file from your base project to determine the magic strings that go in the id fields. For example, in my .cproject for -Wextra I can see this:
<option id="gnu.c.compiler.option.warnings.extrawarn.176373860" name="Extra warnings (-Wextra)" superClass="gnu.c.compiler.option.warnings.extrawarn" value="true" valueType="boolean"/>
That translates to this command in the template.xml:
<!-- Set -Wall by checking the checkbox in the settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.warnings\.extrawarn.*" />
<simple name="value" value="true" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
The id goes from gnu.c.compiler.option.warnings.extrawarn.176373860 to regexp .*compiler\.option\.warnings\.extrawarn.*. The beginning is .* so that this applies to C and C++ compiler options as the C++ id would have started with gnu.cc.compiler[...] and I get rid of the end with .* because the number and suffix is not known to you in the template.xml
Next steps
When you are done, see Launching Eclipse plug in template for how to export the plug-in into your running Eclipse.
I like Jonah's answer, it is very informative. Lately I've been using Ease and Py4J to automatically re-recreate a large number of projects with the cdt settings I need. I just wanted to mention another possible way of doing this type of automation.
Create your template project , store it in some workspace, doesn't necessarily need to be in the same workspace as the one you are importing to
File->Import->Gneral->Existing Projects-> Select your template project directory
Select "Copy projects into workspace" option
Finish
Optionally rename the project, this way when you import the project again as a new project, there will be no naming conflicts
Related
I am updating existing Workitem Template to have a new field that should be "MultiLineControl". Below is what all i did.
1) Changed WorkItem template as
<FIELD name="IssueOwner" refname="test.IssueOwner" type="String" reportable="dimension" >
<HELPTEXT>Issue Owner</HELPTEXT>
<SUGGESTEDVALUES expanditems="true">
<LISTITEM value="test1" />
<LISTITEM value="test2" />
<LISTITEM value="test3" />
</SUGGESTEDVALUES>
</FIELD>
<Control FieldName="test.IssueOwner" Type="FieldControl" PreferredType="MultiValueControl" Label="Issue Owner" LabelPosition="Left" />
2) Installed extension First i tried from below location under "Install control on Web Access"
https://devblogs.microsoft.com/devops/multivaluelist-control-in-tfs-work-item-tracking/
But then the extension is deprecated for TFS 2017
So then I installed
https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-extensions-multivalue-control
But still my field is Simple dropdown. Not sure what i am missing. Can someone plz help
Update 1) I also tried stuff from Entension but it doesn't effect any change. in my Work Item export I have two section in FORM. Layout and WebLayout. The link talks abt changing WebLayout. But how to change Layout as thats what my TFS load when i use it on explorer?
Tested on TFS 2017 (Version 15.117.27414.0), everything works as expected.
Please follow below steps to do that:
Install Multivalue control extension.
Export the specific WIT with witadmin tool (you can also use the TFS Process Template Editorif you are using Visual Studio 2015 or 2017, reference this thread for details. ) :
witadmin exportwitd /collection:CollectionURL /p:Project /n:TypeName /f:FileName
Open the exported xml file with text editor and add an Extensiontag to make the control available to the work item form.
<Extensions>
<Extension Id="ms-devlabs.vsts-extensions-multivalue-control" />
</Extensions>
Add your customized field:
<FIELD name="IssueOwner" refname="test.IssueOwner" type="String" reportable="dimension" >
<HELPTEXT>Issue Owner</HELPTEXT>
<SUGGESTEDVALUES expanditems="true">
<LISTITEM value="test1" />
<LISTITEM value="test2" />
<LISTITEM value="test3" />
</SUGGESTEDVALUES>
</FIELD>
Add the ControlContribution tag for your Multivalue control. This
example adds it to the "Status" group.
<Group Label="Status">
<Control Label="Reason" Type="FieldControl" FieldName="System.Reason" />
<ControlContribution Label="IssueOwner" Id="ms-devlabs.vsts-extensions-multivalue-control.multivalue-form-control">
<Inputs>
<Input Id="FieldName" Value="test.IssueOwner" />
</Inputs>
</ControlContribution>
</Group>
Import the modified xml file to your project:
witadmin importwitd /collection:CollectionURL /p:Project /n:TypeName /f:FileName
Check the result:
Is there a straightforward way to create a new C++ project that clones the settings of an existing project? When developing C++, I like to write many small tests and examples, but if my code depends on external libraries, as they often do, I have to set the includes, libraries, compiler settings, etc., up from scratch each time. Is there some sort of template mechanism?
I know about Export/Import of C/C++ Project Settings. However, this only appears to pick up include paths and #defines for the C++ compilation. The fact that it doesn't export the full slate of settings (compiler options, warning settings, linker options, libraries, library paths, ...) really limit its usefulness.
Also, you have to do it separately for each run configuration, though this is a minor inconvenience.
What I usually resort to is copying one test project and manually editing the .project and .cproject files and then nuking and replacing the files. But this seems like an error-prone hack.
Are there other approaches? Do I need to switch to a separate build system and generate the eclipse projects externally in order to have what seems like pretty basic functionality?
UPDATE
I've tried creating a Plug-in Project but the instructions leave more than a little to be desired if you haven't done this before. I definitely want to figure out how to do this.
I copied and modified the sample template in some very simple ways, just to get started, but the "How to register a project template with CDT" instructions lost me from the start: "1. Create an empty plug-in project from the Eclipse workbench without the source folders." I assume this requires installing the PDE, which I did, but then I'm lost. I tried "File / New / Plug-in Project", deselected "Create a Java Project" (I assumed this was what was meant by "Empty"). This creates a project that still has a lot of stuff in it. I then created the subdirectories as described in step 2, but can't figure out how to get these to show up in Eclipse, and as a result I can't browse to the template XML file in step 11. Also, in steps 9/10, I don't get a template 'literally named "(template)"' - instead it creates one with the full name of my template project.
CDT has a complete Templating mechanism for creating new projects.
Basically, you extend the org.eclipse.cdt.core.templates extension point and that points to a template.xml file that has a bunch of commands you can do. You don't need to write any Java code for this, but you do need to create a Plug-in project.
The kinds of things you can do:
Create folders
Add files to a project
Set Managed Build settings (this is the one most relevant because you can set compiler options and add libraries, etc)
Add extra pages to the New Project Wizard to prompt user for extra information
The Eclipse documentation has a special section giving a run down on how to do it here: http://help.eclipse.org/mars/topic/org.eclipse.cdt.doc.isv/guide/projectTemplateEngine/index.html
The Hello World project that comes with CDT has its template here: https://github.com/eclipse/cdt/blob/master/build/org.eclipse.cdt.managedbuilder.gnu.ui/templates/projecttemplates/HelloWorldCAnsiProject/template.xml
A little note, if you initially create your plug-in to install as a non-packed plug-in, you can edit it in place, adding new templates or editing the one you have already done.
Going further, you can share this template plug-in project with your team and all benefit from having this feature.
Step-by-step
The step by step process to do this (tested on Eclipse Mars.1 with CDT and Plug-in development tools installed plus an XML editor for editing the template.xml)
Create a Plug-in project (File | New | Other... | Plug-in project)
Fill in a project name and press Next / Finish until done
You should now have files on your disk that looks like this in the project you created:
$ find . -type f
./.classpath
./bin/com/example/cdt/templates/Activator.class
./.project
./src/com/example/cdt/templates/Activator.java
./.settings/org.eclipse.jdt.core.prefs
./META-INF/MANIFEST.MF
./build.properties
Open the plug-in.xml and do the following
Select the Extensions tab
Press Add
Type the extension point org.eclipse.cdt.core.templates
Un-check the Show only extension points [...] checkbox
Select the org.eclipse.cdt.core.templates from the list
Press Finish
Say Yes to adding dependency
Add the required settings to the plugin.xml as shown in the screenshot and given in the plugin.xml code sample after.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.cdt.core.templates">
<template
filterPattern=".*gcc"
id="com.example.cdt.templates.template1"
location="template/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>
</plugin>
Now create the template.xml in the location specified in the plugin.xml (template/template.xml) with these contents:
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Stack Overflow"
revision="1.0" author="Jonah Graham" id="EXE" label="Stack Overflow Example"
description="An example for https://stackoverflow.com/questions/33092746/creating-a-new-c-project-in-eclipse-cdt-with-the-same-settings-as-another-proj."
help="help.html">
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
<simple name="name" value="$(projectName)" />
<simple name="artifactExtension" value="exe" />
<simple name="isCProject" value="true" />
</process>
<process type="org.eclipse.cdt.core.CreateSourceFolder">
<simple name="projectName" value="$(projectName)" />
<simple name="path" value="src" />
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)" />
<complex-array name="files">
<element>
<simple name="source" value="src/basename.c" />
<simple name="target" value="src/$(projectName).c" />
<simple name="replaceable" value="true" />
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.ui.OpenFiles">
<simple name="projectName" value="$(projectName)" />
<complex-array name="files">
<element>
<simple name="target" value="src/$(projectName).c" />
</element>
</complex-array>
</process>
<!-- Set -Wall by checking the checkbox in the settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.warnings\.extrawarn.*" />
<simple name="value" value="true" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
<!-- Set -Werror by adding textual build settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.misc\.other.*" />
<simple name="value" value="-c -fmessage-length=0 -Werror" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
<!-- Add -lmylibname to libraries to link -->
<process
type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*link\.option\.libs.*" />
<simple-array name="values">
<element value="mylibname" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
</template>
Add the source file listed in the template with any content you want in template/src/basename.c
You should now have a directory structure that looks like this:
$ find . -type f
./.classpath
./template/src/basename.c
./template/template.xml
./bin/com/example/cdt/templates/Activator.class
./.project
./src/com/example/cdt/templates/Activator.java
./.settings/org.eclipse.jdt.core.prefs
./META-INF/MANIFEST.MF
./plugin.xml
./build.properties
Launch the Eclipse Application to test (Run menu | Run As | Eclipse Application). You can also right-click on the project and choose Run As | Eclipse Application.
In the newly running Eclipse, start a new project wizard and select your new C project type:
Running a build shows the new settings (the error is expected as I don't actually have a library called mylibname):
Building file: ../src/hello2.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -Wextra -c -fmessage-length=0 -Werror -MMD -MP -MF"src/hello2.d" -MT"src/hello2.o" -o "src/hello2.o" "../src/hello2.c"
Finished building: ../src/hello2.c
Building target: hello2
Invoking: GCC C Linker
gcc -o "hello2" ./src/hello2.o -lmylibname
/usr/bin/ld: cannot find -lmylibname
collect2: error: ld returned 1 exit status
make: *** [hello2] Error 1
The tricky part?
You may need to examine the .cproject file from your base project to determine the magic strings that go in the id fields. For example, in my .cproject for -Wextra I can see this:
<option id="gnu.c.compiler.option.warnings.extrawarn.176373860" name="Extra warnings (-Wextra)" superClass="gnu.c.compiler.option.warnings.extrawarn" value="true" valueType="boolean"/>
That translates to this command in the template.xml:
<!-- Set -Wall by checking the checkbox in the settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.warnings\.extrawarn.*" />
<simple name="value" value="true" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
The id goes from gnu.c.compiler.option.warnings.extrawarn.176373860 to regexp .*compiler\.option\.warnings\.extrawarn.*. The beginning is .* so that this applies to C and C++ compiler options as the C++ id would have started with gnu.cc.compiler[...] and I get rid of the end with .* because the number and suffix is not known to you in the template.xml
Next steps
When you are done, see Launching Eclipse plug in template for how to export the plug-in into your running Eclipse.
I like Jonah's answer, it is very informative. Lately I've been using Ease and Py4J to automatically re-recreate a large number of projects with the cdt settings I need. I just wanted to mention another possible way of doing this type of automation.
Create your template project , store it in some workspace, doesn't necessarily need to be in the same workspace as the one you are importing to
File->Import->Gneral->Existing Projects-> Select your template project directory
Select "Copy projects into workspace" option
Finish
Optionally rename the project, this way when you import the project again as a new project, there will be no naming conflicts
I'm writing an application that uses another library that I'm developing at the same time. This creates the problem where QtCreator will be expecting the library to never change to the point where removed headers cause building the project to fail, and new classes are reported as undefined even if they compile into the library just fine. What is with this? It's like it's not actually looking at the library. Is there any way I can force it to let me use the newer additions to my library?
Here is the Application .pro
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = BlockEditor
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
openglqt.cpp \
tilelabel.cpp
HEADERS += mainwindow.h \
openglqt.h \
tilelabel.h
FORMS += mainwindow.ui
LIBS += -L/usr/local/lib -lGLU -lGLEW
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN/libs
QMAKE_RPATH=
release {
LIBS += -L$$PWD/../drEngine/bin/Release/ -ldrEngine
}
debug {
LIBS += -L$$PWD/../drEngine/bin/Debug/ -ldrEngine
}
INCLUDEPATH += $$PWD/../drEngine
DEPENDPATH += $$PWD/../drEngine
QMAKE_CXXFLAGS += -std=c++11
The Library is developed over in Code::Blocks
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Dark Realms Engine" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/drEngine" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/drEngine" imp_lib="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).a" def_file="$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_BASENAME).def" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-O3" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-Wall" />
</Compiler>
<Unit filename="Block.cpp" />
<Unit filename="Block.hpp" />
<Unit filename="BlockList.cpp" />
<Unit filename="BlockList.hpp" />
<Unit filename="Camera2D.cpp" />
<Unit filename="Camera2D.hpp" />
<Unit filename="Camera3D.cpp" />
<Unit filename="Camera3D.hpp" />
<Unit filename="Entity.hpp" />
<Unit filename="Includes.hpp" />
<Unit filename="RenderInfo.cpp" />
<Unit filename="RenderInfo.hpp" />
<Unit filename="Renderer.cpp" />
<Unit filename="Renderer.hpp" />
<Unit filename="Scene.cpp" />
<Unit filename="Scene.hpp" />
<Unit filename="TextureAtlas.cpp" />
<Unit filename="TextureAtlas.hpp" />
<Unit filename="dr.hpp" />
<Unit filename="isoMap.cpp" />
<Unit filename="isoMap.hpp" />
<Extensions>
<envvars />
<code_completion />
<lib_finder disable_auto="1" />
<debugger />
<DoxyBlocks>
<comment_style block="0" line="0" />
<doxyfile_project />
<doxyfile_build />
<doxyfile_warnings />
<doxyfile_output />
<doxyfile_dot />
<general />
</DoxyBlocks>
</Extensions>
</Project>
</CodeBlocks_project_file>
I know the pains of developing library and app using it.
Are you sure that you recompile both on updates? - normally qt creator updates only current project. If you go to 'Project' screen and 'Dependencies' tab, you can tell QtCreator that one project depends on another - should be always kept in sync.
Also avoid copying of the final library to application folder if library is still under development. Best way is to symlink library from it's original position to your application directory. Even newer versions of windows offer symlinks these days (never tried it myself though), so you should have no trouble to do it this way.
If this doesn't help, mor edetailed analysys is required, so please post your qmake .pro files for both application and library.
EDIT:
BTW "QtCreator will be expecting the library to never change" - Qt Creator doesn't care about your library at all - this is handled at the level of qmake (which doesn't care about it's contents as well, it only knows what is written in .pro file), and later linker.
Easiest to try would be to remove EVERYTHING not user created from both projects - so sources and your .pro files and whatever equivalent Code::Block uses are the only thing to stay. Then compile both as if you just written them now. If it still doesn't work, it means that it's not QtCreator (or qmake, or linker) problem but problem with your source.
If this doesn't work, then I suspect you have some stale version of your library somewhere in your build environment. It seems that you use linux and ld as compiler (right?). Try using --trace option to see which version of your library is being used. Just add
LIBS += -Xlinker --trace
To your .pro file, and see compiler output.
I am working on a dotnet 2008, Nunit 2.6,Nant0.91 application.
I am using log4net for my logging purposes.
When trying to run test cases through Nunit, a log file is generated, but when I try to run it through Nant, I am unable to run my test case.
I am pasting the complete information present in my build file:
<?xml version="1.0" encoding="utf-8"?>
<project name="w2" default="run" basedir=".">
<!--Here we are building DLL -->
<target name="build">
<mkdir dir="Libraries" />
<mkdir dir="Output"/>
<csc target="library" output="Libraries/${project::get-
name()}.dll">
<sources>
<include name="C:\\Users\\rm99699\\Documents\\Visual Studio
2008\\Projects\\w2\\w2\\*.cs" />
<include name="C:\\Users\\rm99699\\Documents\\Visual Studio 2008\
\Projects\\w2\\w2\\app.config.xml"/>
</sources>
<references basedir="Libraries">
<include name="${nant::scan-probing-
paths('nunit.framework.dll')}" />
<include name="${nant::scan-probing-paths('log4net.dll')}" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.Support.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\ThoughtWorks.Selenium.Core.dll" />
</references>
</csc>
</target>
<!--Here we are running testcases -->
<target name="run" depends="build">
<nunit2 failonerror="false" >
<formatter type="Xml" usefile="true" extension=".xml"
outputdir="Output"/>
<test assemblyname="C:\\Users\\rm99699\\Documents\\Visual Studio 2008\
\Projects\\w2\\w2\\Libraries\\w2.dll" appconfig="C:\\Users\\rm99699\
\Documents\\Visual Studio 2008\\Projects\\w2\\w2\\app.config">
<references basedir="Libraries">
<include name="${nant::scan-probing-
paths('nunit.framework.dll')}" />
<include name="D:\selenium-dotnet-2.8.0\net35\WebDriver.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\WebDriver.Support.dll" />
<include name="D:\selenium-
dotnet-2.8.0\net35\ThoughtWorks.Selenium.Core.dll" />
<include name ="D:\nant-0.91-bin\nant-0.91\bin\lib\common
\2.0\log4net.dll" />
<!-- <include name="${nant::scan-probing-paths('log4net.dll')}" />-->
</references>
</test>
</nunit2>
</target>
</project>
Based on my build file, are there any visible errors that are preventing me from running my test case?
What is the console output? NAnt includes log4net in it's core, and I've seen cases where it causes problems when one's code uses a different version of log4net than NAnt does. You could try using an <exec> task to run the unit tests -- especially since NAnt's <nunit2> task uses a heinously outdated NUnit 2.2.
In Eclipse CDT Indigo, there is a new feature that allows you to add new C/C++ template projects to the new project wizard. I've figured out how to do this successfully up to a point. I can create a basic project that just depends on simple source files but now I'd like to create a CPPUnit project to which I'd like to automatically add the CPPUnit library. For the life of me, I can't figure out how to achieve this end. Does anyone know how?
Sorry I am late, but I just had the very same question for the very same problem. I have figured out a solution. It works for me, but I am well aware that it is probably not as general as hoped for. In your template.xml, you may want to add the following process:
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
<simple name="projectName" value= "$(projectName)"/>
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.cpp.link.option.libs" />
<simple-array name="values">
<element value="dl" />
<element value="cppunit" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
The crucial part is to know where to put the two libraries dl and cppunit. The key gnu.cpp.link.option.libs is the correct one for the GNU compiler tool chain which is active on most Linux computers.
I have extracted the key name from the Eclipse plugin org.eclipse.cdt.managedbuilder.gnu.ui_XXXXXXX. You can find it at Eclipse's plugins folder. If you need the key for another toolset, I recommend opening the plugin.xml file. Here, you should search for the attribute valueType="libs". The corresponding id is the key you need to manipulate in your process file.
If you also need to manipulate the library search path, search for valueType="libPaths". This will lead you to the key gnu.cpp.link.option.paths. You can add additional entries to the list with a process similar to the one shown above.
It is AMAZING how hard this stuff is to find. In addition to plugin.xml browsing, all the templates provide efficient ramp up on implementing these options:
Source Reference
manual download: Eclipse CDT Source Download
Templates to Browse
plugins/org.eclipse.cdt.managedbuilder.gnu.ui_X.X.X.xxxxx.jar/templates/projecttemplates/
and then in each proj dir (e.g. 'HeloWorldCAnsiProject') locate template.xml
GNU C Options to Browse
plugins/org.eclipse.cdt.managedbuilder.gnu.ui_X.X.X.xxxxx.jar/plugin.xml
Example Implementation By Reverse-Engineering
Goal - set 'Cross GCC Compiler' -> Optimization -> 'Other optimization flags'
create a dummy C project with no customization
open properties. set the target field manually. I set 'Other optimization flags' to 'COME_FIND_ME'
open the .cproject file in an editor. search for COME_FIND_ME. here is what I found:
<option id="gnu.c.compiler.option.optimization.flags.1380831355" superClass="gnu.c.compiler.option.optimization.flags" value="COME_FIND_ME" valueType="string"/>
it is then of type 'string' and 'id' gnu.c.compiler.option.optimization.flags.
Search in the plugin.xml listed above for 'gnu.c.compiler.option.optimization.flags'. Here's what i found (on line 1120):
<option
name="%Option.Posix.Optimize.Flags"
category="gnu.c.compiler.category.optimization"
id="gnu.c.compiler.option.optimization.flags"
valueType="string">
</option>
get outta this example project, and go back to your template.xml you want to add this to. we want to append here to default value, so lets do that. add:
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.c.compiler.option.optimization.flags" />
<simple name="value" value="-Omg_eclipse" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
and that's it.
Useful Links
Help - Eclipse Platform - How to register a project template with CDT
Help - Eclipse Platform - Example template
Notes
Here are where the MBS append/set functions live:
org.eclipse.cdt.managedbuilder.core.source_X.X.X.xxxxx.jar/org/eclipse/cdt/managedbuilder/templateengine/processes
Full Template File Example
finally, here's a code snippet that may save you hours of scouring the internet. this template.xml creates a new project by copying over main.c, and setting three build options.
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="stack_overflow" revision="1.0" author="Justin Reina"
id="EXE" label="My C Project" description="set some stuff."help="help.html">
<process type="org.eclipse.cdt.core.CreateSourceFolder">
<simple name="projectName" value="$(projectName)"/>
<simple name="path" value="bsp"/>
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="source" value = "main.c"/>
<simple name="target" value = "main.c"/>
<simple name="replaceable" value = "true" />
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues">
<simple name="projectName" value= "$(projectName)"/>
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.c.link.option.libs" />
<simple-array name="values">
<element value="corestuff" />
<element value="utilstuff" />
</simple-array>
<simple name="path" value="" />
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.c.compiler.option.optimization.flags" />
<simple name="value" value="-Omg_eclipse" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
<process type="org.eclipse.cdt.managedbuilder.core.SetMBSBooleanOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value="gnu.c.link.option.nostdlibs" />
<simple name="value" value="true" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
</template>
To the Eclipse Foundation; next time can I just pay you a half-day's salary for you to give me this information???