GPUImage build error - gpuimage

I am trying to use GPUImage, already add the target and build successfully, but when I use it in the viewController and build, there are some problem I can't understand. Anyone know why? Thank you very much.
The code:
UIImage *inputImage = [UIImage imageNamed:#"1"];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init];
[stillImageSource addTarget:stillImageFilter];
[stillImageSource processImage];
UIImage *currentFilteredVideoFrame = [stillImageFilter imageFromCurrentlyProcessedOutput];
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(60, 60, 200, 300)];
image.image = currentFilteredVideoFrame;
[self.view addSubview:image];
[image release];
The error:
ld: warning: ignoring file /Users/xiaodong/Library/Developer/Xcode/DerivedData/SilentGif-cuagrzcstwdoemeamjiufacggbfa/Build/Products/Debug-iphonesimulator/libGPUImage.a, file was built for archive which is not the architecture being linked (x86_64): /Users/xiaodong/Library/Developer/Xcode/DerivedData/SilentGif-cuagrzcstwdoemeamjiufacggbfa/Build/Products/Debug-iphonesimulator/libGPUImage.a
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GPUImageSepiaFilter", referenced from:
objc-class-ref in ThirdViewController-5FAAC33C6210C63D.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

You can change Architecture from Standard architectures to Standard architectures (including 64-bit) in GPUImage.xcodeproj like this.
This is a capability issue, see this.

Related

OpenGL EGL eglGetDisplay keeps return EGL error 0x3008(EGL_BAD_DISPLAY )

My ubuntu version is 16.04, and I first installed mesa-common-dev, libgl1-mesa-dev, libglm-dev, libegl1-mesa-dev. Then I installed NVIDIA-Linux-x86_64-440.64.run with opengl support.
But when I tried to run a toy example, I keep getting this error main: Assertion display != EGL_NO_DISPLAY failed
/* Compile with gcc -g3 -o example example.c -lX11 -lEGL */
#include <assert.h>
#include <stdio.h>
#include <EGL/egl.h>
#include <EGL/eglplatform.h>
void printEGLError();
int main(void) {
Display* x_display = XOpenDisplay(NULL);
EGLDisplay display = eglGetDisplay(x_display);
// EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert(display != EGL_NO_DISPLAY);
EGLint major, minor;
eglInitialize(display, &major, &minor);
char *string = eglQueryString(display, EGL_CLIENT_APIS);
assert(string);
printf("%s\n", string);
return 0;
}
/* Use printEGLError to show a description of the last EGL Error.
The descriptions are taken from the eglGetError manual */
#define ERROR_DESC(...) fprintf(stderr, "%s\n", __VA_ARGS__); break
void printEGLError() {
switch(eglGetError()) {
case(EGL_SUCCESS):
ERROR_DESC("The last function succeeded without error.");
case(EGL_NOT_INITIALIZED):
ERROR_DESC("EGL is not initialized, or could not be initialized, for the specified EGL display connection.");
case(EGL_BAD_ACCESS):
ERROR_DESC("EGL cannot access a requested resource (for example a context is bound in another thread).");
case(EGL_BAD_ALLOC):
ERROR_DESC("EGL failed to allocate resources for the requested operation.");
case(EGL_BAD_ATTRIBUTE):
ERROR_DESC("An unrecognized attribute or attribute value was passed in the attribute list.");
case(EGL_BAD_CONTEXT):
ERROR_DESC("An EGLContext argument does not name a valid EGL rendering context.");
case(EGL_BAD_CONFIG):
ERROR_DESC("An EGLConfig argument does not name a valid EGL frame buffer configuration.");
case(EGL_BAD_CURRENT_SURFACE):
ERROR_DESC("The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid.");
case(EGL_BAD_DISPLAY):
ERROR_DESC("An EGLDisplay argument does not name a valid EGL display connection.");
case(EGL_BAD_SURFACE):
ERROR_DESC("An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering.");
case(EGL_BAD_MATCH):
ERROR_DESC("Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface).");
case(EGL_BAD_PARAMETER):
ERROR_DESC("One or more argument values are invalid.");
case(EGL_BAD_NATIVE_PIXMAP):
ERROR_DESC("A NativePixmapType argument does not refer to a valid native pixmap.");
case(EGL_BAD_NATIVE_WINDOW):
ERROR_DESC("A NativeWindowType argument does not refer to a valid native window.");
case(EGL_CONTEXT_LOST):
ERROR_DESC("A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering. ");
}
}
More Information: my graphics card is Titan Xp and I tried to run sudo servide lightdm stop and removed all possible remote desktop softwares. But the problem still exists. Anyone could help?
For those who may be confused about this problem, just unset DISPLAY. This may save your day.

Qt: Why does my custom qgraphicsview widget create error during compiling on Linux?

My Qt project compiled successfully on Windows, but when I was trying to compile it on Linux it gives me all kinds of errors including the one I'm asking here:
I have a custom QGraphicsView class in my project, and it's prompted from the Qt designer. When I compiled my codes on a Linux machine, it gives me errors:
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:55: error: ISO C++ forbids declaration of ‘myGraphicsView’ with no type
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:55: error: expected ‘;’ before ‘*’ token
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h: In member function ‘void Ui_GTvalidation::setupUi(QDialog*)’:
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: ‘graphicsView’ was not declared in this scope
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: expected type-specifier before ‘myGraphicsView’
/usr/mvl1/hy2vf/metaData/bin/ui_gtvalidation.h:173: error: expected ‘;’ before ‘myGraphicsView’
Does anyone have had same issues? What's the solution?
Here is the part in ui_gtvalidation.h where it says the problems are. I'm actually not sure what part of my codes I should post to help, so let me know what you want to look at.
55:myGraphicsView *graphicsView;
173:graphicsView = new myGraphicsView(GTvalidation);
graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
myGraphicsView.h
#include <QtGui>
class myGraphicsView : public QGraphicsView{
public:
myGraphicsView(QWidget* parent = 0);
~myGraphicsView(void);
protected:
//Take over the interaction
virtual void wheelEvent(QWheelEvent* event);
};
myGraphicsView.cpp:
#include "myGraphicsView.h"
myGraphicsView::myGraphicsView(QWidget *parent) : QGraphicsView(parent){
}
myGraphicsView::~myGraphicsView(void){
}
void myGraphicsView::wheelEvent(QWheelEvent* event) {
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
// Scale the view / do the zoom
double scaleFactor = 1.15;
if(event->delta() > 0) {
// Zoom in
scale(scaleFactor, scaleFactor);
} else {
// Zooming out
scale(1.0 / scaleFactor, 1.0 / scaleFactor);
}
// Don't call superclass handler here
// as wheel is normally used for moving scrollbars
}
Your problem is actually in your gtvalidation.ui file. When you promote a widget to custom class, you need to specify include header correctly. For some reason compiler cannot find specified header in Linux. The most simple reason of this could be capitalization mismatch (as Linux filesystems are case sensitive and Windows ones are not). Check header files specified in promotion settings of your form in Designer.

How to save the contents of a COM object to a file Visual C++

I'm working my way through a DirectX11 tutorial and one of the "extra credit" exercises is to compile a shader and save the compiled code to a .shader file.
The program I ended up writing is super simple so I'll just list it here instead of explaining it in English.
The main program:
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dx10.h>
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
#pragma comment (lib, "d3dx10.lib")
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
ID3D10Blob *VS, *Errors;
D3DX11CompileFromFile(L"shaders.shader", 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VS, &Errors, 0);
if(Errors)
MessageBox(NULL, L"The vertex shader failed to compile.", L"Error", MB_OK);
else if(!Errors)
MessageBox(NULL, L"The vertex shader compiled successfully.", L"Message", MB_OK);
HANDLE sHandle = CreateFile(L"compiledShader.shader",
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(WriteFile(sHandle, VS->GetBufferPointer(), VS->GetBufferSize(), NULL, NULL)) // <--- break point
MessageBox(NULL, L"The compiled shader was saved successfully to 'compiledSahder.shader'", L"Message", MB_OK);
else
MessageBox(NULL, L"The vertex shader was not saved successfull.", L"Error", MB_OK);
return 0;
}
And the shader:
float4 VShader(float4 position : POSITION) : SV_POSITION
{
return position;
}
Since the contents of the VS Blob is where the compiled code is my first instinct is that I need to save the contents of that Blob to a .shader file. The only file writing I've worked with before is using fstream in basic C++ in linux so I'm unsure how to approach this. I've dug through the MSDN library for various file writing functions but I couldn't find anything that would let me write the content of a COM object to a file.
Let me know if you need any more information, and thanks in advanced for your help.
EDIT: the code has been updated per the suggestions of the current answer. I'm not 100% sure if I'm using these functions properly as I had to intuit how to by reading their descriptions on MSDN, but I think I'm on the right track. It creates the file, but when I try to write to it I'm getting the following error:
First-chance exception at 0x755cdeef in shader compiler.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x755cdeef in shader compiler.exe: 0xC0000005: Access violation writing location 0x00000000.
The program '[5604] shader compiler.exe: Native' has exited with code -1073741819 (0xc0000005).
I feel like it's a simple mistake that is causing this problem. Any ideas?
EDIT #2: Here is what gets written to the file "compiledShader.shader"
Compiled shader code?
Does this look correct? If so I'll close the question as answered and worry about whatever is causing the generic access error on my own.
Look at the ID3D10Blob interface for the content, and check the CreateFile, WriteFile and CloseHandle Win32 functions.

Warning C4278: 'GetCurrentDirectory': identifier in type library 'GCRComp.tlb' is already a macro; use the 'rename' qualifier

I'm migrating a VC++ 6.0 application to Visual studio 2008. I've fixed all the migration errors, now I'm fixing the warnings. The following warning occurs in almost 40 instances, Even after so much trial and errors and research in google, I'm not able to fix this warning.
Please find below an instance of the C42778 Error, If I get some help to fix the one below, I'll follow the same approach to fix the remaning 39 warnings.
Warning C4278: 'GetCurrentDirectory': identifier in type library 'GCRComp.tlb' is already a macro; use the 'rename' qualifier
------Code snippet from ZipFile1.h -------
#import "GCRCOmp.tlb" rename_namespace("GCRTools") // C42778
------Code snippet from gcrcomp.tlh -------
Virtual HRESULT __stdcall raw_GetCurrentDirectory {
/*[out]*/ BSTR * dirname,
/*[out, retval]*/ VARIANT_BOOL * okStatus)=0;
virtual HRESULT __stdcall get_currentDirectory {
/*[out, retval]*/ BSTR * pVal)=0;
__declspec(property(get=GetcurrentDirectory))
_bstr_t currentDirectory;
VARIANT_BOOL GetCurrentDirectory (
BSTR * dirname);
_bstr_t GetcurrentDirectory ();
------Code snippet from gcrcomp.tli-------
inline VARIANT_BOOL IFtp1::GetCurrentDirectory(BSTR * dirname){
VARIANT_BOOL _result = 0;
HRESULT _hr = raw_GetCurrentDirectory(dirname, &_result);
if(FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _result;
}
inline _bstr_t IFtp1::GetCurrentDirectory(){
BSTR _result = 0;
HRESULT _hr = get_currentDirectory(&_result);
if (FAILED(_hr) _com_issue_errorex(_hr, this, __uuidof(this));
return _bstr_t(result, false);
}
Any help to fix this warning is greatly appreciated. Thanks a lot in advance!
It because GetCurrentDirectory is already defined in Windows SDK. It is a part of ANSI/Unicode API conversion. The way to fix is undefined it before import GCRCOmp.tlb. Try this:
#pragma push_macro("GetCurrentDirectory")
#undef GetCurrentDirectory
#import "GCRCOmp.tlb" rename_namespace("GCRTools")
#pragma pop_macro("GetCurrentDirectory")

Problem with UICustomSwitch,

I am using UICsutomSwitch for my application. When I try to create it, I am getting an exception like,
Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSArray objectAtIndex:]: index 2 beyond bounds for empty array'
My code is as follows,
UICustomSwitch.h
#import <Foundation/Foundation.h>
#interface UICustomSwitch : UISwitch
{
}
-(void)setLeftLabelText:(NSString *)labelText;
-(void)setRightLabelText:(NSString *)labelText;
#end
UICustomSwich.m
#import "UICustomSwitch.h"
#implementation UICustomSwitch
-(UIView *)slider
{
return [[self subviews ] lastObject];
}
-(UIView *)textHolder
{
return [[[self slider] subviews]objectAtIndex:2];
}
-(UILabel *)leftLabel
{
return [[[self textHolder] subviews]objectAtIndex:0];
}
-(UILabel *)rightLabel
{
return [[[self textHolder] subviews]objectAtIndex:1];
}
-(void)setLeftLabelText:(NSString *)labelText;
{
[[self leftLabel] setText:labelText];
}
-(void)setRightLabelText:(NSString *)labelText
{
[[self rightLabel]setText:labelText];
}
#end
View Controller:
UICustomSwitch* switchView=[[[UICustomSwitch alloc]initWithFrame:CGRectMake(200,5,90,30)]autorelease];
[switchView setLeftLabelText:#"F"];
[switchView setRightLabelText:#"M"];
[switchView addTarget:self action:#selector(genderAction:) forControlEvents:UIControlEventValueChanged];
[elementView addSubview:switchView];
I am getting exception at " return [[[self slider] subviews]objectAtIndex:2];" call. I don't know what is the wrong, Can you guys please suggest me on this.
Thanks in advance,
Sekhar.
I ran across this issue and found the answer here:Custom UISwitch Text
Basically in iOS 4, there were UILabel's in the UISwitch's subviews that represented the "On/Off" labels. In iOS 5, there are no UILabels in the subviews array (hence the array error you're getting). The above link offers an external class you can download and customize. In my opinion, it seems like Apple is discouraging customization of UISwitch. The functionality you're after could be accomplished another way (segmented control, simulated checkbox, etc).
Also, in the given link above, the author proposes that the issue might be with not including armv6. I tried this and it does not fix the problem.
The exception indicates you are attempting to access an element of the array that is out of bounds (in a place that is larger than the actual size of the array).
You can use breakpoints and/or NSLog() calls carefully placed in your code to determine if this array ever is not-empty, and if that is so, you can continue to use these calls to find out just where the array becomes empty.
Clearly if the array is empty then the switch is setup differently than you expect it to be.

Resources