Advertisement

InitializeCriticalSection identifier not found error

Started by February 20, 2013 07:12 AM
9 comments, last by PsyKing 11 years, 9 months ago

Hello,

This is my first post here, though I have been lurking on this site for a while. I have been using Microsoft Visual Studio 2012 Express edition for the past two weeks, so I'm still very new with it. I tried to compile AngelScript from source using the provided project for VC++ 2012 edition, and I got these 5 errors (used to be 10, with 5 of them being Intellisense errors, those are gone now though):


              Description                                                          File             Line   Col  Project

Error    1    error C3861: 'InitializeCriticalSection': identifier not found       as_thread.cpp    334    1    angelscript
Error    2    error C3861: 'CreateSemaphore': identifier not found                 as_thread.cpp    384    1    angelscript
Error    3    error C3861: 'InitializeCriticalSection': identifier not found       as_thread.cpp    386    1    angelscript
Error    4    error C3861: 'WaitForSingleObject': identifier not found             as_thread.cpp    413    1    angelscript
Error    5    error C3861: 'WaitForSingleObject': identifier not found             as_thread.cpp    437    1    angelscript 

The error is coming from the file "as_thread.cpp", but from my Google searches and my quick search of the GameDev forum, I haven't found any solutions to remove those errors in order to successfully compile AngelScript. I was hoping someone on these forums might have an potential solutions or workarounds. I have tried adding


#include <synchapi.h>

to the code in the file "as_criticalsection.h", since it is running on Windows 8, and InitializeCriticalSection is supposed to be in that header file according to MSDN, but the errors persist.

This is strange. I use MSVC2012 Express edition with Windows 8 myself and I do not have these problems.

I'll see if I can figure out what might be going on.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Maybe the cpp's are not included in the project itself? (in my experience, Visual Studio does not search among folders to look for files. you have to tell it that there are "existing items". Try to drag and drop those files from the explorer maybe? I dunno. never happened to me before.

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)

This is strange. I use MSVC2012 Express edition with Windows 8 myself and I do not have these problems.

I'll see if I can figure out what might be going on.

Well, when I use the pre-processor definition AS_NO_THREADS, I don't get these errors anymore, but to my understanding, that removes the multi-threading capabilities of AngelScript.

Maybe
the cpp's are not included in the project itself? (in my experience,
Visual Studio does not search among folders to look for files. you have
to tell it that there are "existing items". Try to drag and drop those
files from the explorer maybe? I dunno. never happened to me before.

That shouldn't be the problem though, as the methods that are 'not found' are in the headers provided in the Win32 API (according to the MSDN documentation at least).

Yes, defining AS_NO_THREADS disables support for multi-threading and it won't reference the symbols above.

Is it a new installation of MSVC 2012? Have you already compiled other windows applications, or is AngelScript the first project you attempt to compile? Perhaps the Windows SDK hasn't been properly installed, and that is why it doesn't see the symbols.

Another thought is that perhaps you're having the project settings to generate the code for non-multithreaded CRT library. I'm not in front of my home computer at the moment to test this, but I imagine that this may make the compiler not see these symbols in the Windows SDK.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Are you attempting to build a Metro UI application for Windows Store? Or an ordinary Windows desktop application?

I found a link on google that hinted at these functions not being available for the Metro UI. And in fact, by reading the MSDN document carefully it is stated that these versions of the functions are only available for desktop applications. For Windows Store applications the extended versions of the functions must be used instead, i.e. InitializeCriticalSectionEX, CreateSemaphoreEx, and WaitForSingleObjectEx.

Can you try changing the functions to the extended versions and see if that fixes your problem?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Yes, defining AS_NO_THREADS disables support for multi-threading and it won't reference the symbols above.

Is it a new installation of MSVC 2012? Have you already compiled other windows applications, or is AngelScript the first project you attempt to compile? Perhaps the Windows SDK hasn't been properly installed, and that is why it doesn't see the symbols.

Another thought is that perhaps you're having the project settings to generate the code for non-multithreaded CRT library. I'm not in front of my home computer at the moment to test this, but I imagine that this may make the compiler not see these symbols in the Windows SDK.

I have successfully compile the PocoProject libraries with it, but it is a new and fully updated copy of MSVC2012. I was using the default settings that came with the AngelScript project that was specifically there for MSVC2012, so it should've already been set-up for using the multithreaded CRT library (but I will check).

Edit: I checked and it is using the multithreaded CRT.

Are you attempting to build a Metro UI application for Windows Store? Or an ordinary Windows desktop application?

I found a link on google that hinted at these functions not being available for the Metro UI. And in fact, by reading the MSDN document carefully it is stated that these versions of the functions are only available for desktop applications. For Windows Store applications the extended versions of the functions must be used instead, i.e. InitializeCriticalSectionEX, CreateSemaphoreEx, and WaitForSingleObjectEx.

Can you try changing the functions to the extended versions and see if that fixes your problem?

I won't touch the Metro UI unless I absolutely have to. I'm creating a desktop application, so I have access to what the W8 apps don't have access to.

Still, give it a try. Just change the name of the functions to add the suffix Ex. If this is the problem, then the error 'identifier not found' will go away. Of course, the compilation will fail because of incorrect function arguments, but that should be easy to fix with the use of some default arguments.

I'll probably end up changing to the Ex versions anyway as I want the library to compile properly for Metro too (even if you're not trying to build for Metro), but it would be good to have a confirmation that this is really the problem you're facing.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Still, give it a try. Just change the name of the functions to add the suffix Ex. If this is the problem, then the error 'identifier not found' will go away. Of course, the compilation will fail because of incorrect function arguments, but that should be easy to fix with the use of some default arguments.

I'll probably end up changing to the Ex versions anyway as I want the library to compile properly for Metro too (even if you're not trying to build for Metro), but it would be good to have a confirmation that this is really the problem you're facing.

It seems that I didn't need to... I'm so confused now, I compiled it again (without changing anything), and it compiled successfully. It compiled correctly in both the default AngelScript project and the one that I've imported it into (I've moved files around in the import to my project). I still tried changing the methods to the extended ones, and it seems that they are now not being recognised where the non-extended ones are being recognised now. This is really strange.

Strange, indeed.

Still, it's clear that it is something to do with the project settings and/or MSVC2012 rather than the code. I hope you manage to figure it out.

I will however make the necessary code changes to allow AngelScript to be used in Windows Store applications too, so I thank you for bringing this to my attention.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement