I am trying to run a code using Geant4 (A physics library) and trying to compile it on VS2010.
It seems that some libraries of Geant4 have problem matching with my C++ libraries. In compilation I get a huge number of similar errors like the following:
libG4Tree.a(G4ASCIITree.o) : error LNK2038 : mismatch detected for
'_ITERATOR_DEBUG_LEVEL' : value '0' doesn't match value '2' in
Workshopexample1.OBJ
And get this error with more than 100 different .a files in my G4 libraries.
I really need the debug level to be off ('0'). Since otherwise G4 codes will take years to be run. So, I need to find where is this _ITERATOR_DEBUG_LEVEL defined in my VS2010 and set it to '0' to avoid mismatching. Can anybody help?
Cheers,
Payam
The error can be caused by mixing together debug builds and release builds in same executable or dll.
Release version of the static lib with /MDd instead of /MD, whereas the application is /MD in release. Setting the correct /MD in the static lib project solved the issue.
This is done in Project properties
Select Configuration Properties / C C++ / Code Generation in the tree
and the option Runtime Library set to the same on all your dependencies projects and application.
Search for _ITERATOR_DEBUG_LEVEL and _SECURE_SCL remove them or set them appropriately in all projects and sources and rebuild everything.
_ITERATOR_DEBUG_LEVEL = 0 // disabled (for release builds)
_ITERATOR_DEBUG_LEVEL = 1 // enabled (if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 // enabled (for debug builds)
In short you are probably mixing release and debug dlls. Don't linked release dlls in debug or vice versa!
Related
The Problem
When I repeatedly build release in Xcode, the resulting dSYM is completely empty and so the debugger can't show anything.
I've been able to reproduce this with a minimal project as follows in Xcode 11.3.1:
File -> New Project (macOS, App, Objective-C)
in the target's Build Settings:
set the DEPLOYMENT_POSTPROCESSING for Release to YES
Product -> Scheme -> Edit Scheme
set Build Configuration to Release
Product -> Build
change a file that's not being compiled into the binary (e.g. change the Copyright notice in Info.plist
Product -> Build
Now there is a warning in the build log in the GenerateDSYMFile step
warning: no debug symbols in executable (-arch x86_64)
If the resulting app is run, there will be no debug information (you can't set a breakpoint in Xcode, if you break manually the stack frames will just be ___lldb_unnamed_symbol, ...)
What I found out so far
The relevant part of the Xcode build process seems to be:
Linking the object files to form the binary (only if at least one of them has changed)
Generate dSYM file from binary (if anything in the output has changed)
Stripping the binary, i.e. removing debug symbols (if anything in the output has changed)
So 1) is skipped in the repeated build, because the sources (and thus the object files) have not changed. 2) is executed, because the Info.plist has changed, but it operates on the binary that has already been stripped by the previous build. Hence, the dSYM is empty.
It looks like 2) should only be rerun under the same conditions as 1), but these dependencies seem to be hard-wired in Xcode...
Is there any way around this problem?
Right-click on the solution title in the Solution Explorer window, then go to Configuration Properties -> Configuration. The table appears, showing check-boxes, allowing to turn off/on a build of particular projects for certain configurations.
My solution and projects are generated with CMake.
Is it possible to turn off a particular project for Debug build configuration from CMakeLists.txt?
==
Background of a problem is failing build of Cython project for Debug config.
Release builds fine. CMake module was taken from this example on Github.
Debug config wants debug Python library python27_d.lib, that is forced by pyconfig.h. I use Anaconda python, which is missing this library.
Moreover, I don't need debug build of that project. I've unsuccessfully spent several hours, modifying CMakeLists.txt in various ways, trying to remove definition of _DEBUG macro from compiler command line. CLI parameter /D_DEBUG was absent in all dialogs with properties and "complete command line" listings, that Visual Studio has shown me. Nevertheless, something has always appended it.
So, I'd like to simply disable this project in Debug build for now.
This sets that check-box from the first part of the question to unchecked state:
set_property(TARGET <my Cython module>
PROPERTY EXCLUDE_FROM_DEFAULT_BUILD_DEBUG TRUE)
Now I wonder, where did compiler command line come from, because /D_DEBUG was absent in all dialogs with properties, that Visual Studio has shown me (second part of the question).
I am building this project in VS2013. Initially, that string /D_DEBUG was present in Project properties -> C/C++ -> Preprocessor -> Preprocessor definitions for the Debug configuration. Then I've added
string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
to my CMakeLists.txt file, building the Cython code, and that macro has disappeared from the Project properties.
Nevertheless, the project was still requiring python27_d.dll.
I've also added
#define _DEBUG
in one of files, and have got the following compiler warning
C:\projects\project\file.cpp(9): warning C4005: '_DEBUG' : macro redefinition
command-line arguments : see previous definition of '_DEBUG'
I have a problem with the standard MSBuild.exe used on our Team Build server, the standard version used is in
"C:\Windows\Microsoft.NET\Framework\v4.0.30319", version 4.0.30319.18408 or
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319" respectively (same version).
Using this version leads to Fake dlls not being generated in the same way as on our local development machines (i.e. some fake methods are missing on the server), resulting in broken builds (unit tests) on the TFS.
I updated the build definition template to use the MSBuild version located under "C:\Program Files (x86)\MSBuild\12.0\Bin" as it is more recent (version 12.0.30723.0), however, this results in an error MSB1025, System.Threading.Tasks.Dataflow, Version=4.5.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a not found.
Update
Further investigation - manually adding the System.Threading.Tasks.Dataflow.dll with the correct version number to the MSBuild directory results in a broken build with
Unsupported ToolsVersion 12.0
Manually setting the ToolVersion in the Microsoft.TeamFoundation.Build.Workflow.Acitvities.MSBuild element to "4.0" results in a broken build with
Cannot set unknown member "Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild.ToolVersion"
So... no real improvement.
Any ideas how to fix this?
Fakes is sensitive to the Visual Studio version. Try passing /p:VisualStudioVersion=12.0 to MSBuild arguments. Also avoid handling System.* assemblies manually.
I use VisualStudio2010 and CMake 2.8.12.1. I created a CMakeLists.txt for a MFC project. MFC capability was done by following lines in the CMake file:
add_definitions(-D_AFXDLL) #enables MFC
set(CMAKE_MFC_FLAG 2) #use shared MFC library
Furthermore the project will be build with MD as runtime library (default). But now I want my project to be build as MT (which also requires to specify static MFC library). So I replaced the lines above with:
add_definitions(-D_AFXDLL) #enables MFC
set(CMAKE_MFC_FLAG 1) #use static MFC library
set(CMAKE_CXX_FLAGS_RELEASE "/MT") #set release configuration to MT
set(CMAKE_CXX_FLAGS_DEBUG "/MTd") #set debug configuration to MTd
If I build my project now, I get error message:
fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds
As far as I know this means that there's a mismatch between MT/MD on one side and static/shared MFC library on the other side. I checked the configuration in my project settings once again. Runtime library IS set to MT and MFC library IS set to static. So I do not understand the error. Does anybody know help? Did I miss something?
Regards,
Michael
_AFXDLL is never used with a static MFC build! _AFXDLL.
_AFXDLL is only set when the shared MFC builds are used.
Also static MFC build implies a static CRT.
When compiling a C++ application with VisualStudio I noticed that each output line has a number in front of it. What does the "\d>" stand for?
Example:
4>ContentTimecodeConverter.cpp
1>avus_mpeg_stream_out.obj : warning LNK4221: no public symbols found; archive member will be inaccessible
4>ContentTarget.cpp
4>ContentBrowserWidget.cpp
1>Build log was saved at "file://d:\compile\release\libabc\BuildLog.htm"
1>libabc - 0 error(s), 1 warning(s)
You have concurrent building enabled, an option that enables building multiple projects at the same time. Each build running on one of the cores you have. Which inevitably causes their output to get intermingled. The number helps you keep track of which project produced the message.
It is configured with Tools + Options, Projects and Solutions, Build and Run, "maximum number of parallel build projects" setting.
It is a source of build breaks if you don't set the project dependencies correctly.