Sign in to follow this  
Bombshell93

[VS 2010 C++] Strange behavior including boost

Recommended Posts

Bombshell93    245
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
[code]#include <boost\thread.hpp>[/code]
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
[code]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 ==========[/code]

but on further investigation, though I don't know why building release gives me those errors
removing the
[code]#include <boost\thread.hpp>[/code]
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

Share this post


Link to post
Share on other sites
ApochPiQ    23063
The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>. The latter actually generates [i]escape sequences[/i] which means you're not getting "path\to\file" you're getting, well, what's likely gibberish :-)

Share this post


Link to post
Share on other sites
Nanoha    2682
[quote name='ApochPiQ' timestamp='1311058917' post='4837239']
The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>. The latter actually generates [i]escape sequences[/i] which means you're not getting "path\to\file" you're getting, well, what's likely gibberish :-)
[/quote]

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.

Share this post


Link to post
Share on other sites
rip-off    10979
#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.

Share this post


Link to post
Share on other sites
wqking    761
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.

Share this post


Link to post
Share on other sites
Bombshell93    245
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
[code]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 ==========[/code]

And heres what I get on Debug
[code]'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).[/code]

Share this post


Link to post
Share on other sites
Rattrap    3385
[quote name='bombshell93' timestamp='1311077797' post='4837341']
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
[/quote]

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

Share this post


Link to post
Share on other sites
Bombshell93    245
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)

Share this post


Link to post
Share on other sites
Rattrap    3385
[quote name='bombshell93' timestamp='1311079666' post='4837347']
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)
[/quote]

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

[quote]

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...
[b]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[/b]
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.

Share this post


Link to post
Share on other sites
Rattrap    3385
[quote name='ApochPiQ' timestamp='1311058917' post='4837239']
The correct syntax for #include is #include <path/to/file.h> not <path\to\file.h>.
[/quote]

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]


Share this post


Link to post
Share on other sites
Bombshell93    245
do you think they could be causing the problem of the program doing nothing?
if so what would I be looking for that indicates CLI?
I'm unfamiliar with the language, but taking a quick google it seems similar to C# (with that being the coding language I'm most familiar with its plausible I used similar code in C++ by mistake)

Share this post


Link to post
Share on other sites
Rattrap    3385
[quote name='bombshell93' timestamp='1311083618' post='4837378']
do you think they could be causing the problem of the program doing nothing?
if so what would I be looking for that indicates CLI?
I'm unfamiliar with the language, but taking a quick google it seems similar to C# (with that being the coding language I'm most familiar with its plausible I used similar code in C++ by mistake)
[/quote]

It's basically a modified version of C++ that uses the .Net Common Language Runtime. Check your project files (Right click on the Project and choose [b]Properties[/b]). Check under [b]General [/b]-> C[b]ommon Language Runtime Support [/b]and see if it says [b]Common Language Runtime Support /clr[/b] (see picture below)

[attachment=4226:VS2010CLR.png]


If it is there, try changing it to [b]No Common Language Runtime Support[/b].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this