Generate VC++ .aps file in build directory and not source directory - visual-c++

I am building a VC++ project in Visual Studio 9.0 with CMake. The project is built out-of-source. The project has a GUI component and when the resource file (.rc) is compiled it creates a binary version of the file (.aps).
However, the .aps file is being created in the source directory adjacent to the .rc file and not in the build directory.
How can I have the binary .aps file generated in the build directory?
I want to keep my build completely out-of-source to avoid polluting it and inadvertently committing it. I would rather not resort to adding this one file to an ignore file in my version control and have it built in the build directory.

Related

CMake cannot find source file, but file was not specified in CMakeLists.txt, in TFS build definition

I'm porting a large project to linux. I wrote all the CMakeLists.txt files, and everything compiles in my machine.
For whatever reason we still use TFS. The old version, not git with TFS.
I'm working in my own branch, but that branch has no build definition for linux. Before I check in, I want to be sure that everything compiles on the server too. So I need to merge my branch to another one, and submit that shelve set to the build job.
In my machine everything compiles fine. But when I run the build in the server, applying a shelveset to the branch that has a linux build definition, I get an error from the build, saying
CMake Error at
/myproject/subproject/CMakeLists.txt:165 (add_library):
Cannot find source file:
/myproject/subproject/IInternalTransactionManager.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
Indeed, that file is not there. Cmake complains about the file not being in the sources directory, which is true, because it is in another directory. But the fact is that I'm not asking for it either! My CMakeFiles.txt file does not include that file. That file is a header which is used in a few files, contains only classes definitions (no implementations), and the directory in which myHeader.h resides has been defined in include_directories. My CMakeLists.txt looks something like this:
set(PROJECT_NAME project)
project(${PROJECT_NAME})
include_directories(
../_include
)
set(source_files
main.cpp
file_that_includes_myHeader.cpp
)
add_library( ${PROJECT_NAME} STATIC ${source_files} )
and my file structure is something like:
/myproject/subproject/main.cpp
/myproject/subproject/file_that_includes_myHeader.cpp
/myproject/subproject/CMakeLists.txt
/myproject/_include/myHeader.h
So, why should cmake complaining about a missing file, if such file is not included in the CMakeLists.txt file? And why would this happen only the build in TFS? My guess is that there is something wrong when applying the shelvetset and is not related to my code, but I cannot prove it.
I compared the code after the shelveset is applyied, and still in that version the CMakeLists.txt does not mention myHeader.h
Or, there is some rule about including headers in CMakeLists.txt files which I'm not aware of.
So, after expending too much debuging I contacted the team in charge of the build process. And as it turns out, the building process in the TFS building definition was definetly NOT what I expected. And of course this was not documented.
Our development is mostly in windows (by far). The linux build has a step before building: a script is launched which parses each Visual Studio project file, gets the included files, and substitutes the source files in the CMakeLists.txt files with the one parsed from VS. Right or wrong, is just the way it is.
I could build the linux build in my local machine because everything was done correctly. The windows build worked too, even though the VS project files sometimes included some files which were not in the source directory but in some header only directory, and somehow that compiled. I guess because the directory was defined in the include directory. But When the CMakeLists.txt files were updated, cmake complained (rightly so) about not finding the files.
So, if anybody experiences similar issues, contact your devops team or whoever is in charge of such things.

Building SQLite DLL with VS2015

I'm trying to build SQLite as a DLL from sources. In the the "How to" section of the website, they give a simple command line to build it :
cl sqlite3.c -link -dll -out:sqlite3.dll
When I try this command, I get the DLL but not the ".lib" file. With the DLL only I cannot use SQLite inside another dev project. Without the .lib file, there are some symbols missing.
here are some notes i made a while ago on creating a sqlite3.lib file using the contents of sqlitedll-X_X_X.zip (and some other files). This approach might differ from your intended approach - but it may get your project started - I hope it helps.
create \tmp folder in your project directory
find the following 3 files (on the web) and then copy them into the \tmp directory: lib.exe, link.exe, mspdb80.dll
from the latest sqlitedll-X_X_X.zip file (i used: http://www.sqlite.org/sqlitedll-3_7_3.zip) copy sqlite3.def and sqlite3.dll to \tmp directory
open command line (terminal) and navigate to \tmp directory
create .LIB file by typing:
LIB /DEF:sqlite3.def /MACHINE:X86
copy the newly created sqlite3.lib file to your project directory
make sure that the following files are in the project directory:
sqlite3.h (from: http://www.sqlite.org/sqlite-amalgamation-X_X_X.zip)
sqlite3.dll (from: http://www.sqlite.org/sqlitedll-X_X_X.zip)
also
add the sqlite3.h file to the project
make sure that the linker can see sqlite3.lib
For those trying to do this with CMake, and assuming that you are building from amalgamation sources, to produce the .lib file when building a shared variant on Windows you need to add a compile definition SQLITE_API=__declspec(dllexport), for example:
project("SQLite3"
VERSION 3.39.1
DESCRIPTION "Small, fast, self-contained, high-reliability, full-featured SQL database engine"
LANGUAGES C
)
# ...
add_library(${PROJECT_NAME})
# ...
if(BUILD_SHARED_LIBS)
if(WIN32)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
"SQLITE_API=__declspec(dllexport)"
)
else() # haven't tested that
target_compile_definitions(${PROJECT_NAME}
PRIVATE
"SQLITE_API=__attribute__((visibility(\"default\")))"
)
endif()
endif()
# ...

Specify .gradle taskArtifacts directory

Using Android Studio:
To keep my source directories small, for google drive backup etc, I found how to specify a global gradle build directory outside my project directories here:
Gradle global build directory
Is it possible also to put the rather large .gradle/.../taskArtifacts directory outside the project directory.
Set --gradle-cache-dir when invoking gradle from the command line.

trouble creating an axis 2 .aar file: xml/services not found error

I am trying to create an aar file using OSX 10.7.5 (as a part of this tutorial). To generate the .aar, I navigate to the directory holding my webservice in my eclipse workspace and type
jar cvf FirstWebService.aar ./*
This is the command that Apache says to use to generate the aar in their Code Listing 9 from the apache axis 2 documentation.
The command creates an.aar -- but something is wrong with the process that I am using to create the .aar because when I go to load the .aar file into tomcat's /webapps I get an .xml/services not found error.
I am not sure what to do to fix this error. If I search my computer's file system for the services.xml file, I can find it in /path to eclipse workspace/workspace/MyFirstWebService/WebContent/WEB-INF/services/FirstWebService/META-INF
but I am not sure if this file is supposed to be rolled in to the .aar file somehow or if I can just manually plunk this file somewhere into the apache directory structure to get the thing to run.
Note: I do not think I am manually unzipping or unpacking the aar like in this question. Axis2 web service error: services.xml not found I am just running the command listed above from the apache documentation.
Here is the .aar file
note I am using all of the same versions of the software as in the tutorial -- but I am using OSX 10.7.5 where they use windows in the tutorial. Accordingly, I have changed the make-aar command for windows shown in the tutorial (jar cvf FirstWebService.aar com META-INF) into the one shown above. If I just try to run the command from the tutorial jar cvf FirstWebService.aar com META-INF I get the same xml/services not found error. It gives this output in the terminal...
com: no such file or directory
META-INF: no such file or directory
added manifest
I found the issue. When you type the command to create the aar file you have to be in the directory .../EclipseWorkspace/EclipseProjectName/WebContent/WEB-INF/services. This directory contains /META-INF/services.xml. The process that makes the .aar file must be looking in this folder.

Including DLL's In VC++(VS2010) Project Output

Disclaimer: Am a C# developer trying to understand a few C++ fundamentals
Have created a command line project which has the .lib of a DLL file linked under Linker > Input > Additional dependencies, and also has the location of the header files specified under C/C++ > General > Additional Include Directories. Ran a build and all compiled okay, with the .exe being built in the Debug/Release dir.
Problem is I also expected the .dll file the project depends on to be there (just like when you add a reference in a .Net project) - but it isn't. When launching the .exe it complains that it can't find the DLL. Fair enough, but why didn't the VC++ put the DLL there if it knows it's required?
And is there a "best practice" to ensuring the dependent DLL files are in the output dir, other than manually copying them there? I have a project that will require use of some third-party libraries, and I was hoping the IDE would help me manage them...
Big thanks for any guidance given!
If you create solution which contains exe and dll, all output files are created in $(SolutionDir) Debug or Release subdirectories, and exe runs successfully. Otherwise, you have one of the following options:
Copy Dll in Post-build step to directory where it is available for loading (usually .exe directory)
Add Dll directory to PATH.

Resources