# include <cstddef> file not found in xcode - c++

Hello i am using this library for implementation of annotation but facing one issue in bellow image
i checked user header path and library search path and
also try this link:
size_t on XCode
Xcode cannot find cstddef
Please Help Me

I believe the reason is that the implementation file, that includes the header from that library, needs to be Objective-C++.
This is easily fixed by renaming it from .m to .mm.
It will also be necessary to avoid exposing the library to the rest of your project if you are unwilling to make the whole app Objective-C++ and I believe the sample project you reference does this as all implementation files are Objective-C apart from one which is Objective-C++.
Doing that is non-trivial.

Related

Boost library demanding lib file that I believe is not necessary

I am working with some autogenerated C++ code provided by a vendor. They use the Boost libraries extensively, and as such I also need to use the boost libraries in order to create the appropriate objects to send as inputs to vendor methods. They provide all the Boost header files within a lib folder in the autogenerated code.
I have never used Boost before, but from what I've gathered in the past few days it is for the most part a header only library, which to me means that there are no *.dlls or *.lib files required to use it in my software provided I don't use the listed features that do require a lib file.
The problem I am having is when I try to include "boost\date_time.hpp" when it comes time to build it I get a LNK1104 error "cannot open file libboost_date_time-vc140-mt-gd-1_38.lib". I have noted that on the Boost website it says that some libraries do have optional compiled libraries depending on if certain features are used; for date_time it says the following:
"Boost.DateTime has a binary component that is only needed if you're using its to_string/from_string or serialization features, or if you're targeting Visual C++ 6.x or Borland."
I do not require any of the features that would require a compiled library, and have not referenced any features at all yet in my code, simply added the include. So why is it demanding this file? Also, how does it even know what file to demand? Is there a sneaky #pragma hidden in one of the header files? I started to look but there were too many paths to go down.
The vendor does supply a compiled dll and lib file for Boost.DateTime, however it is named 'boost_date_time-vc140-mt-gd-1_38.lib', the file the compiler is looking for has 'lib' prefixed to the front. If it does require it, then how can I direct the linker to the correct file? I know I can change the name of the file to what the linker is looking for (the linker has the path to the folder containing the file already, it is nothing to do with that) but as this code comes from the vendor code generation software it will frequently revert back to the original file name, so that would not be an optimal solution.
As always, thank you for any help you can provide.
As tkausl mentioned in the comments there was a #pragma comment in a header file trying to load the lib.
By adding the line '#define BOOST_ALL_NO_LIB' before the '#include "boost\date_time.hpp"' line this solved the problem as the defined Macro tells Boost to not to load the lib file.

How to configure Eclipse C project to accept C++ includes

I have a C project in which I would like to use some C++ files.
I've modified the Makefile accordingly, but I get the
make\mingw32-make.exe[1]: *** No rule to make target
error.
I noticed that the included headers from the cpp standard library are not found.
Headers Not Found . picture
[Edit] As a note, all the .c, .cpp, .h files are in the same folder.
If I add
#include <string>
in the .c file it is found. In the .cpp it's not.
In Eclipse I've seen that I can't set includes for C++.
No C++ Includes . picture
Is there a way to do this ?
Thank you.
Unfortunately I didn't find any solution for this issue.
Still I am on the right path as there is a way to use the C code from Alglib.
http://forum.alglib.net/viewtopic.php?f=2&t=3766
It may be better to download CPython version of ALGLIB and to work with source of its computational core. It is written in C, without even trace amounts of C++, so you may find it more convenient than making wrappers around C++ core.

Using Cocoa static library built in c++, some ObjC code tries to rebuilt it in OC

I am programming in Xcode in ObjC using a Cocoa static library built in c++ (built by me). For the library project, I made one public header(.hpp) that includes all the other header files(.hpp). Then in the ObjC project, I wrote a wrapper code(.hpp and .mm) to play as the interface, so it includes the public hpp header. To access the library, I then include the wrapper code in a normal m file. I believe all of these followed the tutorials, as it worked well for a few weeks.
However, after doing something stupid yesterday, the compiler for the ObjC project started to insist on building all the headers in ObjC. It first had problems with openCV packages in the c++ library, producing errors saying thoses are supposed to be built in c++ (as shown below). Even if I removed the openCV, the compiler cannot find any standard c++ libararies. I tried renaming the .hpp's to .h but it did not work.
Any suggestions on what I did wrong and how I can fix this?Much appreciated!
()
Your errors are coming from compiling ImageProcessor.m. .m is the extension Obj-C files, so the compiler will try to compile it, and everything it includes as Obj-C.
I'd suggest renaming it to ImageProcessor.mm.
After learning more about header files, I realized what I did wrong: I included every header in the interface, so they are re-built every time outside the library, even if they are referenced by none-c++ code. The solution is to separate the interface header with other headers in the library completely.

Import C++ code to IOS application [duplicate]

This question already has answers here:
How can I use C++ with Objective-C in XCode
(2 answers)
Closed 8 years ago.
I write a code in C++, and I want to use some of it's methods in my IOS application, so is it possible to (import) C++ library "t.cpp" to IOS application in XCode?
if yes what's the simple way to do it?
Yes, that will work without error, however you might want to change the Xcode C++ compiler settings (language level and runtime library), depending on the version of iOS you are using.
When it comes to actually using the C++ classes within your Objective-C code, you simply need to rename any files from .m to .mm.
A complication occurs when you want to include the C++ headers in Objective-C headers where both .m and .mm see that Objective-C header file. In this case you might find that you need to change many more files from .m to .mm in order for this to work, but there are ways around this if that becomes too onerous.
Just add the file to the project.
You need to rename a file from .m too .mm only if the translation unit contains a C++ header. Then, the module gets "infected" by C++ and needs to be compiled with the Objective-C++ compiler.
This is only required if any C++ header will be directly or indirectly included/imported from that module. There is no need to rename all files.
Additionally, if this C++ code depends on the C++ standard lib, you need also ensure, that the executable binary links against the C++ standard lib, via setting the appropriate build setting in the executable binary.
For example, in the target build settings of your app, add the following option to Other Linker Flags:
-lc++
e.g.:
OTHER_LDFLAGS = -ObjC -lc++
Caution:
If possible, don't include/import a C++ header in a public Objective-C header, since then all modules will be infected by C++ when they import this Objective-C header and become Objective-C++.

Is it possible to include a library from another library using the Arduino IDE?

I'm trying to write an Arduino library (effectively a C++ class) which itself references another library I have installed in my Mac's ~/Documents/Arduino/libraries directory.
At the top of the .cpp of the library I'm writing, I've tried
#include <ReferencedLibrary.h>
and
#include "ReferencedLibrary.h"
... neither of which work. I can successfully #include <ReferencedLibrary.h> from sketches in my ~/Documents/Arduino directory. Am I missing something or is this a limitation of the Arduino IDE/makefile? Is there a workaround?
I have been able to include a library in another Arduino library by using a relative path. For example, to include the AbstractSwitch library into the DigitalSwitch library, assuming that both of these libraries live in their own separate folders within Arduino's standard library folder, you can use the following include statement:
#include "../AbstractSwitch/AbstractSwitch.h"
In other words, your include statement should read:
#include "../LibraryFolder/LibraryHeaderFile.h"
The documentation here https://github.com/arduino/Arduino/wiki/Build-Process states:
The include path includes the sketch's
directory, the target directory
(/hardware/core//) and
the avr include directory
(/hardware/tools/avr/avr/include/),
as well as any library directories (in
/hardware/libraries/) which
contain a header file which is
included by the main sketch file.
This means that if you #include "ReferencedLibrary.h" from your main sketch file, this causes that file's libraries directory to get added to the include path for other libraries to include. A bit of a hack but it does work on my Mac.
This issue was solved in the Arduino 1.6.6 release. The release notes of 1.6.6 mention that library to library dependencies have been fixed.
Library to library dependencies: when your sketch imports a library, and that library uses another, the IDE will find out without you having to add a useless #include to your sketch
Updating your version to 1.6.6 or newer will resolve your problem.
Using the Arduino environement, as I understand it, you cannot access your own library from another of your own libraries. There is no way to add paths, so there is simply no way for the compiler to find the code. That makes it hard to write libraries that use code in another of your libraries. My web research indicates this has been a problem for years but to my knowledge has not been solved. I suspect there are difficulties in the implementation details or perhaps a desire to keep the system simple at the expense of capability.
Of course, you can always cut and paste code into each new library, but that's exceedingly sub-optimal. You can also write one huge library with all of your code in one pair of .h and .cpp files. That's also not very satisfactory, but I've done it on occasion.
There is a work around, however, for using standard Arduino libraries in your own library that you're placing in your sketchbook/libraries directory. Since sketches include paths to the standard library locations, and link the standard library code, you can include the header file for the standard library of interest in your sketch. Below that, also in your sketch, include your own library header file. The standard library will then become available to your library as well as to your sketch.
Not recommended method: It is possible to add basically any external library code to Arduino IDE build by knifing boards.txt file. Headers in c/cpp flags and libraries in ld flags. This may be useful for library dev using external tools (cmake/QT creator for me today).
I modified /home/pekka/arduino-1.8.5/hardware/teensy/avr/boards.txt by adding "/coderoot" to gcc include path and E_OS_arduino define, modified lines below:
teensy36.build.flags.cpp=-fno-exceptions -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -I/coderoot -DE_OS_arduino
teensy36.build.flags.c=-I/coderoot -DE_OS_arduino