Set project configurations using Visual Studios custom template wizard - c++

I am trying to create a C++ project template using the custom project wizard. I just need a simple template for an empty C++ CLI application that uses an external library, i.e I need the wizard to set the following settings found under Project -> Properties:
Configaration Setting -> VC++ Directories -> Executable Directories
Configaration Setting -> VC++ Directories -> Include Directories
Configaration Setting -> VC++ Directories -> Library Directories
Configaration Setting -> Linker -> Input -> Additional Dependencies
It seems I need to modify default.js more specifically the function AddConfig which contains:
function AddConfig(proj, strProjectName)
{
var config = proj.Object.Configurations('Debug');
var CLTool = config.Tools('VCCLCompilerTool');
// TODO: Add compiler settings
var LinkTool = config.Tools('VCLinkerTool');
// TODO: Add linker settings
}
I need help in setting the project settings here.

Related

vcxproj additional include path that are not shown in the project properties

I changed the path of my VS2017 project. Despite the fact that I updated every additional or include path under my project properties, I noticed that inside the *.vcxproj file are exist some additional include directories <AdditionalIncludeDirectories> from my previous project path. These additional paths are not shown inside the properties manager.
For example additionalIncludePath inside vcxproj below, it belongs to previous project's path.
<ResourceCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;</PreprocessorDefinitions>
<AdditionalIncludeDirectories>D:\Software\hor_earlyversions\revision-1\source\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
I found also <AdditionalIncludeDirectories> under <Midl> tags.
So my questions are :
a) why I can not see them under project properties
b) do I have to delete them manually ?

Separate dll from other output files in c++ projects

I have a few dll projects in a solution (some depending on each other)
Project1 -> Properties -> Linker -> Input -> Additional Dependencies -> Project2.lib
Project1 -> Properties -> Linker -> General -> Additional Library Directories -> $(OutDir)
All is working fine.
Projects are Win7Debug Win32, Win7Debug x64..... and a Win32 project with only Debug and Release configurations.
I would like to have all dll's for Win32 placed in one folder and the x64 ones in another folder. So I added the x64 configuration for the Win32 project, and changed
Project1 -> Properties -> Linker -> General -> Output File -> $(SolutionDir)/i386/$(TargetName)/$(TargetExt)
(for Win32 - similar change for x64)
all seemed fine - and I only received dlls in the i386 folder... until I had to rebuild and got
Warning 23 warning MSB8012:
TargetPath(C:\Path\Win7Debug\Project1.dll) does not match the Linker's OutputFile
property value (C:\Path\i386\Project1.dll). This may cause your project to build
incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and
$(TargetExt) property values match the value specified in %(Link.OutputFile).
This seems serious... and I don't want to have problems with missing dependencies (though everything seems to be working fine - and not just on my machine)
I changed
Project1 -> Properties -> Configuration Properties -> General -> OutputDirectory -> $(SolutionDir)/i386
(to match the linker output) but now of course I get lib and exp files in the same folder as the dll's.
Other than using post build script, is there a way to separate the output files ?
Should I just leave the settings how I had them and disregard the warning above ?
Note: I am not trying to separate the Platform/configuration output files... That is done automagically using the default output directory.
What I need is, for each platform, to place only DLL files in one folder away from anything else. Redirecting Linker output (and leaving project output to standard) accomplishes that - I just am not sure if it is correct. Logically I should not have any build problems since I am giving linker all the info it needs...
The standard approach is to leave all these properties unchanged (inherit from parent). In this case linker will create DLL and LIB in $(Output) directory, which by default is $(SolutionDir)$(Configuration).
You just specify the name for x64 configuration, and all output files will be separated automatically.
The standard (and the easest) way to link import library is to add reference to corresponding project in Common Properties / References page. Nothing else is required.
If, for any reason, it is impossible, add $(SolutionDir)$(Configuration) to Configuration Properties / VC++ Directories / Library Directories and add library to be linked to Linker / Additional Dependencies. If there are many projects in your solution, you may create Property Sheet for the solution and specify Library Directories only once.

Setting gcc ( gcc-arm-embedded ) in Eclipse IDE for C/C++ Developers Mars in OS X

I am a newbie in Eclipse IDE for C/C++ .
I want to set gcc-arm-embedded in Eclipse IDE for C/C++ Developers Mars Milestone 4 (4.5.0M4), I just downloaded https://launchpad.net/gcc-arm-embedded/+download, and now I guess that I have to set PATH somewhere in Eclipse, as I am experiencing this ERRORs in 1 project
Program "arm-none-eabi-g++" not found in PATH
Program "arm-none-eabi-gcc" not found in PATH
The location of the error is in
Project Properties -> C / C++ General -> Preprocessor Include Paths, Macros, etc -> Languages (GNU C) -> [ CDT GCC Built-in Compiler Settings Cross ARM]
But I can't edit this entry: "Setting entries for this provider are supplied by the system and are not editable"
I've tried with:
export PATH=$PATH:/Users/joanot/Development/gcc-arm-none-eabi-4_9-2014q4/bin
and in
Project Properties -> Paths and Symbols -> adding the directory /Users/joanot/Development/gcc-arm-none-eabi-4_9-2014q4/bin
and
In Eclipse -> Preferences -> C / C++ -> Build -> Build Variables:
Create 1 variable named GCC_EABI, type= Directory, value= /usr/local/gcc-arm-none-eabi-4_9-2014q4/bin
In Eclipse -> Preferences -> C / C++ -> Build -> Environment:
Add -> Name = PATH , value = ${GCC_EABI}
In case someone reads this later (like I just did) this works, however the real answer is here
Essentially you need to go to Eclipse -> Preferences -> C/C++ Build -> Tools Paths
Add the path (in my case /Users/${USER}/armtools/install/bin) to the Toolchain folder

Setting up ZeroMQ in a Visual Studio '13 Project

I'm trying to get ZeroMQ to work with my C++ project. I want to do the ZeroMQ Hello World tutorial, shown below:
// Hello World server
#include <zmq.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
int main (void)
{
// Socket to talk to clients
void *context = zmq_ctx_new ();
void *responder = zmq_socket (context, ZMQ_REP);
int rc = zmq_bind (responder, "tcp://*:5555");
assert (rc == 0);
while (1) {
char buffer [10];
zmq_recv (responder, buffer, 10, 0);
printf ("Received Hello\n");
sleep (1); // Do some 'work'
zmq_send (responder, "World", 5, 0);
}
return 0;
}
However, whenever I try to compile and run it, Visual Studio says it can't find zmq.h or any of the ZeroMQ methods I am using. I already installed ZeroMQ from http://zeromq.org/distro:microsoft-windows, what else do I have to do to get it to work?
Including the headers:
Right click Project -> Properties -> C/C++ -> General
Edit 'Additional Include Directories'
Add C:\Program Files\ZeroMQ 4.0.4\include
Right click 'Header Files' -> Add -> Existing Item -> C:\Program Files\ZeroMQ 4.0.4\include\zmq.h
Adding the library dir:
Right click Project -> Properties -> Linker -> General
Edit 'Additional Library Directories'
Add C:\Program Files\ZeroMQ 4.0.4\lib\
Linking to the proper library:
Right click Project -> Properties -> General
Check "Platform Toolset", notice the version number (ex: v120)
Configuration Properties -> Linker -> Input
Edit 'Additional Dependencies'
Add appopriate toolset library (ex: libzmq-v120-mt-gd-4_0_4.lib) "-gd-" is the debug version
Ensure your app is 64-bit
Build -> Configuration Manager
Active solution platform -> New...
Select x64
Copy settings from Win32
Right click Project -> Properties -> Linker -> All Options
Edit "Output File" set to ".\x64\Debug\whatever.exe"
Include the pre-compiled dll as a resource for distribution
Right click Project -> Properties -> Build Events -> Post-Build Event
Edit "Command Line"
insert copy command
ex:
copy /Y "C:\Program Files\ZeroMQ 4.0.4\bin\libzmq-v120-mt-gd-4_0_4.dll" "$(OutDir)"
You should download and install 0MQ first.
Then you will be able to configure your Project properties to point to the right include and lib paths.

Eclipse content assist doesn't recognize std::thread, but compiles correctly

I am running Ubuntu 14.04.
Steps I took to reproduce:
Create a new C++ project (New -> C++ -> Hello World project), which I called TestStdThread
Change the code in the main file to this:
#include <thread>
#include <iostream>
int main() {
std::cout << "You have " << std::thread::hardware_concurrency() << " cores." << std::endl;
return 0;
}
Go to TestStdThread -> Properties -> C/C++ Build -> Settings -> GCC C++ Compiler, and change the Command options from g++ to g++ -std=c++11
Go to TestStdThread -> Properties -> C/C++ Build -> Settings -> GCC C++ Compiler -> Includes, add /usr/include to the Include paths (-I), and add pthread.h to the Include files (-include)
Go to TestStdThread -> Properties -> C/C++ Build -> Settings -> GCC C++ Linker -> Libraries, add pthread to the Libraries (-l), and add /usr/lib/x86_64-linux-gnu to the Library search path (-L)
TestStdThread -> Build Project
Click "Run"
There were no build errors. Eclipse told me that the project had errors and asked if I wanted to run it anyway, and when I said yes, the output was, correctly: You have 4 cores.. However, Eclipse still underlined the std::thread::hardware_concurrency part in red, and reported it (on hover) as "Function 'hardware_concurrency' could not be resolved," and std::thread didn't show up when typing std:: Ctrl+Space.
This is the bash command I used to find where my pthread files were located within /usr (/usr/share omitted as it contains lots of doc files that I'm not looking for):
llama#llama-Satellite-E55-A:/usr$ find -name "*pthread*" -not -path "./share/*"
./include/pthread.h
./include/x86_64-linux-gnu/bits/pthreadtypes.h
./lib/x86_64-linux-gnu/pkgconfig/pthread-stubs.pc
./lib/x86_64-linux-gnu/libpthread.so
./lib/x86_64-linux-gnu/libpthread_nonshared.a
./lib/x86_64-linux-gnu/libgpgme-pthread.so.11.11.0
./lib/x86_64-linux-gnu/libgpgme-pthread.so.11
./lib/x86_64-linux-gnu/libpthread.a
./lib/perl/5.18.2/bits/pthreadtypes.ph
./lib/debug/lib/x86_64-linux-gnu/libpthread-2.19.so
Go to Project -> Properties -> C/C++ General -> Preprocessor include paths, etc -> Providers -> CDT GCC Builtin Compiler Settings and append -std=c++11 to the compiler specs.
You can also do this for all projects going to Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery and append -std=c++11 to the CDT GCC Builtin Compiler Settings specs.
Make sure to reindex your project afterwards.
These instructions are for Eclipse Luna (4.4.0), for previous versions the paths are similar.