[VS 2010 C++] Strange behavior including boost

Started by
12 comments, last by Rattrap 12 years, 9 months ago
I'm pretty confused.
I tried including the boost thread library to get working with multi-threading within my DLL
but some off stuff happened.
I added the necessary directories into the project settings and put in
#include <boost\thread.hpp>
but it told me the file didn't exist. (which it did)
I did some poking around and realized the problem, the directories needed for the header file were needed in the executable settings too.

Now the confusing part. After adding the directories to the project settings I started getting errors saying how Windows.h suddenly stopped existing!!
I "fixxed" this by having the settings inherit from default.
I put that in quotes because now I have a really odd problem, everything builds okay in debug (or so it seams) but when the program runs it doesn't even open a window. it does nothing at all.
just out of curiosity I decided to build in release. Which keeps giving me
1>------ Build started: Project: IndigoFramework, Configuration: Release Win32 ------
1> Indigo.cpp
1>c:\users\bombshell\documents\visual studio 2010\projects\indigoengine\indigoengine\Indigo.h(8): fatal error C1083: Cannot open include file: 'd3dx11.h': No such file or directory
2>------ Build started: Project: IndigoEngine, Configuration: Release Win32 ------
2> MProg.cpp
2>c:\users\bombshell\documents\visual studio 2010\projects\indigoengine\indigoengine\Indigo.h(8): fatal error C1083: Cannot open include file: 'd3dx11.h': No such file or directory========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========


but on further investigation, though I don't know why building release gives me those errors
removing the
#include <boost\thread.hpp>
from the DLL header file everything goes back to normal... (though building in release still gives the above error)

I'm just completely confused as to what is going on.
Any help is appreciated,
Thanks in advanced,
Bombshell
Advertisement
The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>. The latter actually generates escape sequences which means you're not getting "path\to\file" you're getting, well, what's likely gibberish :-)

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>. The latter actually generates escape sequences which means you're not getting "path\to\file" you're getting, well, what's likely gibberish :-)


I'm not sure if thats the problem as VS is quite happy to accept either \ or / without generatign escape sequences. ..\ works as intended. I am curious as the right direction (\ or /) as I've never really been sure. I'm currently using \ with no problems - though whether that is the right thing to do or not I've no idea.

Bombshell, I would recheck the includes, remove them and try it again. I'm sure you've tried that a few times but thats the most likely problem. Don't add them as project includes, add them to VS itself Tools->Options->Projects and Solutions->VC++ Directories.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

#include directives are not string literals, escape sequences are not necessarily valid there. I believe they are actually implementation defined, apart from the standard headers of course.
You need to set proper include paths in both debug and release mode.
Fire up your project setting dialog, then choose "release" target, check the include path.

BTW, you can use "boost\thread.hpp", but I think it's better to use '/' instead of '\' so it can be compiled anywhere (on Mac, Linux, etc). Though I'm not sure if '\' can compile on Linux.

https://www.kbasm.com -- My personal website

https://github.com/wqking/eventpp  eventpp -- C++ library for event dispatcher and callback list

https://github.com/cpgf/cpgf  cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.

thanks for the clarification on the release problem.

as for debug when including boost
all the necessary directories are in VC++ Directories project settings.
But the program still does nothing after running.

I still find the strangest thing to be the fact that removing the boost include stops the problem.
I didn't think a single header file could have so much of a difference in getting the program to run.
To build sure, with linking problems or something, but the fact its building but not running has me most confused.

Here is what I get on build, seems relatively harmless
1>------ Build started: Project: IndigoFramework, Configuration: Debug Win32 ------
1> Indigo.cpp
1>..\IndigoEngine\Indigo.cpp(10): warning C4244: '=' : conversion from 'float' to 'UINT', possible loss of data
1>..\IndigoEngine\Indigo.cpp(11): warning C4244: '=' : conversion from 'float' to 'UINT', possible loss of data
1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\basic_timed_mutex.hpp(160): warning C4793: 'boost::detail::basic_timed_mutex::unlock' : function compiled as native :
1> Found an intrinsic not supported in managed code
1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\thread_primitives.hpp(314): warning C4793: 'boost::detail::win32::interlocked_bit_test_and_set' : function compiled as native :
1> Found an intrinsic not supported in managed code
1> Creating library C:\Users\Bombshell\documents\visual studio 2010\Projects\IndigoEngine\Debug\IndigoFramework.lib and object C:\Users\Bombshell\documents\visual studio 2010\Projects\IndigoEngine\Debug\IndigoFramework.exp
1>Indigo.obj : warning LNK4248: unresolved typeref token (01000023) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run
1> IndigoFramework.vcxproj -> C:\Users\Bombshell\documents\visual studio 2010\Projects\IndigoEngine\Debug\IndigoFramework.dll
2>------ Build started: Project: IndigoEngine, Configuration: Debug Win32 ------
2> MProg.cpp
2> LINK : C:\Users\Bombshell\documents\visual studio 2010\Projects\IndigoEngine\Debug\IndigoEngine.exe not found or not built by the last incremental link; performing full link
2> IndigoEngine.vcxproj -> C:\Users\Bombshell\documents\visual studio 2010\Projects\IndigoEngine\Debug\IndigoEngine.exe========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


And heres what I get on Debug
'IndigoEngine.exe': Loaded 'C:\Users\Bombshell\Documents\Visual Studio 2010\Projects\IndigoEngine\Debug\IndigoEngine.exe', Symbols loaded.
'IndigoEngine.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'IndigoEngine.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'IndigoEngine.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'IndigoEngine.exe': Loaded 'C:\Users\Bombshell\Documents\Visual Studio 2010\Projects\IndigoEngine\Debug\IndigoFramework.dll', Symbols loaded.
'IndigoEngine.exe': Loaded 'C:\Windows\SysWOW64\mscoree.dll', Cannot find or open the PDB file
'IndigoEngine.exe': Unloaded 'C:\Windows\SysWOW64\mscoree.dll'
'IndigoEngine.exe': Unloaded 'C:\Users\Bombshell\Documents\Visual Studio 2010\Projects\IndigoEngine\Debug\IndigoFramework.dll'
The program '[4528] IndigoEngine.exe: Native' has exited with code -1073741701 (0xc000007b).

1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\basic_timed_mutex.hpp(160): warning C4793: 'boost::detail::basic_timed_mutex::unlock' : function compiled as native :
1> Found an intrinsic not supported in managed code
1>c:\program files (x86)\boost\boost_1_47\boost\thread\win32\thread_primitives.hpp(314): warning C4793: 'boost::detail::win32::interlocked_bit_test_and_set' : function compiled as native :
1> Found an intrinsic not supported in managed code


Are you using C++/CLI? It looks like it is complaining about boost's use of non-managed code along with managed code.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

I'm not using C++/CLI... at least not to my knowledge
Intellisence still works and it was to my understanding it didn't work with projects that included / used C++/CLI (I've come across VS 2010 commenting on it in the bottom right corner when looking at certain code examples)

I'm not using C++/CLI... at least not to my knowledge
Intellisence still works and it was to my understanding it didn't work with projects that included / used C++/CLI (I've come across VS 2010 commenting on it in the bottom right corner when looking at certain code examples)


I just tried creating a test C++/CLI project in VC2010 and included <boost/thread.hpp> and got the exact same error you did.



1>------ Build started: Project: CLRTest, Configuration: Debug Win32 ------
1>Build started 7/19/2011 8:51:27 AM.
1>InitializeBuildStatus:
1> Creating "E:\Programming\CLRTest\_Obj\Win32\Debug\CLRTest\CLRTest.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> stdafx.cpp
1> AssemblyInfo.cpp
1> CLRTest.cpp
1> Generating Code...
1>e:\programming\boost\boost\thread\win32\basic_timed_mutex.hpp(160): warning C4793: 'boost::detail::basic_timed_mutex::unlock' : function compiled as native :
1> Found an intrinsic not supported in managed code
1>e:\programming\boost\boost\thread\win32\thread_primitives.hpp(314): warning C4793: 'boost::detail::win32::interlocked_bit_test_and_set' : function compiled as native :
1> Found an intrinsic not supported in managed code

1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
1>C:\Users\Rob Yull\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp : fatal error C1083: Cannot open compiler generated file: 'E:\Programming\CLRTest\_Obj\Win32\Debug\CLRTest\C:\Users\Rob Yull\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.obj': Invalid argument
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:04.30
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[/quote]

It looks like your IndigoFramework project is C++/CLI.

You are correct about Intellisense and C++/CLI, but I'm guessing only one of the projects may be incorrectly setup this way.

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]


The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>.


VC 2010 Pro (not sure about express) actually has the option to auto-complete includes either with either slash (defaults to \ )

[attachment=4225:VS2010Slash.png]


"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

This topic is closed to new replies.

Advertisement