SWIG : Error: Unable to find 'stdexcept' - swig

I use SWIG to create some C# wrappers, but it seems that I got a set of errors, even after including the corresponding .i libraries!
%module test_module
%include <stl.i>
%include <windows.i>
%include <typemaps.i>
%include <stdint.i>
%include <std_string.i>
%include <std_vector.i>
%include <inttypes.i>
%include <attribute.i>
%include <cpointer.i>
%include <exception.i>
%include <carrays.i>
%include <cdata.i>
%include <cmalloc.i>
%include <constraints.i>
%include <cpointer.i>
%include <cwstring.i>
%include <intrusive_ptr.i>
%include <math.i>
%include <pointer.i>
%include <std_except.i>
%include <swigarch.i>
%include <swigrun.i>
%include <wchar.i>
%include <shared_ptr.i>
%{
#include "Context.hpp"
%}
%feature("nspace") Context;
%include "Context.hpp"
and here is the list of errors :
core\Expected.hpp(18) : Error: Unable to find 'memory'
core\Expected.hpp(19) : Error: Unable to find 'utility'
core\Expected.hpp(20) : Error: Unable to find 'typeinfo'
core\Expected.hpp(21) : Error: Unable to find 'exception'
core\Expected.hpp(22) : Error: Unable to find 'stdexcept'
core\Expected.hpp(23) : Error: Unable to find 'type_traits'
core\Definitions.hpp(22) : Error: Unable to find 'inttypes.h'
core\Definitions.hpp(23) : Error: Unable to find 'type_traits'
core\Definitions.hpp(24) : Error: Unable to find 'stddef.h'
core\Definitions.hpp(25) : Error: Unable to find 'stdint.h'
core\EnumBitMaskGenerator.hpp(18) : Error: Unable to find 'type_traits'
core\PImpl.hpp(20) : Error: Unable to find 'type_traits'
core\PImpl.hpp(21) : Error: Unable to find 'memory'
core\PImplSizes.hpp(18) : Error: Unable to find 'vector'
core\PImplSizes.hpp(19) : Error: Unable to find 'deque'
core\PImplSizes.hpp(20) : Error: Unable to find 'fstream'
core\PImplSizes.hpp(21) : Error: Unable to find 'memory'
core\PImplSizes.hpp(22) : Error: Unable to find 'map'
core\PImplSizes.hpp(23) : Error: Unable to find 'mutex'
core\PImplSizes.hpp(24) : Error: Unable to find 'atomic'
concurrency\ThreadLocalPointer.hpp(20) : Error: Unable to find 'thread'
concurrency\ThreadLocalPointer.hpp(21) : Error: Unable to find 'unordered_map'
And here the command line, with the options:
swig.exe -includeall -c++ -csharp -macroerrors -cppext cpp ...
Any idea ?
Thanks

Try using -I to set the include path. See:
http://swig.org/Doc3.0/SWIG.html#SWIG_nn2

It seems like *.i files from the SWIG/Lib are quite useless and provided as a kind of stub. You have to add SWIG/Lib/csharp as SWIG include dir instead.

Related

Trouble groking cython memoryviews ... how do I implement here?

Two functions: one which creates a 32-million integer array and another which uses it for a lookup millions of times.
from cpython cimport array as c_array
from array import array
def get_lut(file_location):
cdef c_array.array lut
with open(file_location, "rb") as f:
lut = array("I", f.read())
return lut
def use_lut(int[:] lut):
// Do a whole bunch of lookups.
Compiling with the following command:
c:\Users\Michael\Documents\Poker>set DISTUTILS_USE_SDK=1
c:\Users\Michael\Documents\Poker>python setup.py build_ext -i --compiler=msvc
Produces the following output:
Compiling handeval.pyx because it changed.
Cythonizing handeval.pyx
warning: View.MemoryView:288:5: Cannot profile nogil function.
warning: View.MemoryView:763:5: Cannot profile nogil function.
warning: View.MemoryView:899:5: Cannot profile nogil function.
warning: View.MemoryView:1063:5: Cannot profile nogil function.
warning: View.MemoryView:1070:5: Cannot profile nogil function.
warning: View.MemoryView:1124:5: Cannot profile nogil function.
warning: View.MemoryView:1131:5: Cannot profile nogil function.
warning: View.MemoryView:1142:5: Cannot profile nogil function.
warning: View.MemoryView:1163:5: Cannot profile nogil function.
warning: View.MemoryView:1223:5: Cannot profile nogil function.
warning: View.MemoryView:1295:5: Cannot profile nogil function.
warning: View.MemoryView:1317:5: Cannot profile nogil function.
warning: View.MemoryView:1352:5: Cannot profile nogil function.
warning: View.MemoryView:1362:5: Cannot profile nogil function.
running build_ext
building 'handeval' extension
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.exe /c /nolo
go /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\Michael\Anaconda3\include -IC:\Users\Mic
hael\Anaconda3\include /Tchandeval.c /Fobuild\temp.win-amd64-3.4\Release\handeva
l.obj
handeval.c
handeval.c(2391) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'long',
possible loss of data
handeval.c(2420) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(2449) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(2478) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(2507) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(2536) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(2565) : warning C4244: '+=' : conversion from 'Py_ssize_t' to 'int',
possible loss of data
handeval.c(12955) : error C2275: 'PyGILState_STATE' : illegal use of this type a
s an expression
C:\Users\Michael\Anaconda3\include\pystate.h(191) : see declaration of '
PyGILState_STATE'
handeval.c(12955) : error C2146: syntax error : missing ';' before identifier '_
_pyx_gilstate_save'
handeval.c(12955) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13026) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13052) : error C2275: 'PyGILState_STATE' : illegal use of this type a
s an expression
C:\Users\Michael\Anaconda3\include\pystate.h(191) : see declaration of '
PyGILState_STATE'
handeval.c(13052) : error C2146: syntax error : missing ';' before identifier '_
_pyx_gilstate_save'
handeval.c(13052) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13125) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13152) : error C2275: 'PyGILState_STATE' : illegal use of this type a
s an expression
C:\Users\Michael\Anaconda3\include\pystate.h(191) : see declaration of '
PyGILState_STATE'
handeval.c(13152) : error C2146: syntax error : missing ';' before identifier '_
_pyx_gilstate_save'
handeval.c(13152) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13242) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13909) : error C2275: 'PyGILState_STATE' : illegal use of this type a
s an expression
C:\Users\Michael\Anaconda3\include\pystate.h(191) : see declaration of '
PyGILState_STATE'
handeval.c(13909) : error C2146: syntax error : missing ';' before identifier '_
_pyx_gilstate_save'
handeval.c(13909) : error C2065: '__pyx_gilstate_save' : undeclared identifier
handeval.c(13935) : error C2065: '__pyx_gilstate_save' : undeclared identifier
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\Bin\\
amd64\\cl.exe' failed with exit status 2
Whereas removing the int[:] type declaration from the use_lut signature compiles fine.
What am I doing wrong here?

Exception while try to get jmeter directory

I would like to start jmeter load test via console but it's Data Driven Load Test, so I need to read some information from csv files. I found a solution to include into User Parameters row to get the path to the place where the script was launched:
${__BeanShell(newFile(org.apache.jmeter.gui.GuiPackage.getInstance().getTestPlanFile().toString()).getParent())}
but I got an error in logs:
2013/06/11 15:23:54 ERROR - jmeter.util.BeanShellInterpreter: Error
invoking bsh method: eval Sourced file: inline evaluation of:
``newFile(org.apache.jmeter.gui.GuiPackage.getInstance().getTestPlanFile().toStrin
. . . '' : Command not found: newFile( java.lang.String )
2013/06/11 15:23:54 WARN - jmeter.functions.BeanShell: Error running
BSH script org.apache.jorphan.util.JMeterException: Error invoking bsh
method: eval Sourced file: inline evaluation of:
``newFile(org.apache.jmeter.gui.GuiPackage.getInstance().getTestPlanFile().toStrin
. . . '' : Command not found: newFile( java.lang.String ) at
org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:192)
What's wrong with this method?
The issue is you have:
newFile
instead of:
new File

Error in building itk with GDCM git repository

I build ITK with gdcm official release for windows. But its not having some of file that I'm using in further coding. So I have to use git version of gdcm cause its having those which I needed but following error encountered when I am trying to build ITK with ITK_USE_SYSTEM_GDCM and using gdcm git version to build gdcm bin.
>------ Build started: Project: ITKIOGDCM, Configuration: Debug Win32 ------
80>Compiling...
80>itkGDCMImageIO.cxx
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMImageIO.cxx(41) : fatal error C1083: Cannot open include file: 'gdcmImageHelper.h': No such file or directory
80>itkGDCMSeriesFileNames.cxx
80>D:\ITK\src\Modules\IO\GDCM\include\itkGDCMSeriesFileNames.h(154) : error C2664: 'void gdcm::SerieHelper::AddRestriction(const gdcm::TagKey &)' : cannot convert parameter 1 from 'const std::string' to 'const gdcm::TagKey &'
80> Reason: cannot convert from 'const std::string' to 'const gdcm::TagKey'
80> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(29) : error C2248: 'gdcm::SerieHelper::SerieHelper' : cannot access protected member declared in class 'gdcm::SerieHelper'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(198) : see declaration of 'gdcm::SerieHelper::SerieHelper'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(64) : see declaration of 'gdcm::SerieHelper'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(160) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(160) : error C2227: left of '->IsReadable' must point to class/struct/union/generic type
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(163) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(163) : error C2227: left of '->GetFileName' must point to class/struct/union/generic type
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(166) : error C2027: use of undefined type 'gdcm::File'
80> D:\GDCM\gdcm\src\gdcmSerieHelper.h(34) : see declaration of 'gdcm::File'
80>..\..\..\..\..\src\Modules\IO\GDCM\src\itkGDCMSeriesFileNames.cxx(166) : error C2227: left of '->GetFileName' must point to class/struct/union/generic type
80>itkGDCMImageIOFactory.cxx
80>Generating Code...
80>Build log was saved at "file://d:\ITK\binGDCM\Modules\IO\GDCM\src\ITKIOGDCM.dir\Debug\BuildLog.htm"
80>ITKIOGDCM - 9 error(s), 0 warning(s)
Please help.
You are mixing the very old and deprecated GDCM 1.x with GDCM 2.x. They are actually API incompatible.

Linker error when connecting C to mysql

i want to connect C to mysql using the following code:
#include <C:\Program Files\MySQL\MySQL Connector C 6.0.2\include\my_global.h>
#include <C:\Program Files\MySQL\MySQL Connector C 6.0.2\include\mysql.h>
#include <stdio.h>
MYSQL *conn; /* pointer to connection handler */
int main ( int argc, char *argv[] )
{
conn = mysql_init ( NULL );
mysql_real_connect (
conn,"localhost","root","","operator", 3306, NULL,0 );
mysql_close ( conn );
return 0;
}
When i try to compile ,i get:
Error 3 error LNK2019: unresolved external symbol _mysql_real_connect#32 referenced in function _main C:\Users\kristel\Documents\Visual Studio 2010\Projects\database\database\database.obj database
Error 4 error LNK2019: unresolved external symbol _mysql_init#4 referenced in function _main C:\Users\kristel\Documents\Visual Studio 2010\Projects\database\database\database.obj database
It seems like something is missing but i dont know when.
I have added the mysqllib.lib like in the picture but still the problem is not resolved.
Just another question: Doing my searches,i have found something concerning cmake.Is there any relation between my error and cmake?
Thank you.
While you have included the mySQL header files in your code, you haven't included the mySQL library in your link options.

Weird error compiling code that calls Surface low-level CUDA API

This minimal example:
int main()
{
struct surfaceReference* surfaceReferencePointer;
cudaGetSurfaceReference(&surfaceReferencePointer, "surfaceReference");
}
Fails when it is compiled like this:
nvcc -g -arch=sm_20 -o foo.out foo.cu
Showing the following error message:
foo.cu(4): warning: argument of type "surfaceReference **" is incompatible with parameter of type "const surfaceReference **"
foo.cu(4): warning: argument of type "surfaceReference **" is incompatible with parameter of type "const surfaceReference **"
foo.cu: In function ‘int main()’:
foo.cu:4: error: invalid conversion from ‘surfaceReference**’ to ‘const surfaceReference**’
foo.cu:4: error: initializing argument 1 of ‘cudaError_t cudaGetSurfaceReference(const surfaceReference**, const char*)’
I cannot understand what I am doing wrong. I am compiling on a Linux Ubuntu 64-bit machine, using CUDA 3.2.
The struct surfaceReference* pointer should be defined as const:
int main()
{
const struct surfaceReference* surfaceReferencePointer;
cudaGetSurfaceReference(&surfaceReferencePointer, "surfaceReference");
}
Kudos to codymanix, who provided the right answer in the comments.