Not all components required for linking are present on the command line - c++

I'm trying to use Intel Threading Building Blocks using Intel Parallel Studio XE 2013 (Intel C++ 14.0 project). I have the following to my code
#include <tbb/tbb.h>
using namespace tbb;
and am trying to operate on a map<char, concurrent_vector<int>> stats, specifically to perform an operation such as stats[x].push_back(y).
and have set the 'Use Intel TBB' option in project properties. When I try to compile, I get an error saying
Error 10 error #11023: Not all components required for linking are present on command line C:\Dropbox\Projects\Games\Preference\Preference\ipo Preference (Intel C++ 14.0)
With subsequent errors complaining that I have unresolved externals such as tbb::internal::concurrent_vector_base_v::internal_push_back(...).
How can I fix this?

It seems you need to include tbb_debug.lib into you linking process or to disable auto-linkage to it. Try defining __TBB_NO_IMPLICIT_LINKAGE

Related

Is there a way to include both WICTextureLoader and DDSTextureLoader without 'redefinition' errors?

I'm trying to load a DDS texture. For that, I'm using DDSTextureLoader11 provided by DirectXTex. I already am using another texture loader from the same library - WICTextureLoader11.
The problem is, I don't get errors with WICTextureLoader11, however I do get errors either when including only DDSTextureLoader11, or when I use both of them.
This is some of the errors I get when I include both or only DDSTextureLoader11:
/WICTextureLoader11.cpp:51:17: error: redefinition of 'SetDebugObjectName'
/WICTextureLoader11.cpp:273:17: error: redefinition of 'MakeSRGB'
/WICTextureLoader11.cpp:747:17: error: no matching function for call to 'SetDebugObjectName'
/DDSTextureLoader.h:156:35: error: redefinition of default argument
I first thought that it was because both WICTextureLoader and DDSTextureLoader contain same functions, so when including both they "overlap" (i.e. compiler detects redefinition).
I'm using a batchfile to compile my project, where I link against both DirectXTex and DirectXTK. I also tried to include DDSTextureLoader, but without success: I've read the GitHub page of the DirectXTK's DDSTextureLoader, where I include <DDSTextureLoader.h> that gives me a link error, which I guess is related to the incorrect call of the function CreateDDSTextureFromFile, so right now I'm trying to find a way to make the right call to the function.
Edit: no, it seems like I'm making the right function call. The wrong thing is that I'm trying to include DDSTextureLoader.h, but it also wants DDSTextureLoader.cpp. However, the errors occur when I include DDSTextureLoader.cpp, such as:
'DDSTextureLoader.cpp': call to 'BitsPerPixel' is ambiguous -> 'DirectXTex.h' or 'DDSTextureLoader' error: redefinition of 'SetDebugTextureInfo', previous definition in 'WICTextureLoader'.
I think, what I need is to include the .cpp file, but somehow get rid of the errors.
Edit2: So far, I tried to get rid of DirectXTex (I don't remember why I even needed it), and I've included WICTextureLoader.cpp and DDSTextureLoader.cpp. I downloaded and built the DirectXTK library, then included #pragma comment(lib, "directxtk.lib"). Now, the weird thing is: when I compile with Clang++, it doesn't throw any errors (but the program crashes after a second-long gray screen), however when I compile with cl (through vcvars64), I get fatal error LNK1104: cannot open file 'directxtk.lib'.
Edit3: Wait, I don't even know why I even need the directxtk.lib. So I removed it, and it compiles, but nothing works. I thought I needed that static library to resolve external symbol errors when trying to include the header (XXXTextureLoader.h), instead of the source (XXXTextureLoader.cpp).
Edit4: Wait,wait,wait. I think, I'm going crazy. Now, if I include only WICTextureLoader.cpp (and remove DDSTextureLoader.cpp), it gives me this error: (directxtk.lib) mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'. I don't know why I did that, but I'm crazy now, I blindly brute-force my way through resolving this cursed issue. Why can't I just throw both headers in my directory and just simply include them? Is there a way to do so? What should I do? Why doesn't DirectXTK/Tex pages on GitHub give a step-by-step guide to how to use these things? The examples drive me crazy!
Please, help me resolve this what seems to be a simple issue.
Edit5: The last thing that I tried is to include DDSTextureLoader.h and WICTextureLoader.h, and use directxtk.lib, but it gives me these errors:
directxtk.lib(DDSTextureLoader.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main-3dacd8.o
directxtk.lib(pch.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in main-3dacd8.o
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
I don't use VS, so I don't know how to use /NODEFAULTLIB.
You have three choices for loading DDS and other image files with WIC:
Use DirectXTex (the library)
Use DDSTextureLoader/WICTextureLoader (the standalone versions)
or use DirectX Tool Kit (the library).
There's no reason to use more than one of them in the same program, and it's going to conflict if you try. See this post.
Unless you are writing a texture processing tool, or need support for the plethora of legacy DDS pixel formats, using DirectX Tool Kit is usually the simplest. The tutorials for DirectX Tool Kit covers this pretty well.
The error you are getting indicates something much more basic to using Visual C++. The DirectXTex, DirectXTK libraries build using the recommended "Multithreaded DLL" version of the C/C++ Runtime (i.e. /MDd and /MD).
The error indicates your program is building with "Statically linked" version of the C/C++ Runtime.
See Microsoft Docs
You didn't mention what compiler toolset you are using other than "not VS".
See directx-vs-templates for a bunch of 'basic device and present loop' samples. If you don't use VS, there are 'CMakeLists.txt' available on that site.
I was confused once again with DirectXTex and DirectXTK.
I resolved the issue by:
Removing DirectXTex
Downloading DirectXTK
Running the DirectXTK_Desktop_2019_Win10 solution
Changing the Build to Release and x64
Opening the properties
Finding the option Runtime Library
Choosing Multi-threaded /MT
Building the solution
In my source file, I include:
#include <WICTextureLoader.h> and #include <DDSTextureLoader.h>
I can now link to the generated static library directxtk.lib, without getting errors.
Plus. If there are people who want to use things like /NODEFAULTLIB:library, but you don't use cl or Visual Studio, you can use the #pragma directive in your source file like this:
#pragma comment(linker, "/NODEFAULTLIB:MSVCRT")

How to fix "no member named 'somefunction' in the global namespace"

Environment: Windows 7, Visual Studio 2012, Pepper_34
We have an application that requires parallel processing. We used to use TBB for that. Now porting to PNaCl, we wanted to use this opportunity to switch to using a thread pool built around std::thread in C++11.
Before making the switch, the application (not using TBB) builds for PNaCl without errors.
We know that we will need C++11 for the new thread pool so I enabled C++11 with the command line -std=c++11.
Now I get several errors similar to:
T:\nacl_sdk\pepper_34\toolchain\win_pnacl\usr\include\c++\v1\cstdio(138,9): error : no member named 'snprintf' in the global namespace
So I'm surely missing a compile flag, a command line argument, a pathname or something because this error is generated from compiling cstdio.
Same kind of error when compiling
T:\nacl_sdk\pepper_34\toolchain\win_pnacl\usr\include\c++\v1\__locale and
T:\nacl_sdk\pepper_34\toolchain\win_pnacl\usr\include\c++\v1\locale
Are those pathnames correct?
So my question is what am I missing here to get rid of those errors?

Trying to get my game running in VC 2010, can't seem to link SOIL library, don't know how to link, game source code included

I've been using CodeBlocks for a while now as I make a little hobby game in C++. Come across a snag whereby I want to see the current values of all the data in my arrays at any point, CodeBlocks doesn't seem to have that ability. Have been told by workmates (professional game programmers) that I should use Visual Studio.
Have previously used Visual Studio C# in the past, was very handy being able to use a break point while debugging other small games I've made and then going through the big list of watches to look at particular array values or any other value from within my program at that time.
So I've created a new blank project in VC2010 and added all my code files to the project. I know I have to link libraries and such, have spent the last few hours trying to figure out how to do that. But even after all that is done, I'm still getting link errors (I think)
First problem is this:
fatal error C1083: Cannot open include file: 'gl\glext.h': No such file or directory
So I commented it out to see how much further I could get.
Eventually had to add to my main.cpp file
#pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "glu32.lib")
#pragma comment (lib, "libsoil.lib")
I ended up copying the libsoil.a file to C:\Program Files\Microsoft Visual Studio 10.0\VC\lib and renaming it to libsoil.lib (as stated on the authors's website http://www.lonesock.net/soil.html)
So now I get this when I compile
1>libsoil.lib(stb_image_aug.o) : error LNK2019: unresolved external symbol ___chkstk referenced in function _stbi_zlib_decode_noheader_buffer
1>libsoil.lib(image_helper.o) : error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2
1>C:\Repositories\HappyHelperPuppy\CppVer\HappyHelperPuppy\Debug\HappyHelperPuppy.exe : fatal error LNK1120: 2 unresolved externals
..And I have no idea what to do next. I've spent ages in Google and trawling through forums and I really just don't know what to do.
So as a last ditch effort I'm zipping up all my code and project files and letting anyone whos interested to have a look and see if they can find a solution. It's not like this game will have any secret feature I want to keep under wraps, and all the art is from an open game competition from ages ago ("TIGSource Assembly" for those who know what it is) or from DeviantArt (just wanted something to look at while I made it, wouldn't be final game release art)
The code/game can be found here http://users.on.net/~infernoraven/hhp_busted_code.zip (27mb)
The SOIL library should be in the main directory in its own soil.zip
Any help would be good, but I'm just getting really depressed as I seem to spend most of my time either fighting with the IDE/Compilers or some annoying syntax problem.
The CodeBlocks project files should be in there also, so if you..
un-comment out glext.h
link to SOIL
link to libopengl32 and libglu32
Hopefully it'll compile for you. Otherwise there should be an HappyHelperPuppy.exe that's precompiled by CodeBlocks that should hopefully run and give you an idea of what is suppose to happen
In the SOIL package there are a number of project files for visual studio. When I try to load up the VC9 one and convert it to VC10, I get conversion errors.
Conversion Report - SOIL.vcproj:
Converting project file 'C:\Documents and Settings\Administrator\My Documents\Downloads\soil\Simple OpenGL Image Library\projects\VC9\SOIL.vcproj'.
Failed to upgrade platform 'x64'. Please make sure you have it installed under '%vctargetspath%\platforms\x64'
VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Attribute 'Detect64BitPortabilityProblems' of 'VCCLCompilerTool' is not supported in this version and has been removed during conversion.
Failed to upgrade 'Debug|x64'. Please make sure you have the corresponding platform installed under '%vctargetspath%\platforms\x64'
The project configuration dimension name/value "(Platform, Win32)" was not found in the project manifest.
Project upgrade failed.
If I use the VC8 project file and try to upgrade that, a libSOIL.lib file is generated by VC2010 throws an error saying "Unable to start program ... \SOIL.lib The specified file is an unrecognized or unsupported binary format"
But the author on his site states that I can simply rename the libSOIL.a file to a libSOIL.lib file and it should work.
The soil.zip file contains some .sln files under the folder projects. Use the proper .sln file to build the library, then link your project against this library. It worked fine on my side.

updating boost libraries for Rad Studio

I need to update boost libraries to version 1_46, currently Rad Studio XE/2010 have 1_39 version. When I try just to overwrite boost include path compile fails with various errors from Borland VCL. When i try to add new boost libs in other path keep previous version it also fails with compile condition errors when constructing std::* classes.
I need shared_memory_manager support that is available only in new boost versions. Is there any other ways to upgrade boost libraries or use shared memory that will be available to same processes?
Compilation errors when compiling with new boost version only:
[BCC32 Error] bad_weak_ptr.hpp(44): E2113 Virtual function 'bad_weak_ptr::what() const throw()' conflicts with base class 'std::exception'
[BCC32 Error] xlocale(953): E2228 Too many error or warning messages
There are dozens of locations inside of boost which check the compiler version in order to determine whether or not certain workarounds are needed. (checking against both __CODEGEARC__ and __BORLANDC__) You need to test each of these and update the version number as appropriate. Also there are a number of defines set inside the config/compiler/codegear.hpp file (typically BOOST_HAS_* and BOOST_NO_*) which you also need to turn on/off for different versions of the compiler.
It is a very tricky and time consuming process.

Custom attributes are not consistent?

i have converted a C++ library to managed and get the following error on this code line:
std::ifstream fin(filename, std::ifstream::in);
Errors:
Error 30 error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0003b5). C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\MSVCMRTD.lib(locale0_implib.obj)
Error 32 error LNK2034: metadata inconsistent with COFF symbol table: symbol '??0_Container_base12#std##$$FQAE#XZ' (06000493) has inconsistent metadata with (0A000075) in MSVCMRTD.lib(locale0_implib.obj) C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK
Error 59 error LNK2034: metadata inconsistent with COFF symbol table: symbol '?memcpy##$$J0YAPAXPAXPBXI#Z' (060004DD) has inconsistent metadata with (0A0003E3) in MSVCMRTD.lib(locale0_implib.obj) C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK
Error 60 error LNK1255: link failed because of metadata errors C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK
How to fix that or how to change that code line without having to change the rest of the code?
Essentially, you're compiling your managed code which includes the <fstream> header. That means that all declarations from <fstream> are compiled as if they're managed, too. Yet the CRT DLL contains unmanaged versions of <fstream>.
At link time, this is detected when the import lib MSVCMRTD.lib contains the unmanaged std::_Container_base class, but your .obj files need a managed std::_Container_base.
(The _C tells us it's an implementation helper class).
I know this question is old, but after 1 week struggling to solve this I feel committed to post the solution I found to whoever could be fighting with a similar error.
In my case I'd two projects, one unmanaged with std's all over the place (list, vectors and queues, this is a project which should work on linux too so I cannot use .net collections), and pure standard C++ code, on the second project I create a managed project to wrap this classes to be used in .net projects, I was using Visual Studio 2010, trying to use framework 2.0, unfortunatelly VS 2010 does not have a nice support to VC++, and I tried everything to force it to use 2.0, without success, everytime I compiled I got the same annoying message "Inconsistent blah".
I installed VS 2008, ported the projects to 2008 and voila! everything worked in 10 mins, I spend 1 week trying to solve this in VS 2010 and 2008 did the trick.
I hope this might save a lot of hours trying to solve something that appears to be unsolvable on VS 2010.