I'm developing a code which uses Easylogging++ as the underlying logging library. Recently, I wanted to update the library since it has some high visibility / high impact bugs and I found out that the library is divided into two files (.cc and .h). This new structure needs inclusion of the .cc file in the build string alongside the main program code.
I'm using Eclipse to develop the project and generate the make files to build the project. I need to tell Eclipse (Oxygen.1) that it needs to compile the .cc file alongside the main file while building the project, however I was unable to do so. Any help is greatly appreciated.
It's easier than I thought. Eclipse's managed build is more intelligent than it seems. Adding many source files under the /src folder causes Eclipse to automatically compile all the files under that folder, unless you exclude them.
This means adding the .h to /lib folder and the .cc file to the /src folder and modifying to .cc to look for the .h file under /lib have solved the problem neatly.
To complete the compilation I had to add some flags, since the developer likes to extensively modify his library between releases.
Everything is working fine again.
Related
I want to package my executable file and other needed files into an install file (using NSIS) so that other people can install and use. There are a few file types I am uncertain of whether they are needed for installation or if it is safe to delete them.
Here is a random example of the files in the project folder as well as the Debug file automatically generated by VS:
I have already deleted the .user file as I know that is not needed, but not sure when it comes to .vcxproj, .tlog, .build.cppclean, .idp, and .pdb files. Also, do I need to keep the .obj files as well as the .cpp files?
This is my first time trying to do this, I am just messing around to seeing how it all works so thanks in advance.
You generally only need the .exe. Your app might depend on custom .dlls or the C++ run-time library in which case you would bundle the custom .dlls and/or the C++ redistributable.
Your screen shots are of a debug build and you normally want to distribute a release build instead because it is often smaller and contains more optimized code.
.obj files contain the machine code for each source file and is used by the linker when it merges all the required code into your .exe.
.pdb files contain debugging information. You should not distribute them but it is helpful to store them for yourself in case you need to debug a released version of your application.
The rest of the files in Debug and Release can also be ignored.
If your project is open source then you could include the c/c++ files and the Visual Studio project files. Or you could just upload them to Github.
In NSIS you could do something like this
InstallDir $ProgramFiles\MyApp
Page Directory
Page InstFiles
Section
SetOutPath $InstDir
File myproject\Release\MyApp.exe
File mylibrary\Release\*.dll
SectionEnd
It is a good idea to test your installer on a freshly installed Windows instance. Ideally the minimal version you require, Windows 7 etc. This should allow you to verify that you have included all the files required by your application.
I'm trying to extend an open source project with my own source files, so that the executable being produced includes my code as well. Probably it's very easy, but somehow I'm overlooking it.
The build process is using cmake and the open source project contains a well written CMakeLists.txt. Instead of adding my source files in the directories of the open source project (and possibly changing CMakeLists.txt of the open source project), I prefer to separate my code in its own directory as follows:
src/opensourceproject/src/...
src/opensourceproject/include/...
...
src/myaddition/include/...
src/myaddition/src/...
Is there a way to wrap the build process and create a CMakeLists.txt that builds opensourceproject with my sources added to the opensource build? The reason why I want it, is that I'm more or less writing a plugin and I want my code to be present in the produced executable.
I'm writing a cross-platform application. One version will work under Win32 and the second on Windows Phone.
I'd like to reuse my C++ core - especially that there are no platform dependencies inside, STL only. I order to do so, I want to use the same source files in two projects: static Win32 library (.lib) and Windows Phone Component (C++/CLI).
How can I configure these two projects to use exactly the same source and header files?
OK, let's take an example. Let's say, that I have project:
MyApp.Library [win32 lib]
myClass.cpp
myClass.h
This library is compiled to .DLL file and then imported in a Win32 application:
MyApp.Win32App [win32 C#]
Since Win32 is not compatible with Windows Phone on the binary level, I cannot use that library directly. But since the library uses only STL, I can create a Windows Phone component, put all its sources there, and build.
MyApp.Component [Windows Phone component]
myClass.cpp
myClass.h
I want these two files to be exactly the same ones as used in the library. How should I organize the project to achieve this effect?
You can add source code from a common location to multiple projects. I do that a lot; I have code in a common directory that is at the same level in the directory hierarchy as most of my project files. It's simply a matter of adding .h and .cpp files from the common directory to your various projects.
I did notice that VisualStudio gets a little cranky and difficult if you use a network drive for common source, so I don't do that. But so long as all of your source code is on local disks, and the IDE knows where to find them, there is no problem having the same source file in very many projects.
one way is to put all .hpp and .cpp files into a seperate folder - call it "Shared".
Then add an additional include Directory inside your solution configuration property - this directory must be a relative path.
Then add ONLY the .cpp files relative from that shared folder into your project
NB! If you have include "stdafx.h" inside your .cpp files in the Shared folder, then comment those out.
I use XCode 5.1 for C++ development. I have existing code which I add to the project by dragging files from Finder. The project shows all necessary .h and .cpp files. But when I click Build Phases->Compile Sources, I only see sources that from the root directory in my source structure. None of the source files from subdirectories appear in the Compile Sources. Why? And how to fix this?
Also, when I try to add the missing .cpp file from Build Phases->Compile Sources by pressing +, XCode does not expand the subdirectories, so I cannot select the missing .cpp files.
This is unbelievable. The only problem was that I was adding folder structure with Create folder references for any added folders option instead of Create groups for any added folders.
But still don't understand what is the difference in terms of recognition of source files.
Other peculiarity is that you should add resource files in opposite way (Create folder references for any added folders). Otherwise the iOS application does not find the files and does not compile.
I am in the process of porting my c++ engine to mac, and so I used premake to generate an xcode project, which it does fine.
Box2D is built into the engine and one of its files "b2Broadphase.h" is including algorithm from the c++ standard library.
This is giving these errors: ::clock_t has not been declared and so on for all the using commands in the ctime file.
I cannot figure this out because when using premake to build a make file it runs fine and build a perfect library on OSX. Its only Xcode giving these errors.
My guess is that Xcode has not been configured to include the implementation files (.m or .cpp) or it has not been configured to link against a library which you are using. In general, you need to do two things: 1. include the headers 2. link against the libraries with the actual executable objects.
In Xcode, you do this by selecting the project (top-most item) in the file-browser panel on the left, and there is a section in the main area to choose which libraries to link to. You must specifically tell it to link against whichever libs you are using, even if you have imported their headers.
For .cpp or .m implementation files, you need to tell it to include that file in the target for compilation. This can be done either in the build settings (similar place to the lib inclusion) or else when you have a file selected, the inspector panel on the right has a little area for you to choose which targets to include the file in. (you only need to "include" implementation files like this, not .h files)