What #include to use for using Vector3 in MSDN c++ - c++

I am trying to implement rotation in and the MSDN document has suggested everywhere to use Vector3 structure to achieve this. However I get an error for both Vector3 and Quaternion saying identifier not defined
I understand this is because of not including the appropriate header file or not linking the proper library. I searched online but could not find which exact file to link and include.

Related

C onnx header can't find OrtEnv definition

I am trying to wrap the ONNX header for use in another language. To be clear it uses the C dll and requires the C header however I'm having issues compiling using the C header due to the ONNX header seemingly missing the definition of the OrtEnv struct that is used in the current ONNX samples.
https://github.com/microsoft/onnxruntime/blob/master/include/onnxruntime/core/session/onnxruntime_c_api.h
This is the ONNX api header that I'm trying to use to wrap.
And the sample
https://github.com/microsoft/onnxruntime/blob/master/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp
On line 30 it declares a raw pointer to a struct I cannot find the definition of in the api header thenless I do not understand something.
Could someone possibly elaborate on what I am doing wrong? All I can see is method declarations returning OrtEnv but never the type declaration.
There is a complete dynamic package available here with the header:
https://github.com/microsoft/onnxruntime/releases/download/v1.4.0/onnxruntime-win-x64-gpu-1.4.0.zip
where it should be simple to link the dll to your application and include the aforementioned header that im having issues with.
If a header does not contain a definition, it means that the author did not want to give it to you. That can happen for various legitimate reasons, one of them is that you should not be able to tamper with the content.

Eigen and CImg compatibility issues

So, I'm trying to record and display an image using CImg but I'm also using a linear algebra library called Eigen. Coincidentally, they each seem to have a macro with the same name, "Success". I've tried doing an #undef but that didn't work out smoothly. So whenever I try to compile, I get this error that "Success" is defined twice in different files. How should I go about removing this error without losing either macro? Help is much appreciated!
The problem arises because CImg includes the X11 header X.h which has a macro called "Success" defined. This macro clashes with the ComputationInfo enum definition in Eigen, since it has an enum value called "Success".
As a workaround, you can undefine "Success" after including CImg, and before including Eigen as so:
#include <CImg/CImg.h>
#ifdef Success
#undef Success
#endif
#include <eigen3/Eigen/Eigen>
See also issue #253 on Eigen's bug tracker: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=253
Neither Eigen nor CImg have such a #define. However, Eigen does have such an enum in the Eigen namespace, so the problem more likely comes from X11 X.h header file which #define Success.
So, if you need to use Success from X11, then include Eigen's header before X11 ones (or anyone that could include it).
If you need Success from Eigen, then include Eigen last, and #undef Success before it.
You may also want to display the includes of the X11 header files in CImg, by defining macro cimg_display to 0 before including "CImg.h" (or put the -Dcimg_display=0 flag when compiling).
Of course, do this only if you don't need the display capabilities of CImg.
If you dont need one of them macros in your code, you can #undef it between the 2 includes. So, it really depeneds on what you need in your code.

Problems with void function in header of my static library

I'm programming a .lib file for mobile robot.
Among other commands regarding robot movement, I also have command for scanning for Bluetooth devices looking something like:
void ScanForDevices(vector<Device> &Robot)
{
/* code for searching Bluetooth devices and saving their names and addresses into vector of Device struct*/
}
My question is related with writing the header of the .lib file.
One of my commands is:
string RobotMove(int Translation, int Rotation)
{
/* create Command
return string(Command);
}
In the header, for that command I have:
// Returns MOVE command
std::string RobotMove(int Translation, int Rotation);
What I have problem with is what to write in the header for:
void ScanForDevices(vector<Device> &Robot)
I keep getting "Incomplete type is not allowed" is I try to do the same way as RobotMove command. Do I have to declare in some way in the header struct Device?
Do I have to declare in some way in the header struct Device?
If you want to create vectors for Devices, you need to let compiler know the size of the class by defining it. As noted by BoBTFish, the usual way is to just include Device.h header (or similar).
If you use pointers (vector<Device*> or even better, appropriate kind of smart pointer: vector<shared_ptr<Device>>) forward declaration (just stating class Device;) would be enough, as compiler knows size of the pointer on your architecture. (Note that this is completely different approach with different semantics than in your question, and this is just a side-note).
if your header file does not include (directly or indirectly),a definition for vector class you need to add #include <vector> to your header file. The compiler does not know this data type without providing it the right information.

g++/gcc cannot find header file named String.hpp

I created my own string class and named it 'String.hpp' and included this file in my 'String.cpp'. However, g++/gcc says it could not find 'String.hpp' no matter what I tried. Furthermore, it also cannot find the class named 'String'.
I thought strings in c++ were lowercase 'string'. Is 'String' a reserved class or word in C++?
EDIT:
I seemed to have solved this issue by redoing the code body. The names have all remained the same. I guess the next time this happens, I will look through my own code and try to find a problem there.
In C++ a string is a standard defined type not a keyword. And is use like so
#include <string>
//elsewhere
std::string str("hi");
If your compiler can't find your string header then it ins't going to know about your class whatever happens.
You should include your own header like this. Note the quotations, not the angle braces. Angle braces mean that the compiler should search the include directories not the current directory.
#include "String.hpp"
//else where
yournamepsace::String str //etc...
This won't collide with the standard version, you should however make sure that it is namespaced as you will be no doubt dealing with very similar names.
If the compiler still can't see then you need to make sure that the file is in the same directory that your source file is in.
Finally if this is some sort of programming practice then carry on but if this is production code please consider using the std::string, the world doesn't need another string. :)
My suspicion is you are doing a
#include <String.hpp>
This excludes the current directory from the where the compiler will search for the file. If that is the case, you want to do
#include "String.hpp"
in which case, the compiler will also search the current directory.

Strange linkage problem with Visual C++ 2005

please help me, I have a strange problem which i can't sort out in any way.
Premise: I'm using visual c++ 2005 on windows 7 x64, and I'm sure that my code isn't fatally flawed because with g++ under Linux it runs nicely.
I am developing an application which uses a static library also developed by me.
In the link phase of the application i get two mysterious LNK2019 errors.
This is the header of one of the classes of the library:
namespace sulfur
{
class Quark
{
public:
... various methods
void addAccel(const Vec2 &a);
... various methods
private:
... various data
};
}
Obviously in the cpp file i provide an implementation for addAccel with exactly the same signature.
When I try to link the application with the library, ALL the other member functions are found, except for addAccel.
The linker searches for the symbol "?addAccel#Quark##QAEXABV?$TemplateVec2#M#Atlax###Z"
while in the .lib file there is (which i found using dumpbin) "?addAccel#Quark#sulfur##QAEXABV?$TemplateVec2#M#Atlax###Z". The only difference here is that the linker searches for a mangled name without the namespace part and I don't know why.
I've tried to change name, position, calling convention and signature of the metod but to no avail, always getting the same error.
The second error is very similar. I have another header in the library:
namespace sulfur
{
class Cluster
{
...
Quark *addQuark(sulfur::Feature feat, float x, float y, float m=0.1f, float aF=0.01f);
...
};
}
and a correct implementation file is provided. Like before, all the other methods are linked properly, but not addQuark.
The linker searches for "?addQuark#Cluster#sulfur##QAEPAVQuark##W4Feature#2#MMMM#Z"
but in the library there is "?addQuark#Cluster#sulfur##QAEPAVQuark#2#W4Feature#2#MMMM#Z".
This time the difference is the absence of the first '2' between the '#' in the version which the compiler searches for.
This isn't the first time that I build this application with visual studio and it has always linked ok except for this time with the last changes.
I don't have any clue,
thank you in advance
Where and how is the void addAccel(const Vec2 &a); function implemented? Are you sure that you are not missing Quark:: prefix on the implementation of the function?
Well, I've just solved the issue.
There where two erroneous forward declarations (outside of the namespace) of class Quark and class Cluster. For some reason g++ was ok with that, while VC++ was right to complain about it.
Thank you anyway.