How to use Boost headers with Jetbrains Appcode - c++

I have the Boost libraries installed on my Macbook via MacPorts and was wondering how to configure AppCode to recognize the headers.
I tried right clicking on the project -> Add Frameworks and Libraries -> Other... -> browse to /opt/local/include -> Choose but this doesn't seem to add Boost to the list.
Has anyone successfully gotten Boost to work with AppCode?

In case anyone else stumbles upon this via google:
There are three steps involved:
Right click on the project and choose Add Frameworks and Libraries, followed by Other, and browse for all of the dylibs. Since I installed boost via brew, the dylibs were located under /usr/local/Cellar/boost/1.53.0/lib/. Make sure that you select all of them, so that under the new Frameworks folder in your navigation window, a list of all of the boost libraries appear.
Right click on the project and choose Project Settings. Scroll to Search Paths and add the path to your boost include directory under Header Search Paths. For me it was located under /usr/local/Cellar/boost/1.53.0/include. Make sure that Recursive is unchecked, or you will get compile errors if you are using std!!!
Proceed to add the boost lib dir (that you browsed to in step 1) under Library Search Paths. After steps 2 & 3, your search paths may look something like:
Thats it! You are now ready to use boost headers like so:
#include <boost/lexical_cast.hpp>
Just make sure to build in 64-bit mode, since that's what the boost libraries are compiled as (might be different for the macports build).

Related

Using Magick++ library on windows

The title is pretty self-explanatory... how do I build the source for Magick++ for Windows? I've tried everything, and followed ImageMagick's directions extensively. However, all of these instructions are outdated. How do I get the static link libraries for Magick++, the include directories, and the dynamic link libraries? Any help is appreciated!
So basically it's super easy... Go to this link here, download whichever version fits your platform, go through the setup, and when a bunch of options comes up click the one that says install developer libraries. The include directories and libs will be in wherever you chose to install it.

Xcode framework no longer found after second build

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).

How do I link Tesseract to a C++ project in VS 2019?

So I've linked OpenCV already and that was pretty straightforward and there are many guides online how to do it.
But I don't know how to go about downloading Tesseract for usage in one's own applications. I want to get the API and use it in my code in conjunction with OpenCV. Can anyone guide me through what I need to download and what settings I'd need to tinker with to achieve this?
Install vcpkg ( MS packager to install windows based open source projects) and use powershell command like so .\vcpkg install tesseract:x64-windows-static. Dependency libraries like Leptonica will be auto installed for you. The tesseract can be auto integrated to your VS project using .\vcpkg integrate install.
I had a similar problem and in this thread I shared my experience on how I solved it. May be helpful for someone. I'll cope the text here:
I've been trying to link tesseract library to my c++ project in Visual Studio 2019 for a couple of days and I finally managed to do it.
Any thread that I found or even official tesseract documentation do not have full list of instructions on what to do.
I'll list what I have done, hopefully it will help someone. I don't pretend its the optimal way to do so.
There are basic tips in official tesseract documentation.
Go to "Windows" section.
I did install sw and cppan but I guess it wasn't necessary.
The main thing here is installing vcpkg.
It requiers Git so I installed it.
then:
> cd c:tools (I installed it in c:\tools, you may choose any dir)
> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat
> .\vcpkg\vcpkg install tesseract:x64-windows-static (I used x64 version)
> .\vcpkg\vcpkg integrate install
At this point everything should work, they said. Headers should be included, libs should be linked. But none was working for me.
Change project configuration to Release x64 (or Release x86 if you installed x86 tesseract).
To include headers: Go to project properties -> C/C++ -> General. Set Additional Include Directories to C:\tools\vcpkg\installed\x64-windows-static\include (or whereever you installed vcpkg)
To link libraries : project properties -> Linker -> General. Set Additional Library Directories to C:\tools\vcpkg\installed\x64-windows-static\lib
Project properties -> C/C++ -> Code Generation. Set Runtime Library to Multi-threaded(/MT). Otherwise I got errors like "runtime mismatch static vs DLL"
Tesseract lib couldn't link to its dependcies, so I added all libs that I had installed to C:\tools\vcpkg\installed\x64-windows-static\lib.
Project properties -> Linker -> Input. I set Additional Dependencies to archive.lib;bz2.lib;charset.lib;gif.lib;iconv.lib;jpeg.lib;leptonica-1.80.0.lib;libcrypto.lib;libpng16.lib;libssl.lib;libwebpmux.lib;libxml2.lib;lz4.lib;lzma.lib;lzo2.lib;openjp2.lib;tesseract41.lib;tiff.lib;tiffxx.lib;turbojpeg.lib;webp.lib;webpdecoder.lib;webpdemux.lib;xxhash.lib;zlib.lib;zstd_static.lib;%(AdditionalDependencies)
And after that it finally compiled and launched.
But... api->Init returned -1. To work with tesseract you should have tessdata directory with .traineddata files for the languages you need.
Download tessdata. I got it from official docs.
BTW, tessdata_fast worked better than tessdata_best for my purposes :)
So I downloaded single "eng" file and saved it like C:\tools\TesseractData\tessdata\eng.traineddata.
Then I added environment variable TESSDATA_PREFIX with value C:\tools\TesseractData\tessdata. I also added C:\tools\TesseractData to Path variables (just in case)
And after all this it is finally working for me.

Integrating GSL with Xcode

I am trying to get Xcode 5.1.1 to find the headers of GSL. My ideal solution would be one that would allow me to access these headers on all future projects with no extra work (automagically if you will). Most instructions seem to say to add the library path under the project's Build Setting -> Search Path section, however, my project does not seem to have a library or header option there. I have also tried to use the Link Binary with Libraries under the Build Phases tab, but /usr/local/include is "invisible" and I am reluctant to move these headers from their install location (unless this is normal/acceptable). Lastly I have tried to edit the Source Trees preference to add the library path, but this does not seem to work either. I wouldn't be surprised if I was doing that last part incorrectly as I am rather confused about the proper way of doing it.
This solution works on Xcode 5.1
In the side view click on your project, there should be a tab that can either be set to "Basic" or "All," select "All." Under the subsection labeled "Linking" there should be a field called "Other Linkers" enter these flags:
-I/usr/local/include
-L/usr/local/lib
-lgsl
-lgslcblas

Installing Boost libraries with MinGW and CodeBlocks

I'm having my first fling with the Boost libraries, and I've picked a pretty girl named Regex.
I've installed the libraries (which build automatically?) on my machine, but I'm getting the above error (cannot find -lboost_regex). I'm using Code::Blocks with MinGW, and a C++0X compiler flag.
I have
Pointed the "search directories" to the installation directory
Added the -lboost_regex flag to the linker
but no luck. Can someone help me get this working?
Update
Got things running now. I've added some further notes in an answer below, for newcomers to this problem.
(Also, changed the title of the question since it turned out to be a broader issue than when I started out.)
Here's some links and tips that can help a newcomer, from my first build experience. I built the libraries directly from the zip file. I built on MinGW and I used CodeBlocks for the IDE.
Download Boost zip, unzip somewhere (I'll call that place $boostdir)
Pretty large when unzipped, > 300MB
Add MinGW bin to PATH var
When Boost builds, it will need access to MinGW executables
Build b2.exe and bjam.exe
The documentation for Windows blithely assumes MSVC compiler is available.
If it is, you can apparently use the bootstrap.bat like the docs say.
If it's not (like mine), you'll have to build the exe files yourself, in steps 4 and 5.
In CMD, navigate to $boostdir/tools/build/v2/engine
Run build.bat mingw (will build b2.exe and bjam.exe)
Some aging basic documentation on that
Now you've got b2 and bjam custom-built according to your system spec. Navigate back up to $boostdir and get ready to start building the libraries.
Boost will make a new bin.v2 directory in the current directory.
All the libs will go in bin.v2.
This is an "intermediate" directory, for some reason
Nothing to do in this step, just some extra info :)
Run b2 toolset=gcc --build-type=complete
This takes a long time, in the neighborhood of 1 - 2 hours.
You'll know if it's working. If you think something's wrong, it's not working.
The build can use various flags
Now you're all built. Time to set up CodeBlocks.
Point your compiler to the header files
Right click your project -> Build Options -> Search Directories tab -> Compiler tab -> add $boostdir address
Boost has built a DLL for the library you want according to your current system spec. Look in the stage\lib\ directory of $boostdir
This DLL will be used later in the linker, so don't close its explorer window yet
Mine was in C:\Program Files\Boost_1_52\stage\lib\libboost_regex-mgw44-1_52.dll
I think the documentation had a smart way to do this but I haven't tried it yet
The "intermediate" directory from step #6 can be deleted now that the build is finished
Point your linker to the directory of that DLL
Right click your project -> Build Options -> Search Directories tab -> Linker tab -> add
that directory address (blah\blah\blah\stage\lib\)
Add that DLL flag to your linker settings
Mine was -lboost_regex-mgw44-1_52
Deep breath, prayers to your god, and fire up a test.
Further docs that may either help or confuse:
The Code::Blocks website has a version of this that I didn't find until I neared the end of my search. It was fairly helpful but had a few weird things. This post also is helpful.
Good luck!
I'm not sure what you mean by which build automatically. Most of the Boost libraries are header-only, but a few, such as regex, need to be compiled to a shared / static library. The compilation step is not automatic, you need to invoke the Boost build system (bjam) to do this. Of course, there are sources (BoostPro for instance) that distribute pre-built Boost binaries for various platforms.
Once that's done, you need to add the path where the libraries are present to the linker's search path. For MinGW, this option is -L"path/to/library". Boost does have directives to allow auto-linking of the required libraries, and this seems to work pretty well with MSVC, but I've never gotten it to work with MinGW. So you must also list the libraries to be linked explicitly. The Boost libraries include target and version information in the file name by default, so a typical linker command line option will look like -lboost_regex-mgw47-mt-1_51 for MinGW gcc 4.7 and Boost 1.51