I tried using the Glew Library for shading and was trying to compile a simple program using the NSOpenGLView Class in Xcode 5. The program fails at the following code in glew.h
#if defined(__gltypes_h_)
#error gltypes.h included before glew.h
#endif
It says that Gltypes.h is included before glew.h.
My implementation file for OpenGLView has headers included in following fashion:
#include <glew.h>
#import "OpenGLView.h" // Includes Cocoa.h
#include "LoadShaders.h" // Includes <OpenGL/gl.h>
So, if glew.h is included in the beginning, why is the error coming here. None of the other headers are included before the inclusion of glew.h, so tests for them(like gl.h) are passing in glew.h. I am not able to find out here as to who is including Gltypes.h in this file.
Hope anyone has a clue to it here.
The precompiled header file (.pch) pulls Cocoa in. Edit it to include glew.h before Cocoa.h and you are good to go.
Related
thanks in advance for the help you will give me.
I have searched this for half a day over the internet yesterday and two hours now and I haven't found anything (more than those two links that did not help FMDatabase.h not found when using route-me library & Failed to emit precompiled header for bridging header)
So here is my problem : I just had in hands a project that a previous developer has been working on, and when I try to launch it, here I have two errors :
failed to emit precompiled header
'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch'
for bridging header
'/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'
/Users/me/Downloads/Alavoc-ios-master/Alavoc/externalLib/customClass/customClassViewController.h:13:9:
error: 'FMDB/FMDB.h' file not found
There is also one fatal error wroten like this (even if I only have two errors counted, this one appears in the log above the two other ones previously described)
fatal error: module file
'/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/30E4RG2TSVLXF/Foundation-3DFYNEBRQSXST.pcm'
is out of date and needs to be rebuilt: signature mismatch note:
imported by
'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch'
/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13:9:
note: in file included from
/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:13:
#import "customClassViewController.h"
customClassViewController.h line 13 :
#import <FMDB/FMDB.h>
I guess those errors are linked. Do you have any idea where it could come from ?
Thanks in advance for your help guys, I really appreciate it!
Edit for battlmonster (new errors) :
Here are the two errros (file not found (in Alavoc-Bridging-Header.h FMDB.h not found)) and failed to emit precompiled header :
fatal error: file
'/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'
has been modified since the precompiled header
'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch'
was built note: please rebuild precompiled header
'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch'
/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h:29:9:
error: 'FMDB/FMDB.h' file not found
import
^ 1 error generated. <unknown>:0: error: failed to emit precompiled header
'/Users/me/Library/Developer/Xcode/DerivedData/Alavoc-arfzuirebtfstncdztyvgvtpcbgw/Build/Intermediates.noindex/PrecompiledHeaders/Alavoc-Bridging-Header-swift_1I75NH5N40QPS-clang_30E4RG2TSVLXF.pch'
for bridging header
'/Users/me/Downloads/Alavoc-ios-master/Alavoc/bridge/Alavoc-Bridging-Header.h'
This error is about a malformed bridging header. The bridging header is a special header file which lists all Objective-C header files with classes that must be accessible from Swift code. All the bridging header definitions are precompiled in a way to be ready to use from Swift. In your case the bridging header is "Alavoc/bridge/Alavoc-Bridging-Header.h", and it includes a header for customClassViewController.h (from Alavoc/externalLib/customClass), which indicates that your fellow developer wants that customClassViewController is accessible in Swift code.
Now the confusing thing about the bridging header is that it is not recursively including everything, i.e. it just looks on the first level of definitions, and if you import something in your import that you want in Swift, you have to add it to the bridging header explicitly, or else you'll probably get a warning (or an error sometimes). Say you have #import "A.h" in the bridging header, and you have #import "B.h" inside "A.h", then you likely would have to add "B.h" to the bridging header as well.
Now in your example A = customClassViewController, and B = FMDB, and normally you would need to add FMDB to the bridging header, but the thing is that you most likely don't want exporting FMDB to Swift via your bridging header, because it is not meant for this (it is for your own objc code and not for 3rd party libs).
The solution would be to remove line 13 from your "customClassViewController.h". This would likely fix the bridging header compilation, but probably break the customClassViewController, so you need to include FMDB in "customClassViewController.m" and most likely adapt the "customClassViewController.h" to not have anything related to FMDB (or forward-declare those usages with #class X;).
If you move #import <FMDB/FMDB.h> to your implementation (.m) files and still get error: 'FMDB/FMDB.h' file not found, it is likely about FMDB path not being listed in your header search paths.
To solve the last one just include the right path in your "Header Search Paths" in Xcode build settings. Let's say FMDB is located at /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB (and you have /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD/FMDB/FMDB.h inside), Then you need to open Xcode project settings - select your target on the left - select "Build Settings" on the top - find "Header Search Paths" setting and add /Users/me/Downloads/Alavoc-ios-master/Alavoc/ASDASD path
If you are using cocoapod and it is a framework, suggesting you NOT to include this in pre-compiled header.
Instead, objc files, use:
#import framework_name;
I'm having an issue with the visibility of header files in my Windows Forms project (Visual Studio 2017). I've included all header files in separate header file called "Header.h". In the first file called "welcome.h", I want to call the next form as shown below...
beta::initial^ f = gcnew beta::initial();
this->Hide();
f->Show();
This is what I'm getting when I'm trying to compile it...
That doesn't actually makes sense to me since initial is the member of beta as shown in this screenshot...
This is how I include my header files in Header.h...
#include <algorithm>
#include "initial.h"
#include "welcome.h"
Every other header file contains...
#include "Header.h"
I also checked if every file is sure to be included in the project and everything is in the same folder. What am I missing?
P.S. This is my first time posting here, so if my question isn't clear, then please guide me.
I just put an answer here:
Style messed up after nuget update.
I searched for this question and could not find much help.
Error:
could not build module 'Foundation'
#import <Foundation/Foundation.h>
What is the problem?
I was able to solve this using the solution provided in this Apple Support Communities thread:
The real problem here is at Build Settings in the session: Apple LLVM 5.0 - Language - Modules, we should set Enable Modules (C and Objective C) to NO
The suggested fix to set Enable Modules (C and Objective-C) did not solve this issue for me.
What did is renaming my someFile.c files to someFile.m. Even though those files contain just C functions (that do use Foundation types), naming them .c produces this error.
I found that if you use some external C / C++ code in your project, you have to remove all the #import in the prefix. That's quite a headache, but it's a true problem.
Cmd + Option + Shift + K and then Cmd + Option + K solved above error for me.
In my case I had a Precompiled Header where I had includes that included <Foundation/Foundation.h> The solution for me was to wrap the include in a
#ifdef __OBJC__
#include SomeIncludeWithFoundation.h
#endif
You may also see in your .pch files something like:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
Be sure your modules are included in the right place in your Precompiled Header
None of the given solutions worked for me.
I have a project with mixed source codes (C and Objective-C) and the problem was given by a .c which included a shared .h which in turn included the Foundation header:
#import <Foundation/Foundation.h>
In order to solve the problem I had to perform the following steps:
In the .c that was causing the problem add as first include/import statement: #import <Foundation/Foundation.h> You can keep the same import statement in the shared header if you need.
In the project settings select the entry under Targets then click
on Build Phases -> Compile Sources. In the Compiler Flags
add -x objective-c. This will force the compilation of the C source code as Objective-C to allow the linking with the Foundation framework and since Objective-C can embed C source code this is perfectly legal.
In the project settings select the entry under Targets then click on Build Phases -> Link Binary With Libraries. Add the Foundation.framework library in the list.
You can try this:
In your .pch file, write like this:
#ifndef PureStandard_PrefixHeader_pch
#define PureStandard_PrefixHeader_pch
#ifdef __OBJC__
#import "A.h"
#import "B.h"
#endif
#endif
I have resolved by change Build System to Legacy Build System
Open the ios/PROJECT_NAME.workspace file
Then in the top menu, select File → Workspace Settings
Then change Build System to Legacy Build System
From this answer:
Set Allow Non-modular Includes in Framework Modules to YES in target's Build Settings
I was seeing the issue on this line in a .m file that is being built as part of an extension:
#import <Foundation/Foundation.h>
So I had the same problem, but the errors would for some reason not cause the build to fail, so they were like fake errors, and I made them go away by quitting Xcode, and deleting ~/Library/Developer/Xcode/DerivedData/ProjectName
Just rename your Objective-C++ file from *.c to *.mm.
The errors are gone that way. It handles all the imports just fine this way.
Use the following:
Cmd + Alt + Shift + K and then Cmd + Alt + K
Menu File → Workspace Settings → Legacy Build System
Cmd + B
It works for me.
So I found Apples great sample called GL3 Text.(LINK) Seems to be doing exactly what I need using included libraries.
I imported the toolkit folder from the sample as it contains everything I need to make it work.
In order to declare a variable type I need, as well as use some methods they had setup in the sample, I need to import OpenGLText.h in my openglview class.
Problem is, when I do this another file from the sample, OpenGLContainers.h, gets errors on these 3 lines
#import <map>
#import <string>
#import <vector>
The error says, for example, "'map' file not found."
If I take out the OpenGLText.h import line, everything compiles fine and I'm able to right click -> jump to definition, on those 3 lines that previously had errors.
I've already double checked that I'm includeing the frameworks they use in the sample. Cocoa, OpenGL, and GLKit.
Any ideas on how to fix this? Seems like theres something conflicting with the imports.
If you don't know how to fix, but have suggestions on other simple ways to render text on an opengl surface on Mac let me know!
Have you tried the advice in the stack overflow posts below?
.h file not found
XCode - #include <map> in ml.hpp : No such file or directory
Lexical or Preprocessor Issue with "#import <map>
Best Regards,
Magnus
Those are C++ headers. You have to compile the sources using those headers as C++ or Objective-C++.
I am new at IPHone development , I included a library with .cxx as implementation class and a .h header but still i get error at compiling , Please any help?
I get errors at lines like below
class StackEvent;
The Objective-C class that is including any C or C++ code must be renamed with a ".mm" suffix rather than ".m" in the implementation class.
Any Objective-C file (.m) that includes any header containing C++ code, either directly or by chained #includes, will likely fail with compile errors.
You need to rename all your .m files to .mm if they can "see" your C++ header.
If that causes too much renaming, then you'll have to limit your #includes, for example by take the C++ #include out of your header file and putting it only in the .mm files that need it.