Release build and debug build of a netbeans project - c++

I compiled the wxwidgets using build=release now i need to know when compiling my project should i go for a "Debug" or a "Release " build and does it make any effect?
Thanks

The build of the wxWidgets libraries and of your project needs to be exactly the same. So if you release build your application you must link with the release build of the libraries. If you try to link an application and a library that have been built with different parameters then you will get linker errors and no executable will be created.
Most people keep two copies of the built libraries, one to link with debug applications and one to link with release applications.

Nothig bad will happen, but debugging the whole project may be more difficult in debug build, because you will distribute product compiled in release mode and there is no effect.

Related

How to get rid of Debug runtime DLLs

I am using a VS2015 to create DLLs which will be used in a project (which will be run on another PC).
I have build the DLLs in Release version on my PC but when I start the project on another PC, I get following errors:
VCRUNTIME140D.dll is missing
MSVCP140D.dll is missing
MSVCP140D.dll is missing
What steps should I take while creating these DLLs so that these debug runtime DLLs won't be required to the run the project on any PC.
In spite of it being built in release mode, if you require "...D.dll", then there are debug builds in the mix.
This could be the result of the third party dll you have or there are DEBUG or _DEBUG defines floating around.
Most likely is that the build (of the dll or the host exe) is explicitly set to use the debug version of the runtime (/MDd). Change this in the project settings to not use the debug version of the runtime (/MD).
Open the project's Property Pages dialog box.
Expand the C/C++ folder.
Select the Code Generation property page.
Modify the Runtime Library property.
To assist in the diagnosis of which binary is responsible for the debug dependency, you can use Dependency Walker to track down the offender. It will give you a list (as a tree) of the dependencies of each file.
In general, for missing the C++ runtimes (release version) on a target machine, you should install the C++ redistributable. As of this writing, VS 2015 redistributable is available here.
In C/C++ -> Code Generation -> set Runtime Library to:
Multi-threaded Debug (/MTd)
And yes, such setting is very much needed if you want to debug a process on a remote machine. So, don't go by others saying, "test with Release build only". Obviously, you'll need Remote Tools installed.
As stated by Niall, you should use dependency walker in order to find which part of the project is causing the error, it might not be the dll in issue after all.
My bet is it's just some part of the project you forgot and built in debug mode, which of should never be used for production as debug dlls are not included in C++ redistrib installers.

How to create a .exe with visual studio 2015 that I can run from my desktop

I've written a game using OpenGL, GLFW, C/C++. I use third party libraries like SOIL and irrKlang. I use Microsoft Visual 2015. Both the debug and release version run ok from visual studio. In properties -> C++ -> Code Generation-> Runtime Library I selected /MDd. I did try other settings but the release version wouldn't work with any other. All of my .dll are saved in the release and debug folders.
However, when I go to my release folder and copy and paste the .exe found there, onto my desktop,it no longer runs. I keep getting a message that says the irrKlang.dll is missing. Could someone please explain how to get a standalone .exe of my game up and running?
Two things here. First, the .exe is the executable which contains the entry point of your application. So this is indeed the first piece you need. However, your application is allowed to depend on code that's not linked into it statically, but rather dynamically -- such dynamically linked code is only loaded at runtime. These runtime libraries of code are called DLLs ("dynamically linked libraries").
If your application depends on a DLL, it will look for that DLL while it's running. If it doesn't find it, you'll see that message box about a missing DLL. So, you need to copy not only the .exe file, but all the .dlls it depends on (and that they depend on) too. Note that your application links against many default system DLLs, e.g. kernel32, but these don't need to be copied next to the .exe because they're always present in the system search path.
Now, the second part. If you want to run your application on a PC that doesn't have Visual Studio installed, you need to make sure that computer has the C/C++ runtimes that the VS2015 toolchain automatically links against installed. These are not DLLs that you copy by hand; rather, there is a redistributable installer for them which installs them globally on the PC for all applications. You can ship this with your own installer.
For this to work, you want to be linking with just /MD in Release (the debug CRT is for debugging only, and is only installed when Visual Studio is installed -- it's not meant to run outside your PC).
This statement:
"Both the debug and release version run ok from visual studio. In properties -> C++ -> Code Generation-> Runtime Library I selected /MDd. I did try other settings but the release version wouldn't work with any other."
Leads me to believe that maybe you don't have a release version of one of your third party libraries.
/MDd causes your application to use the debug version of the MS runtime, which means that something in your project is being built with or as a debug version.
I use the 'depends.exe' application to see the dependencies of my executables and DLLs. It used to be provided directly by Microsoft, but now seems to be supported via a third party. Older SDKs will have it.
http://www.dependencywalker.com/

Boost Statically /MT Release?

I compiled and ran bjam and even b2.exe with the following command:
bjam --with-system --with-thread ..etc
I got my library files as:
libboost_system-vc110-mt-1_53.lib
libboost_system-vc110-mt-gd-1_53.lib
The problem is that, once I stated the directory and linked them in my project it keeps saying Version Mismatch: found /MDRelease in project /MTRelease.
Yes my project is statically linked for /MT release and that's what I need but boost is causing me trouble.
Any ideas? Thank you.
This sounds like a version problem. The error that you are getting indicates that some components were built with one set of libraries, and other components were built with a different set of libraries.
If you are building other components that uses this code with a different type of library, for example MT (multi-threaded - no debug), or MDd (multi-threaded debug for a dll) then you might get this error. You could also get this error if you are linking with the wrong set of libraries for Boost. You need to build with the same type of libraries that you are using in your own code. If you are using MTD, then build with the MTD version of Boost libraries as well.
To see what libraries your project(s) are using, right click on the project in the Solution Explorer Window and select properties. Properties can also be selected from the project menu, but make sure that you have a file in that project as the current file open in the editing window before doing this. Under Runtime Library you will see the type of library that you are using. If the project type is a dll, then this value should really be set to MDd. To see what type of project it is, click the Linker (or Librarian) option under properties and if the output file is dll, then the project type is dll. If it says library or exe, then the project is library or exe respectively. All of your projects of a given type should be built the same way. You should not try to mix and match release and debug versions for example. If you have an exe that you are building, then use whatever library that was used to build the library type of projects. To set the library, under properties select Configuration Properties / C/C++ / Code Generation / Runtime Library and choose a type from the dropdown box.
If the configuration looks correct for all projects, then try rebuilding from scratch. This can be done by right clicking on the project and selecting clean, followed by selecting rebuild.
When running b2.exe to build the libs, I always use the -q option to make it stop if it encounters an error. If there are errors in the build, they can sometimes be difficult to see since there is quite a bit of output from b2. For a list of options associated with b2, see this link.
Note also that the file libboost_system-vc110-mt-1_53.lib can only be used for VS 2012 projects. If you are not using VS 2012, then you need to do two things. First, you might not be able to use boost version 1.53 or higher with any version of Visual Studio prior to 2012 since 2012 is the first version that best supports the latest version of the C++ standard. So, you would probably have to use 1.52 instead. The second thing you would have to do is specify in b2 the version of Visual Studio that you are using with the toolset option (for example - --toolset=msvc-10.0 - if using VS 2010) so that it will build the correct libraries for you.
You need to build static libs. This will do the trick:
bjam --build-type=complete

Msvcr90d.dll not found when building in RELEASE

It's strange, if I build my program in debug mode, I have no errors, but if I build my program in released mode, I get an error saying that Msvcr90d.dll is not found.
Msvcr90d.dll is a debug library, I'm not sure why it's coming up when I load it for release =/
msvcr90d.dll is a debug version of C/C++ library. It looks like you have a dependency somewhere on a debug target. Check that all the projects in release target use the release version of C runtime, and not the debug. Also, check other 3rd party libraries (DLLs) that you might use, so they not depend on msvcr90d.dll
You can use dependency walker tool to check the dependencies of your binaries, so you can identify the project in your solution that still depends on debug version of C library.
If you are getting the warning LNK 4098 during build, please see this
http://msdn.microsoft.com/en-us/library/6wtdswk0(VS.71).aspx
And follow the recommendations.
Also, make sure that you chose the correct C/C++ runtime under the Code Generation tab (Multi-threaded DLL -- not Multithreaded Debug DLL)

A C++ Application Compiled With VS2008 Doesn't Run In Other Computer

I have created a wn32 project with Visual Studio 2008 and Visual C++ language, it uses the ws2_32.lib library and then I compiled in Release mode.
It runs very good in the same computer, but when I copy the exe file to other computer (that doesn't have installed Visual Studio), it doesn't run.
The message I see is:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
But, if I compile my application using DEV C++, it generates a bigger executable (738KB) compared with the Visual Studio 2008 executable (9.5 KB). However, the DEV C++ executable runs in the other computer.
I have add the library ws2_32.lib to the linker properties of my project, in the Additional Dependencies field.
How can I fix it to work with Visual Studio 2008?
My code is the following: http://www.stan.com.mx/yupi/udpserver.cpp
The problem is almost certainly that the other computer does not have version 9 of the C++ CRT installed.
The default setting for compiling against the CRT in VS2008 is to dynamically link vs. statically linking. If you want to deploy your program with a real setup project you'll need to include the CRT redistributable.
However if you want to do an XCOPY deployment follow the steps on the following page.
http://msdn.microsoft.com/en-us/library/ms235291.aspx
Try installing the Visual C++ redistributables. If that doesn't work, use DependencyWalker to find out what DLLs are missing.
I agree with JaredPar. The application you build with VS2008 is using dynamic linking, whereas the DEV C++ is linking statically, hence the larger size and why one works and not the other.
However, if its a plain win32 application project you've got (and you don't want/need to distribute it with a setup), you may be able to get it to run on another machine without redistributing the CRT by getting VS2008 to link statically for you (if its just the standard lib you're missing). I don't have a copy of VS2008 to hand, so I'll describe how to do it in VS2005 and hopefully it'll translate across.
Bring up configuration properties for the project (right click the project name, then select "properties" from the menu)
Expand "Configuration Properties", then "C/C++", then click "Code Generation"
Under the "Runtime Library" item, for your particular configuration select the non-DLL version of the library i.e. for debug builds you want "Multi-threaded Debug (/MTd) and for release builds you want "Multi-threaded (/MT)"
Try and see if that works. You'll obviously get a much bigger final binary now the library is statically linked.
You may be missing an external dependency required by your program. Check the project settings to see if you are linking against MFC dynamically for example. You can also run Depends utility to check for missing dependencies.