JoeHowse / iOSWithOpenCV

These are the projects for my book, iOS Application Development with OpenCV 3.
https://www.packtpub.com/application-development/ios-application-development-opencv
54 stars 18 forks source link

Cannot successfully import and use OpenCV 3 in any application but yours #4

Closed theoknock closed 7 years ago

theoknock commented 7 years ago

I'm extremely frustrated; I can't successfully import and use OpenCV 3 in any application but yours. I'm not sure why, either. I'm no slouch, but here I am...

I can't imagine you taking the time to walk me through it, but an you help me start a new project, import your build of the OpenCV framework, and then #import only the same things you did, and compile successfully?

I nearly threw my laptop across the room today; it has been such a terrible experience. I would be concerned that the only way I could successfully use OpenCV 3 is to duplicate one of your projects, and modify it into my own.

I'm sure that's not necessary; so, please, let me know what you are willing to do. Thanks!!!

theoknock commented 7 years ago

I fixed this myself; here's how for anyone who might have this same problem. It's just two simple steps:

  1. Install OpenCV2 using Cocoapods (it says '2', but it's still version 3). Don't install the 'devel' build.

  2. Open your project in the workspace Cocoapods created for you — not the project file you created — and append every implementation file that uses OpenCV with .mm (versus .m). You'll get strange error messages if you don't.

JoeHowse commented 7 years ago

Hi, @theoknock. I didn't notice this thread until now, for some reason. It sounds as if you've found a solution that's working for you, but I wanted to add a note about point [2] above:

append every implementation file that uses OpenCV with .mm (versus .m). You'll get strange error messages if you don't.

Depending on the project configuration, Xcode may rely on the file extension to give it a hint about which compiler it should use (.m -> Objective-C, .mm -> Objective-C++). If you want to compile everything as Objective-C++ (which may simplify things in a project that uses OpenCV extensively), change the Build Settings | LLVM [Version #] - Language | Compile Sources As configuration option to Objective-C++.

theoknock commented 7 years ago

Thanks for the tip; though, I'll probably leave things the way they are, primarily, because everything is working fine (as you said).

By the way, I wouldn't call my OpenCV installation a "solution" per se; I simply used CocoaPods to install it. That was it.

James 408-685-4049


From: JoeHowse notifications@github.com Sent: Wednesday, May 10, 2017 4:14:42 PM To: JoeHowse/iOSWithOpenCV Cc: James Alan Bush; Mention Subject: Re: [JoeHowse/iOSWithOpenCV] Cannot successfully import and use OpenCV 3 in any application but yours (#4)

Hi, @theoknockhttps://github.com/theoknock. I didn't notice this thread until now, for some reason. It sounds as if you've found a solution that's working for you, but I wanted to add a note about point [2] above:

append every implementation file that uses OpenCV with .mm (versus .m). You'll get strange error messages if you don't.

Depending on the project configuration, Xcode may rely on the file extension to give it a hint about which compiler it should use (.m -> Objective-C, .mm -> Objective-C++). If you want to compile everything as Objective-C++ (which may simplify things in a project that uses OpenCV extensively), change the Build Settings | LLVM [Version #] - Language | Compile Sources As configuration option to Objective-C++.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/JoeHowse/iOSWithOpenCV/issues/4#issuecomment-300638534, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABjCM2pfKvpfAVvCfn-IFQmE6Wf-Mjveks5r4kTigaJpZM4MweKM.