I'm trying to compile shogun toolbox and I'm getting this fault
C:/shogun-3.0.0/shogun-3.0.0/src/shogun/../shogun/mathematics/Math.h: In static
member function 'static int shogun::CMath::is_finite(double)':
C:/shogun-3.0.0/shogun-3.0.0/src/shogun/../shogun/mathematics/Math.h:1255:20: er
ror: 'ifinite' was not declared in this scope
return ifinite(f);
function itself looks like this.
inline static int is_finite(double)
{
#if defined(isfinite) && !defined(SUNOS)
return ifinite(f);
#else
return finite(f);
#endif
}
I believe similar is described here: http://www.alecjacobson.com/weblog/?p=1768, but I'm not sure as I don't include cmath. Any idea what it can be?
Function is isfinite, not ifinite.
You don't include <cmath> but according to Shogun source here, it does include both <cmath> and <math.h> in the wrong order:
#include <shogun/base/SGObject.h>
#include <shogun/lib/common.h>
#include <cmath> <<<<<<
#include <shogun/mathematics/Math.h>
#include <shogun/mathematics/lapack.h>
#include <shogun/io/SGIO.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h> <<<<<<
So you are supposed to use std::isfinite.
I just downloaded shogun-3.0.0 from here, and there is no occurrence of the string “ifinite” anywhere in the source. The definition of is_finite in Math.h is:
/// checks whether a float is finite
inline static int is_finite(double f)
{
#if defined(isfinite) && !defined(SUNOS)
return isfinite(f);
#else
return finite(f);
#endif
}
If the errors and source text you entered into the question are correct, perhaps the sources you have were corrupted. You should download the source and try again.
Related
I am attempting to make a class to contain some math operations from a CRC math tables handbook I have, in creating one of the functions I got a strange error I had not seem before. The code for both the cpp and the header are below:
//Header File
#include <iostream>
#include <cmath>
#include <string>
#define int "CRCMathLib_H"
using namespace std;
class CRCMathLib
{
public:
int DoReturn_Totient(int Toter); //Error comes from here when trying to declare as an int
};
//CPP Class File
#include "CRCMathLib.h"
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int CRCMathLib::DoReturn_Totient(int Toter)
{
return 0;
}
//CPP Main File
#include <iostream>
#include <cmath>
#include <string>
#include "CRCMathLib.h"
using namespace std;
int main()
{
return 0;
}
The Main file does not do anything as of yet as this is a completely new file for these operations, I believe this may be a preprocessing error and its not picking up on the int statement as I ran it on another PC with VS and it was able to read the statement. anything would help. Also it was requesting a decleration of the header file, so thats why I placed the int there, is this possibly the issue? removing it returns the error of not having a decleration.
In your .h remove #define int "CRCMathLib_H" which is most probably a typo
replace it by
#include <iostream>
#include <cmath>
#include <string>
#pragma once
The #pragma once ensure you can safely include your .h from the cpp implementation file and the main.cpp
You mis understood include guard protection usually done by
ifndef CRCMathLib_H
#define CRCMathLib_H
// all of you .h file delcaration
#endif
This can be easily replace by the #pragma once statement at the begining of the file
More on this here: https://www.learncpp.com/cpp-tutorial/header-guards/
I've been struggling with this for a very long time.
Using MATLAB's coder, I've generated a C++ code, but I'm not sure how to implement it in my main file.
This is the directory containing the MATLAB generated C++ code. Could somebody please walk me through how to use this code in another main file?
(The whole process of making a make file, include statements, etc;) I really would appreciate it if the explanation is specific and thorough.
Here is one of the header files that I need to include (IOPfinal.h)
#ifndef IOPFINAL_H
#define IOPFINAL_H
// Include Files
#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "rt_nonfinite.h"
#include "rtwtypes.h"
#include "IOPfinal_types.h"
// Function Declarations
extern double IOPfinal(const emxArray_real_T *wavelength, const emxArray_real_T *
intensity, double range, const emxArray_real_T *polymat);
#endif
I've heard that there are makefiles that are also provided by MATLAB but I'm not sure exactly how to use them and what I should do after using that makefile either. The code below is the main file that I intend to use.
#include "IOPfinal.h"
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include "IOPfinal.h"
#include "IOPfinal_emxAPI.h"
using namespace std;
int main() {
double *wavelength, *intensity;
// some code to initialize wavelength and intensity
emxArray_real_T *inputs, *outputs;
inputs = emxCreateWrapper_real_T(wavelength, 1, 3);
outputs = emxCreateWrapper_real_T(intensity, 1, 3);
return 0;
}
Thanks in advance!
I have come across a strange compile error that I cannot make sense of. Firstly the error refers to the function as if it was in an anonymous namespace, however it is in fact inside namespace database. Secondly the "used but never defined" statement suggests that the compile requires me to define the function from within the header. The function is in fact declared in a separate implementation file. However the function is neither static nor inline so I am at a loss as to why it requires a definition in the header. It is a requirement that this piece of code is strictly compliant, because of this I have compiled with both -Wall -Werror. I have also included a shortened version of my source code for clarification.
Note: This question is different from other similar questions asked here in that it does not involve static or inline functions.
Error:
In file included from src/main.cpp:6:0:
include/database.hpp:19:6: error: 'void {anonymous}::SetupSettings()' used but never defined [-Werror]
void SetupSettings();
^
cc1plus.exe: all warnings being treated as errors
main.cpp
#include <iostream>
#include "config.hpp"
#include "database.hpp"
int main() {
database::SetupSettings();
return 0;
}
database.hpp
#ifndef database
#define database
#include <iostream>
#include "config.hpp"
#include "sqlite/sqlite3.h"
namespace database {
extern sqlite3* settings_database;
void SetupSettings();
// ^^ Apparent warning here.
} // namespace database
#endif
database.cpp:
#include <iostream>
#include <vector>
#include "config.hpp"
#include "database.hpp"
#include "sqlite/sqlite3.h"
namespace database {
sqlite3* settings_database;
void SetupSettings() {/*More code here*/}
} // namespace database
The problem is caused by use of:
#ifndef database
#define database
After that,
namespace database { ...
is seen as
namespace { ...
i.e. an anonymous namespace.
You need to use a different include guard macro, such as:
#ifndef database_hpp
#define database_hpp
I am migrating a huge project from Qt 4.x to 5, (in fact I have asked for help several times here, I couldnt be more grateful for your help).
I am getting the next error:
..\marssies\userlayerswidget.cpp: In member function 'void
LayersModel::importFromOld()':
..\marssies\userlayerswidget.cpp:1736:60: error: 'SHGFP_TYPE_CURRENT'
was not declared in this scope
It doesnt make too much sense, as I have the correct header included, here are all the includes:
#include "userlayerswidget.h"
#include "appcommon.h"
#include "messagebox.h"
#include "polyline.h"
#include "painterbar.h"
#include "rectangle.h"
#include "polygon.h"
#include "label.h"
#include "line.h"
#include "point.h"
#include "encsymbol.h"
#include "touchswibz.h"
#include "mapmodulelist.h"
#include "offlinelayersaver.h"
#include "circle.h"
#include <QMenu>
#include <QDir>
#include <QDesktopServices>
#include <QtDebug>
#ifdef _WIN32
#include <Shlobj.h>
#endif
And here is the piece of code that makes use of SHGFP_TYPE_CURRENT:
void LayersModel::importFromOld() {
TCHAR appPath[MAX_PATH];
if (!(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appPath))) {
//code
}
I have researched and everything is correct according to http://msdn.microsoft.com/en-us/library/bb762181%28VS.85%29.aspx
I tried to find other people with the same problem but either the context was different or the question wasnt answered.
Thankyou.
In ShlObj.h is SHFGP_TYPE_CURRENT defined like this:
#if (_WIN32_IE >= 0x0500)
typedef enum {
SHGFP_TYPE_CURRENT = 0,
SHGFP_TYPE_DEFAULT = 1,
} SHGFP_TYPE;
#endif
So one can do this:
#define _WIN32_IE 0x0500
#include <ShlObj.h>
Or another way is to directly use value 0 or 1 as parameter to SHGetFolderPath.
Doing more research I found an answer that was to replace SHGFP_TYPE_CURRENT with a literal 0, I did it and it compiled, but I'm not sure if it will be the same (I haven't written this program, I'm just migrating it). So if anybody could give some insight it would be nice.
Source: http://webcache.googleusercontent.com/search?q=cache:http://www.dreamincode.net/forums/topic/200660-undeclared-variable/
I am writing a plugin for Autodesk Maya using C++ and have a linker error.
My main class is Maya_Search_Plugin.cpp
#include <Utilities.h>
DeclareSimpleCommand( search_face, PLUGIN_COMPANY, "4.5");
//doIt method is entry point for plugin
MStatus search_face::doIt( const MArgList& )
{
//calls to Maya types/functions and Utilities functions
}
Then I have a Utilities class containing some static methods with header looking like this
#ifndef __Maya_CPP_Plugin__Utilities__
#define __Maya_CPP_Plugin__Utilities__
//#pragma once
//standard libs
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <math.h>
//maya libs
#include <maya/MDagPath.h>
#include <maya/MFn.h>
#include <maya/MFileIO.h>
#include <maya/MIOStream.h>
#include <maya/MFnMesh.h>
#include <maya/MFnTransform.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSimple.h>
#include <maya/MTypes.h>
#include <maya/MPointArray.h>
#include <maya/MObjectArray.h>
class Utilities{
public: static const int max_mov = 50;
public:
static double get_mesh_error(MPointArray, MPointArray, int);
static MStatus translateManipulator(double amount, MObject *path);
static void GetSelected(MObjectArray* objects, MFn::Type type);
};
#endif /* defined(__Maya_CPP_Plugin__Utilities__) */
with the implementation like this
#include <Utilities.h>
double Utilities::get_mesh_error(MPointArray a, MPointArray b, int vertexCount){
...
}
MStatus Utilities::translateManipulator(double amount, MObject *path){
...
}
void Utilities::GetSelected(MObjectArray* objects, MFn::Type type) {
...
}
However I am getting the following error
duplicate symbol _MApiVersion in:
/Users/tmg06qyu/Library/Developer/Xcode/DerivedData/Maya_CPP_Plugin-hjrwvybwlvqyyscbmixdkcpdzjqr/Build/Intermediates/Maya_CPP_Plugin.build/Debug/Maya_CPP_Plugin.build/Objects-normal/x86_64/Maya_Search_Plugin.o
/Users/tmg06qyu/Library/Developer/Xcode/DerivedData/Maya_CPP_Plugin-hjrwvybwlvqyyscbmixdkcpdzjqr/Build/Intermediates/Maya_CPP_Plugin.build/Debug/Maya_CPP_Plugin.build/Objects-normal/x86_64/Utilities.o
ld: 1 duplicate symbol for architecture x86_64
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld failed with exit code 1
Which I presume is a linking error and there is some circular reference somewhere, but I can't work out where it is.
Any help appreciated.
Thanks.
I know this is a year old. But I stumbled on this again a couple minutes ago...
Add
#define MNoVersionString
#define MNoPluginEntry
#include <maya/MFnPlugin.h>
to your header or cpp files where you wrote your plugin code. Include
#include <maya/MFnPlugin.h>
directly in your main.cpp that initializes the plugin.
Most of the examples in maya have the following string:
// This is added to prevent multiple definitions of the MApiVersion string.
#define _MApiVersion
before including anything. For example here.
The issue may happen if you have multiple files which include MFnPlugin.h