0

I was following a tutorial at https://riptutorial.com/opengl/example/13875/creating-opengl-4-1-with-cplusplus-and-cocoa but the project won't build. I may guess that XCode is mixing up my Cpp and Obj-C files. In Application.hpp it suggests replacing "class" with Obj-C "Class" and adding a semicolon, and in MacApp.h it can't find memory to include.

I've been struggling with it for some time, but couldn't find a solution.

Application.hpp

#include <OpenGL/gl3.h>

class Application { // Suggests "Class" and a semicolon
private:
    GLuint          program;
    GLuint          vao;
public:
    Application();
    void update();
    ~Application();

};

MacApp.h

#import <Cocoa/Cocoa.h>
#import "Application.hpp"
#import <memory> // Error here

NSApplication* application;

@interface MacApp : NSWindow <NSApplicationDelegate>{
    std::shared_ptr<Application> appInstance;
}
@property (nonatomic, retain) NSOpenGLView* glView;
-(void) drawLoop:(NSTimer*) timer;
@end

UPD: changing Cpp standard library from libstdc++ to libc++(LLVM...) and moving app pointer into the main.m file fixed the problem

nazzrrg
  • 3
  • 2
  • Give the file you are compiling (which you don't show here) a `.mm` suffix. – Paul Sanders May 22 '20 at 21:50
  • @PaulSanders, already tried it, made no difference. The code in Obj-C is meant to be a wrapper around Cpp, so this shouldn't be an issue anyway. – nazzrrg May 22 '20 at 21:56
  • See: https://stackoverflow.com/questions/2683101/how-can-i-use-c-with-objective-c-in-xcode – Paul Sanders May 22 '20 at 21:57
  • @PaulSanders it apparently was not the case and further dive into different std libs fixed the problem, did change the extension though, thanks! – nazzrrg May 22 '20 at 22:12

0 Answers0