Xcode framework no longer found after second build - c++

Since I upgraded to Xcode 11 every new project I start that includes a framework can be no longer be compiled after the second build of the project.
For example including SDL2 using this command:
#include <SDL2/SDL.h>
will result in this error:
'SDL2/SDL.h' file not found
after the project has been compiled a second time.
Projects that have been created in Xcode 10 work normal in Xcode 11.
I tried changing the embedding options of the frameworks but no setting works. This error occurs in all Xcode 11 versions (0 - 2.1).
I am using macOS Version 10.14.6.
Why does this happen or how can this be fixed?

I hade the same problem with XCode 11.1. What I found out was that I needed to add the Header Search Path in Build Settings/Search Paths to:
/Library/Frameworks/SDL2.framework/Versions/A/Headers
And then it worked. It looks like the path is changed.

I finally found a solution. I added the frameworks with the menu in this screenshot to my project:
In Xcode 9 and 10 this did the same as adding the framework using this menu:
But now in Xcode 11 this isn't the same anymore. Adding the framework using the first menu will copy the framework from it's original path into the build folder of the project but for some reason Xcode does not copy the Headers folder in the framework. I think this is a bug but it seems like they haven't fixed it up to Xcode version 11.2.1 at least.
So now the solution to this problem is adding the framework using the Build Phases menu in the second picture.

SDL2 isn't a framework. Rather it is either a static or dynamic lib. Unless of course you are using some other custom made framework for SDL2.
There are two scenarios you would typically encounter:
SDL2 installed in the default location such as /usr/local
SDL2 installed in a custom place (which is how I do it)
I am guessing you are doing the former. If this is the case, it is possible that with Xcode 11 the default system header search path has somehow changed to not include /usr/local (or where you have installed it).
To fix this, you should first locate your SDL2 library. In particular where the include files are.
Then in Build Settings, go to Search Paths:System Header Search Paths and enter that path in.
Keep in mind the #include is using SDL2 as part of the path, so you do not want to put the SDL2 part in the path. Here is an example of my directory structure. So my path entry for this is $(PROJECT_DIR)/3rdParty/SDL2/include. You can see in my project directory, I have a 3rdParty directory which I use to hold the 3rd Party libs I integrate into the project.
You're using angled brackets for inclusion, which utilizes the system path.
Note you also may have to do update how you link against SDL2 (ie. it may not be able to find it).

Related

How can Codeblocks find my header files even without adding any search paths

I'm learning to use OpenCV (and C++) in Codeblocks. What confuses me, however, is that when I start to include header files from OpenCV in my main.cpp file, Codeblocks automatically suggests to me the files as shown in the image below.
I have not included any search paths to project build options, so how is this possible that Codeblocks can find the files? Is there some other variable working here that I'm unaware of?
Note that I'm a beginner with both Codeblocks and OpenCV and that I only have a little experience with C++.
Thank you
Of course when you install an IDE like code::blocks by default, it knows about standard path for library on your OS.
On my OS -> Ubuntu that is /usr/include
It only searches on a standard path, except you add one. If you install your library by command-line, it goes to the standard place, if you installed manually, then it depends on your option you added to installation. I can not see you screen-shot but it has access to /usr/include by default.
For more detail on Linux and OpenCV
And here is a screen-shot of codeblock on Ubuntu that I added some 3rd-party library
NOTE:
if you install any libraries by command-line, just use it.
But if you have installed them manually, you need to add 2 things to codeblock.
1. First is your path for header file
2. Second is your path for linker
And you see it in screen-shot that say: Search Directory
First is for header and second is for linker

Where is the lib folder (or its replacement) in the current OpenCV?

I'm following a book written for the older version of OpenCV (OpenCV 2 Computer Vision, by PACT) and it tells me to include the lib folder in my Visual Studio 2013 Property Manager when creating a new property sheet.
I don't see a directory called lib in the current GitHub version (opencv-master, which is OpenCV 3.1.x). Has this folder been replaced by something else?
I built OpenCV with cmake. I found a 4 year old unanswered question wherein someone was also looking for this folder. They tried building the library from another directory that no longer exists, but that didn't work for them anyway...
Another OpenCV user just told me that GitHub doesn't include the libraries, so you have to cmake them locally. I'm still not clear on where / how I can cmake them.
I realize the pre-built binaries have this, but I'm avoiding them because I need the SURF functions in opencv_contrib, so I needed to build it from source.
The pre-built binaries will have a library folder in the corresponding path
Local System Path(Opencv Folder)-> build->x64/x86->vc10/vc11/vc12->lib.
As you mentioned that you don't wish to use it then the only option left for you is to build it locally which is a much better option if you plan to use Opencv libraries for varied functions and projects as it resolves many build errors that you might face later.
I used the Cmake Graphical user interface to build opencv, following are the steps I followed to successfully build the libraries on my system .
So, you would need to create a new folder that will contain all
the Makefiles generated.
Please refer to this image for clearer understanding:
In GUI you define source directory path where OpenCVConfig.cmake is present, according to your image it's the
current folder in your image opencv-master.
Similarly, define the path to the new directory you created where all the build files would be stored.
Make sure to uncheck Build_Examples to avoid configuration errors.
Then click Configure at the bottom when configuring is done .(you may need to configure it twice)
After click the tab adjacent to configure, Generate to create the solution file.It will ask you for the compiler name
select the
compiler installed on your system from the list of choices. After
generation is done.
Go to this path Build_New_Directory(the directory you created) you will find OpenCV.sln build this project, it will take around 10-15 minutes depending on your processor, wait patiently .If you get a build error at this point don't invest your time in debugging on Visual Studio go back to Cmake GUi and configure it again and this time give the path to dependent libraries on your system that it could not find .Repeat the process it should be successfully build now.
After it is successfully build you can now locate the path of all opencv libraries build on your system as follows.
Build_New_Directory(the directory you created)->
install->x64->vc10(compiler I used)->lib.
As an update to Nikita's awnser:
There is a cmake build bug where the x64 folder will not be created if OpenCV_RUNTIME is not set. This will happen if you build an old OpenCV (e.g. <= 3.2.0) with a newer Visual Studio Version than was available at that time (e.g. Visual Studio 2017)
To fix this, add the correct MSVC_VERSION elseif-cases in both ./cmake/OpenCVDetectCXXCompiler.cmake and the ./cmake/templates/OpenCVConfig.root-WIN32.cmake.in (or ./cmake/OpenCVConfig.cmake in < v3.2.0) files:
[...]
elseif(MSVC_VERSION EQUAL 1900)
set(OpenCV_RUNTIME vc14)
# old version ends here with endif()
elseif(MSVC_VERSION GREATER 1909 AND MSVC_VERSION LESS 1920)
set(OpenCV_RUNTIME vc15)
elseif(MSVC_VERSION GREATER 1919 AND MSVC_VERSION LESS 1930)
set(OpenCV_RUNTIME vc16)
endif()
[...]

Installing OpenCV 3 on Mac OS X as a framework

I wanted to make an app on OS X El Capitan using OpenCV. I decided to use the latest version, version 3.0.0 released on June 4th, 2015. I had installed version 2.4.x using brew, but since version 3 now has a build script for osx that builds a framework, I wanted to use that method.
After downloading version 3 from the OpenCV.org, I opened a terminal window in the opencv-3.0.0 directory and executed the build_framework.py script as follows:
platforms/osx/build_framework.py osx
(The osx argument tells the script to make a directory named osx to output the framework there)
Everything built without a hitch so I then added the framework built in the osx directory to my project.
Much to my surprise my project would not build without errors. First of all were the two following problems. Here is a screenshot of the first:
If the first problem did not show up, the #ifndef __cplusplus # error for each header file in the opencv2.framework would get triggered.
It turns out that problem was that the C++ headers need to be called before the Objective-C headers, so I added the following to a PCH file to the project:
You can actually add this code to the header file that need the opencv.hpp header file instead of make a PCH file for the project. You should also be sure to say #include and not #import, but they should both work.
Once I figured out those problems I was still stuck with 39 undefined symbols for architecture x86_64.
At first I thought the framework was not including the x86_64 versions, but a quick check revealed that it included both i386 and x86_64 versions of the object files and that my Project settings were all correct.
Next I looked up the names of some of the undefined symbols and found that they were part of a project named OpenCL. OpenCL is supposed to accelerate some of the functions and was included in opencv3. At first I thought that the module was not getting built, but after reading through the build_framework.py build script I found that it was getting its settings from the CMakeLists.txt file. Reading this showed that following OpenCL flags:
WITH_OPENCL
WITH_OPENCLAMDFFT
WITH_OPENCLAMDBLAS
were being set
A little more reading lead me to believe that Mac OS X El Capitan is not compatible with OpenCL, as it appears there needs to be kernel support. So I changed the CMakeLists.txt file to not build OpenCL by adding "AND NOT APPLE"
WITH_OPENCL
WITH_OPENCLAMDFFT
WITH_OPENCLAMDBLAS
After the changes to the CMakeLists.txt file and building the framework again, my program was able to link with opencv2.framework (not sure why they still call it opencv2 instead of opencv3) and run.
It took me more time than I would like to admit, so I thought I would share my experience here in the hopes that it save someone else all the frustration getting OpenCV 3 working with their Mac OS X app. Cheers!
After nearly 2 years, I encountered the same problem. However, I found a more decent solution.
Contrary to your thought, macOS actually is compatible with OpenCL, although it is not linked into the OpenCV2.framework. I tried to link my binary with liblapack.tbd, libcblas.tbd and OpenCL.framework before I link opencv2.framework and it works like a charm.
So just go to the Project Settings -> Build Phases -> Link Binary With Libraries and add the following:
Link Binary With Libraries section

Adding boost library to cocos2d-x project in xcode?

I've stumbled upon a problem trying to build a cross-platform app using cocos2d-x. Currently I'm trying to build for Mac OSX. I've tried linking to the boost header files but I keep getting errors stating boost/shared_ptr.hpp cannot be found. I'm only using the smart pointer headers.
I've added the root boost directory to Header Search Paths: $(SRCROOT)/../../boost_1_55_0 (non-recursive)
and the libs directory to Library Search Paths: $(SRCROOT)/../../boost_1_55_0/libs (non-recursive)
I tried this for both the root project file and cocos2d_libs project file with no good results.
I also tried adding to User Header Search Paths.
I've added them successfully on an SFML project, so does cocos2d-x bypass these search paths?
Thanks to anyone who is willing to help me!
Probably you have missed some step in your setup. Have a double check on every detail as you can go through these guidelines:
Porting a Cocos2d-x iOS game to Android
How to create a multi-platform project in one command line
This should help, as attention to detail if worthwhile.
I never figured out the problem, but I realise now that there's no need to even use boost. Cocos2d-x is compatible with C++11. What a relief.
Since XCode builds Cocos2DX projects for Mac and iOS you need to setup header search paths independently. Just switch target in XCode from iOS to Mac and set path to Boost for Mac build. Should work.

NetBeans with C++ and OpenGL / Freeglut under Windows 7

I recently tried to figure out how to use freeglut with NetBeans 7.
I Google'd a lot and I didn't find a suitable tutorial on how to bind the stuff I need into it.
Currently I have more problem then this:
First one is:
- freeglut 2.8 => in order to compile it I need MinGW and msys.
I have both installed but I can't "configure" or "make all" and "make install" freeglut.
I didn't find an easy-to-read how-to for that task.
Next one:
- once built, where to put what files into a specific folder?
Last one:
- Once put the files into corresponding folder, how to use finally freeglut under NetBeans 7 on a C++ project?
I feel like a lack of information on that.
All I found are always answers like:
download, build, install and done. But I'm already stuck on the "install" and "build".
The solution:
Close NetBeans.
Install and download MinGW from mingw.org
After installing, add the Path to your SystemEnvironemt (example: C:\MinGW).
go to Start->Computer, right mousebutton, select properties
go to advanced system setting, in the following dialog press "Environment Variables".
in the tab "system variables", find the entry Path (or PATH)
add: C:\MinGW;
get freeglut pre-compiled package:
(http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/)
there is a good tutorial how to set up.
Now have fun (just #include " and you're done.
have fun.
Note #1:
if you have problems finding make, the folder is:
C:\MinGW\msys\1.0\bin\make.exe
(when installed MinGW on C:\MinGW).
"mingw-get install msys" in command line should get msys...
last but not least dont forget to add msys\bin to path, too. :)
here's a full tutorial, but in german language.
http://techchan.blog.de/2012/03/18/einrichten-opengl-netbeans-7-1-1-teil-0-start-13209096/
If you need it in english, let me know if you could translate it ;) otherwise i'll think about to translate it myself.
I had a difficult time getting glut working in Netbeans on Windows 7 until I found freeglut, I attributed this to the fact that glut is just very out of date and so are the tutorials I found.
Maybe this will help others looking for instructions on using freeglut in Netbeans. These instructions are like the ones in the link already provided, but help explain how to use it in Netbeans rather than from the command line. This tutorial expects that you've already gotten Netbeans and your compiler working together. IF you have not done so, I found the guide here very helpful: http://netbeans.org/community/releases/68/cpp-setup-instructions.html#mingw
download and extract freeglut from http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ into an easy to reach folder. (I recommend C:/FrGlut)
either add the bin folder (C:\FrGlut\bin) to your Windows PATH variable, or copy the freeglut.dll from your bin folder into C:\Windows\System32
Open Netbeans and open or create your project
go to: file->project properties
Select your compiler, go to include directories, and add the path to your freeglut include folder (C:\FrGlut\include)
under linker, select add libary, and navigate to the file C:\FrGlut\lib\libfreeglut.a
select options and add the following individually:
-dynamic -lfreeglut -lopengl32 -LC:\FrGlut\lib\libfreeglut.a
Netbeans should now be ready to use with your freeglut library.
To use the glut libary add the following include to your source:
#include <GL/glut.h>
Remember that freeglut.dll will need to be shared along with your executable in order for the program to run, as most users will not already have it.