‘FaceRecognizer’ was not declared in this scope - opencv

I am trying to compile a program, I am trying to track an object using openCV.
Now whenever i compile the code i get the following error.
disguise_gui_1306.cpp:101:5: error: ‘FaceRecognizer’ was not declared in this scope
Ptr model, mouthModel;
^
disguise_gui_1306.cpp:101:19: error: template argument 1 is invalid
Ptr model, mouthModel;
^
disguise_gui_1306.cpp:101:26: error: invalid type in declaration before ‘,’ token
Ptr model, mouthModel;
^
disguise_gui_1306.cpp: In function ‘void snapshotCB(Fl_Widget*, void*)’:
disguise_gui_1306.cpp:232:40: error: base operand of ‘->’ is not a pointer
int predictedMouthLabel = mouthModel->predict(testSample);
^
disguise_gui_1306.cpp:242:31: error: base operand of ‘->’ is not a pointer
int predictedLabel = model->predict(testSample);
^
disguise_gui_1306.cpp:260:29: error: base operand of ‘->’ is not a pointer
int predictedLabel = model->predict(testSample);
^
disguise_gui_1306.cpp: In function ‘void
trainFaceRecogniserModel(std::vector, std::vector)’:
disguise_gui_1306.cpp:394:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope
model = createEigenFaceRecognizer();
^
disguise_gui_1306.cpp:395:10: error: base operand of ‘->’ is not a pointer
model->train(img, lab);
^
disguise_gui_1306.cpp: In function ‘int main(int, char**)’:
disguise_gui_1306.cpp:416:39: error: ‘createEigenFaceRecognizer’ was not
declared in this scope
model = createEigenFaceRecognizer();
^
disguise_gui_1306.cpp:417:10: error: base operand of ‘->’ is not a pointer
model->train(images, labels);
^
disguise_gui_1306.cpp:432:15: error: base operand of ‘->’ is not a pointer
mouthModel->train(mouthimages, mouthlabels);
While when the run the same on my friends laptop it compiles smoothly.
We are same OS(debian),OpenCV 3.0.0-rc1.
As per my research this problem should only arise if m using older version of openCV2.3.
I have been trying various solutions like adding contrib.hpp and all.
But nothing seems to help.
Kindly help.

Was your opencv3 built with OPENCV_EXTRA_MODULES_PATH option in make?
-D OPENCV_EXTRA_MODULES_PATH=</path/to/opencv_contrib>/modules

As mentioned above, first check if OpenCV was compiled with contrib modules as described in https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
then:
Add the inlude directories in your cmake CMakeLists.txt as described in
https://docs.opencv.org/4.x/db/df5/tutorial_linux_gcc_cmake.html ; an example:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( "/home/user/opencv-4.x","/home/user/opencv_contrib-4.x" )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
In your program.cpp file include the libraries
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
#include <opencv2/highgui.hpp>
Follow the correct name spaces described per version of OpneCV in https://docs.opencv.org/4.5.5/dd/d7c/classcv_1_1face_1_1EigenFaceRecognizer.html or de FaceRecognizer you use; for example
Ptr<cv::face::FaceRecognizer> model = cv::face::EigenFaceRecognizer::create();

Related

VS2019 and _NO_CRT_STDIO_INLINE, how to explain this weirdo?

Please check my short code below.
pwrapper.h
#include <stdio.h>
#include <stdarg.h>
extern"C" int mm_printfA(const char *fmt, ...);
extern"C" int mm_printfW(const wchar_t *fmt, ...);
pwrapper.cpp
#include "pwrapper.h"
int mm_printfA(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = vprintf(fmt, args);
va_end(args);
return ret;
}
int mm_printfW(const wchar_t *fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = vwprintf(fmt, args);
va_end(args);
return ret;
}
main.cpp
#include "pwrapper.h"
// cl /MT /D _NO_CRT_STDIO_INLINE main.cpp pwrapper.cpp
void main()
{
mm_printfA("What is %d?\n", 123);
}
#if 0
void usedull()
{
vprintf(NULL, NULL);
vwprintf(NULL, NULL);
}
#endif
For some reason, I need to compile it with _NO_CRT_STDIO_INLINE, like this:
cl /MT /D _NO_CRT_STDIO_INLINE main.cpp pwrapper.cpp
But link stage fails saying unresolved external symbol vwprintf and vprintf .
A very weird workaround I find out is: Enable the usedull() function body -- although never be called, and, link through pwrapper.lib, using bb.bat below:
#setlocal EnableDelayedExpansion
#set CFLAGS=/D _NO_CRT_STDIO_INLINE
cl /nologo /c /MT %CFLAGS% pwrapper.cpp
#if errorlevel 1 exit /b 4
lib /nologo /out:pwrapper.lib pwrapper.obj
#if errorlevel 1 exit /b 4
cl /nologo /c /MT main.cpp
#if errorlevel 1 exit /b 4
link /nologo main.obj pwrapper.lib
#if errorlevel 1 exit /b 4
Well, this really works, but why?
This is not a pleasant workaround, because each exe project needs to include a "useless" usedull() function. So, is there any better way?
I really can't tell why this workaround works, an explanation of it is very welcome.
==== Some Clarification ====
There were two main.cpp in my original post. Let me name them separately for later reference in case someone would bother to answer this weird question.
main.0.cpp refers to the one without usedull().
main.1.cpp refers to the one with usedull().
In this question, I use VC++ headers and libs for application(not for kernel), and
I compile main.0.cpp and main.1.cpp without _NO_CRT_STDIO_INLINE.
I always compile pwrapper.cpp with _NO_CRT_STDIO_INLINE.
Whether having pwrapper.obj go through pwrapper.lib produce the same result in this issue.
In short:
compiling pwrapper.cpp with -D _NO_CRT_STDIO_INLINE tells the compiler you are going to provide your own implementation of vprintf and vwprintf at link time, and
compiling main.cpp without -D _NO_CRT_STDIO_INLINE tells the compiler to include implementations of vprintf and vwprintf which are used at link time to satisfy both the references from usedull and mm_printfA/mm_printfW
so, this particular combination works to resolve all undefined symbols at link time. See below for more discussion however.
Discussion
In stdio.h, vprintf (which I'll focus on, but vwprintf is configured in the same way) is defined like so:
_Check_return_opt_
_CRT_STDIO_INLINE int __CRTDECL vprintf(
_In_z_ _Printf_format_string_ char const* const _Format,
va_list _ArgList
)
#if defined _NO_CRT_STDIO_INLINE
;
#else
{
return _vfprintf_l(stdout, _Format, NULL, _ArgList);
}
#endif
Note that
if _NO_CRT_STDIO_INLINE is defined, this becomes a forward declaration
whereas if it is not defined, the full body is included in the compilation of the including translation unit.
Additionally, in corecrt_stdio_config.h whether _NO_CRT_STDIO_INLINE is defined determines the value of _CRT_STDIO_INLINE; if it is defined, _CRT_STDIO_INLINE is defined as empty, otherwise it is defined as __inline.
Putting these together,
if _NO_CRT_STDIO_INLINE is not defined, these functions will be candidates for inline expansion,
otherwise a separate implementation of that function will need to be provided at link time.
Default Compilation (no /O1, /O2, no _NO_CRT_STDIO_INLINE)
The above works with the specific compile and link invocations you are using, as without optimization the compiler will simply include the function body in the compilation of main.1.obj. You can see this using dumpbin; running dumpbin -symbols main.1.obj | find "| vprintf" prints:
01D 00000000 SECT8 notype () External | vprintf
showing that main.1.obj provides vprintf as an externally available symbol.
Checking pwrapper.obj, we get:
00A 00000000 UNDEF notype () External | vprintf
showing that vprintf is undefined in this object file, and will need to be provided at link time.
Optimisation for Inline Expansion
However, if we change the optimisation option for inline expansion, we get different results. Using even the first level of optimisation (-Ob1, included in -O1 and -O2) like so:
cl -c -Ob1 main.1.cpp
causes the compiler to incorporate the body of vprintf directly into usedull, and remove the separate implementation of vprintf, which can be confirmed using dumpbin. So, as you would now expect, attempting to link main.1.obj and pwrapper.obj together will once again give your original error:
pwrapper.obj : error LNK2019: unresolved external symbol vwprintf referenced in function mm_printfW
pwrapper.obj : error LNK2019: unresolved external symbol vprintf referenced in function mm_printfA
main.exe : fatal error LNK1120: 2 unresolved externals
Multiple Implementations?
So, following on from that it is apparent that compiling both files with -D _NO_CRT_STDIO_INLINE will fail as there will be no implementations of the relevant methods. What about if both are compiled without this definition?
If we check the object files, both have defined symbols for vprintf:
01D 00000000 SECT8 notype () External | vprintf
and:
01A 00000000 SECT7 notype () External | vprintf
which under normal circumstances would result in errors due both to multiple definitions of a symbol and violations of the One Definition Rule. However, when performing inline expansion, the compiler and linker have your back. As per 2:
Rather than expand an inline function defined in a header file, the compiler may create it as a callable function in more than one translation unit. The compiler marks the generated function for the linker to prevent one-definition-rule (ODR) violations.

React Native Xcode errors

I use react native 0.65.1 and Xcode 10 to create a react native app.
I have changed the objectVersion in ios/project.xcodeproj/project.pbxproj and ios/Pods/Pods.xcodeproj/project.pbxproj from 54 to 51 so I can open the xcworkspace file in Xcode 10. Other than that I pretty much follow the instructions on react native website and didn't change anything.
When running
npx react-native run-ios
in the terminal, I get the following errors mainly (but not all) in the file "/node_modules/react-native/React/Views/RCTDatePickerManager.m":
RCTDatePickerManager.m:33:5: error: expected a type
UIDatePickerStyle,
^
RCTDatePickerManager.m:35:22: error: use of undeclared identifier 'UIDatePicker
StyleCompact'
#"compact" : #(UIDatePickerStyleCompact),
^
RCTDatePickerManager.m:36:22: error: use of undeclared identifier 'UIDatePicker
StyleWheels'
#"spinner" : #(UIDatePickerStyleWheels),
^
RCTDatePickerManager.m:37:21: error: use of undeclared identifier 'UIDatePicker
StyleInline'; did you mean 'UIDatePickerModeTime'?
#"inline" : #(UIDatePickerStyleInline),
^~~~~~~~~~~~~~~~~~~~~~~
UIDatePickerModeTime
In file included from RCTDatePickerManager.m:8:
In file included from RCTDatePickerManager.h:8:
ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:228:17: note: expanded from macro 'RCT_ENUM_CONVERTER'
mapping = values; \
^
In module 'UIKit' imported from ios/Pods/Target Support Files/React-Core/React-Core-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk/System/Library/Frameworks/UIKi
t.framework/Headers/UIDatePicker.h:16:5: note: 'UIDatePickerModeTime' declared here
UIDatePickerModeTime, // Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
^
RCTDatePickerManager.m:39:5: error: use of undeclared identifier 'UIDatePickerS
tyleAutomatic'; did you mean 'UIActionSheetStyleAutomatic'?
UIDatePickerStyleAutomatic,
^~~~~~~~~~~~~~~~~~~~~~~~~~
UIActionSheetStyleAutomatic
In file included from /node_modules/react-native/React/Views/RCTDatePickerManager.m:8:
In file included from /node_modules/react-native/React/Views/RCTDatePickerManager.h:8:
/ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:230:67: note: expanded from macro 'RCT_ENUM_CONVERTER'
return _RCT_CAST(type, [RCTConvertEnumValue(#type, mapping, #(default), json) getter]); \
^
ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:216:31: note: expanded from macro '_RCT_CAST'
#define _RCT_CAST(type, expr) expr
^
In module 'UIKit' imported from /ios/Pods/Target Support Files/React-Core/React-Core-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk/System/Library/Frameworks/UIKi
t.framework/Headers/UIActionSheet.h:20:5: note: 'UIActionSheetStyleAutomatic' declared here
UIActionSheetStyleAutomatic = -1, // take appearance from toolbar style otherwise uses 'default'
^
RCTDatePickerManager.m:32:1: error: implicit conversion of 'NSInteger' (aka 'lo
ng') to 'id' is disallowed with ARC
RCT_ENUM_CONVERTER(
^~~~~~~~~~~~~~~~~~~
In file included from RCTDatePickerManager.m:8:
In file included from RCTDatePickerManager.h:8:
/ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:230:28: note: expanded from macro 'RCT_ENUM_CONVERTER'
return _RCT_CAST(type, [RCTConvertEnumValue(#type, mapping, #(default), json) getter]); \
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:216:31: note: expanded from macro '_RCT_CAST'
#define _RCT_CAST(type, expr) expr
^~~~
/RCTDatePickerManager.m:32:1: warning: incompatible integer to pointer conversio
n returning 'NSInteger' (aka 'long') from a function with result type 'id' [-Wint-conversion]
RCT_ENUM_CONVERTER(
^~~~~~~~~~~~~~~~~~~
In file included from /RCTDatePickerManager.m:8:
In file included from /RCTDatePickerManager.h:8:
/ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:230:28: note: expanded from macro 'RCT_ENUM_CONVERTER'
return _RCT_CAST(type, [RCTConvertEnumValue(#type, mapping, #(default), json) getter]); \
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ios/Pods/Headers/Private/React-Core/React/RCTConvert.h:216:31: note: expanded from macro '_RCT_CAST'
#define _RCT_CAST(type, expr) expr
^~~~
/RCTDatePickerManager.m:93:7: error: unknown type name 'UIDatePickerStyle'; did
you mean 'UIDatePickerMode'?
UIDatePickerStyle style = [RCTConvert UIDatePickerStyle:json];
^~~~~~~~~~~~~~~~~
UIDatePickerMode
In module 'UIKit' imported from /ios/Pods/Target Support Files/React-Core/React-Core-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator12.0.sdk/System/Library/Frameworks/UIKi
t.framework/Headers/UIDatePicker.h:15:28: note: 'UIDatePickerMode' declared here
typedef NS_ENUM(NSInteger, UIDatePickerMode) {
^
RCTDatePickerManager.m:93:25: warning: incompatible pointer to integer conversi
on initializing 'UIDatePickerMode' (aka 'enum UIDatePickerMode') with an expression of type 'id' [-Wint-conversion]
UIDatePickerStyle style = [RCTConvert UIDatePickerStyle:json];
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RCTDatePickerManager.m:94:12: error: property 'preferredDatePickerStyle' not fo
und on object of type 'RCTDatePicker *'
view.preferredDatePickerStyle = style;
^
RCTDatePickerManager.m:96:12: error: property 'preferredDatePickerStyle' not fo
und on object of type 'RCTDatePicker *'
view.preferredDatePickerStyle = UIDatePickerStyleWheels;
^
RCTDatePickerManager.m:96:39: error: use of undeclared identifier 'UIDatePicker
StyleWheels'
view.preferredDatePickerStyle = UIDatePickerStyleWheels;
^
2 warnings and 10 errors generated.
file paths has been slightly modified for improved readability. Please kindly advice how to fix.
I had this exact problem, and the dispiriting experience of this being the only hit on google, with no response :D
For me, upgrading XCode fixed this. Everything was working locally as I'd recently upgraded XCode fully, but on Bitrise CI, I was getting the error. Bitrise lets you update XCode from the stacks tab.
I upgraded from 11.7 --> 12.4, and that resolved the issue.

Errors building OpenCV 3.2 # Win7Prof64 with Code:Blocks 16.01/ mingw 4.9.2

After doing CMake (all with default) I open the Code:Block project file
and building gives these errors:
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'void cvSetModeWindow_W32(const char*, double)':
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp:474:47: error: 'MONITOR_DEFAULTTONEAREST' was not declared in this scope
hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
^
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp:474:71: error: 'MonitorFromRect' was not declared in this scope
hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
^
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'LRESULT MainWindowProc(HWND, UINT, WPARAM, LPARAM)':
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp:1377:45: error: 'MONITOR_DEFAULTTONEAREST' was not declared in this scope
hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
^
D:\Guido\develop\opencv\sources\modules\highgui\src\window_w32.cpp:1377:69: error: 'MonitorFromRect' was not declared in this scope
hMonitor = MonitorFromRect(&rect, MONITOR_DEFAULTTONEAREST);
... what makes all this more strange:
At the beginning of this file (window_w32.cpp) the symbol _WIN32_IE
is not defined at all (why?).
As I'm new to C:B and OpenCV hints are appreciated.
Edit:
I just found a hint by myself:
http://answers.opencv.org/question/104125/i-am-unable-to-build-opencv-using-mingw-codeblockstotally-a-beginner/
Do I understand this right, that mingw 4.9.2 does not do with recent openCV?
(But 4.9.2 is the compiler that is actually shipped with C:B) ...
Figured it out.
Despite OpenCV dropped mingw compiler support in 2015
(why that??)
it is well possible to build OpenCV with mingw.
2 modules make problems when building: highgui and ts.
Both seems to have to do with the way mingw handles
windows headers.
For module highgui:
Error while building OpenCV :: MonitorFromRect was not declared in this scope
For module ts:
https://github.com/google/googletest/issues/893
Why - in heaven's name - so much stumbling stones
on a way to use a freeware toolchain?
No wonder that M$ will smother everything.
It has to be convenient to use.
If I need a car to do my work, I want to use the car.
Not have to build ("and to understand, that's important!") it.
SCNR.

opencv installation error while mingw32-make on windows

opencv installation using mingw32-make command in windows 10 platform, then likely end up in getting the below error.
Windows version : 10
OpenCv:3.2.0
Please suggest me in installing.
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
critical_section_(new CRITICAL_SECTION) {
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8879:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
critical_section_ = new CRITICAL_SECTION;
^
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
modules\ts\CMakeFiles\opencv_ts.dir\build.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFiles\Makefile2:5379: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I also faced the same problem while trying to build OpenCV 3.2.0 using mingw32 on Windows10. I searched a bit to find a fix on Github for similar problem. It said the problem was:
MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two separate (equivalent) structs, instead of using typedef
So, you have to add another typedef GTEST_CRITICAL_SECTION for _CRITICAL_SECTION and _RTL_CRITICAL_SECTION and use this typedef for either case.
Here is what to do :
Edit "ts_gtest.h" which is inside "opencv\sources\modules\ts\include\opencv2\ts\"
Replace this line (probably line 723)
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct _RTL_CRITICAL_SECTION;
with
#if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#else
// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
Replace this line (probably on line 3060 before your edit - line number would have changed as you modified first part)
_RTL_CRITICAL_SECTION* critical_section_;
with
GTEST_CRITICAL_SECTION* critical_section_;
These two changes should fix your above error.
It was fixed by using TDM-gcc mingw compiler.

Trouble compiling tweak on iOS

I'm currently trying to compile a tweak using theos on my iPhone 5s on 8.1.1 over ssh.
I used an open-sourced one called EasyRespring that I found on github which is claimed to be iOS 8 compatible.
After copying all the files from it and running make, I'm thrown a slew of errors that I'm having trouble deciphering.
I can provide any extra information if necessary.
drop-it-like-its-hotspot:/private/var/easyrespring root# make
/private/var/easyrespring/theos/makefiles/targets/Darwin-arm64/iphone.mk:43: Targeting iOS 4.0 and higher is not supported with iphone-gcc. Forcing clang.
/private/var/easyrespring/theos/makefiles/targets/Darwin-arm64/iphone.mk:53: Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.
Making all for tweak EasyRespring...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
In file included from <built-in>:181:
In file included from <command line>:3:
In file included from /private/var/easyrespring/theos/Prefix.pch:4:
In file included from /private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:9:
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:18:1: error:
C++ requires a type specifier for all declarations
NS_CLASS_DEPRECATED_IOS(2_0, 5_0, "UIAcceleration has been replaced by t...
^~~~~~~~~~~~~~~~~~~~~~~
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:18:26: error:
invalid suffix '_0' on integer constant
NS_CLASS_DEPRECATED_IOS(2_0, 5_0, "UIAcceleration has been replaced by t...
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:18:98: error:
expected ';' after top level declarator
...5_0, "UIAcceleration has been replaced by the CoreMotion framework")
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:26:1: error:
unexpected '#' in program
#property(nonatomic,readonly) UIAccelerationValue x;
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:27:1: error:
unexpected '#' in program
#property(nonatomic,readonly) UIAccelerationValue y;
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:28:1: error:
unexpected '#' in program
#property(nonatomic,readonly) UIAccelerationValue z;
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:30:1: error:
'#end' must appear in an Objective-C context
#end
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:32:1: error:
C++ requires a type specifier for all declarations
NS_CLASS_DEPRECATED_IOS(2_0, 5_0, "UIAccelerometer has been replaced by ...
^~~~~~~~~~~~~~~~~~~~~~~
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:32:26: error:
invalid suffix '_0' on integer constant
NS_CLASS_DEPRECATED_IOS(2_0, 5_0, "UIAccelerometer has been replaced by ...
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:32:99: error:
expected ';' after top level declarator
...5_0, "UIAccelerometer has been replaced by the CoreMotion framework")
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:45:1: error:
unexpected '#' in program
#property(nonatomic) NSTimeInterval updateInterval; //May be capped at ...
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:46:1: error:
unexpected '#' in program
#property(nonatomic,assign) id<UIAccelerometerDelegate> delegate;
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:48:1: error:
'#end' must appear in an Objective-C context
#end
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:50:35: error:
cannot find protocol declaration for 'NSObject'
#protocol UIAccelerometerDelegate<NSObject>
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:24: error:
expected a type
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UI...
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:71: error:
expected a type
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAc...
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:118: error:
expected ':'
...didAccelerate:(UIAcceleration *)acceleration NS_DEPRECATED_IOS(2_0, 5_0);
^
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccelerometer.h:53:118: error:
expected ';' after method prototype
In file included from <built-in>:181:
In file included from <command line>:3:
In file included from /private/var/easyrespring/theos/Prefix.pch:4:
In file included from /private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:10:
In file included from /private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:11:
/private/var/easyrespring/theos/sdks/iPhoneOS8.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIBezierPath.h:12:20: error:
C++ requires a type specifier for all declarations
typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
^~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [obj/Tweak.xm.1c1f697b.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [EasyRespring.all.tweak.variables] Error 2
Im not sure a better way to post that so I'll leave a link to the ghostbin here, perhaps it is more clear?
I'm wondering if it's a problem with the SDK headers you are using, the problem seems to be with random files unrelated to your project (According to the easyrespring files on github). Try a different version of the ios 8.1 SDK if you manually downloaded it. Maybe try this one? https://github.com/MP0w/iOS-Headers
Edit:
With the downloaded 8.1 headers you would replace the existing ones in the theos/sdks/ directory. Then you can try running make in your project again to see if it works properly.

Resources