Archive for diciembre 2012

h1

Errores portando aplicaciones C++ Windows a Solaris (V)

29/12/2012

Al portar una aplicación C++ para Windows desarrollada en Visual Studio hacia Solaris o entornos Unix, se recomienda utilizar las siguientes conversiones y consejos.

EXCEPCIONES

throw std::bad_exception("cAnsiString::ThrowIfOutOfRange. Index is out of range");
Cambiar por:
throw std::runtime_error("cAnsiString::ThrowIfOutOfRange. Index is out of range");

"src/MonteCarlo/cPathCollection.cpp", line 74: Error: Cannot cast from const char* to std::bad_alloc.
Lanzar la excepción sin ningún parámetro.

std::exception
Cambiar por std::runtime_error

VARIOS
headers/ContractPricing/MarketData/cMarketCurve.h:29: error: expected type-specifier before '...' token
Especificar la excepción, generalmente conocida en su cabecera (si no, indicar “Exceptions::cException”)

ParametricImpliedVolatility/cSliceBasedImpliedVolatility.cpp", line 85: Error: The function "lower_bound" must have a prototype.
Declarar la function en el .h

"src/Stock/LogNormal/cBlackScholesEuropeanOptionPricingAnalyticalProblem.cpp", line 27: Error: Utils::DataContainers::cItemDrivenPtrVectorCollection<ContractPricing::Stock::LogNormal::cBlackScholesEuropeanOptionPricingAnalyticalProblem>::Add(ContractPricing::Stock::LogNormal::cBlackScholesEuropeanOptionPricingAnalyticalProblem*) is not accessible from static ContractPricing::Stock::LogNormal::cBlackScholesEuropeanOptionPricingAnalyticalProblem::AddToCollection(const Utils::Memory::cSharedHeapPtr<ContractPricing::Stock::cEuropeanOptionContract, Utils::Memory::cScalarDestroyer, Utils::Synchronization::cFakeSynchronizer>&, ContractPricing::MarketData::cStockImpliedVolatility*, ContractPricing::MarketData::Test::cYieldCurve*, ContractPricing::MarketData::cDividendYieldCurve*, ContractPricing::MarketData::cStockSpotLevel*, Utils::DataContainers::cItemDrivenPtrVectorCollection<ContractPricing::Stock::LogNormal::cBlackScholesEuropeanOptionPricingAnalyticalProblem>*).
Mover de Private a Public el método.

"headers/HestonUtils.h", line 34: Error: The function "OutputDebugString" must have a prototype.
Sustituirlo por un cout.

h1

Errores portando aplicaciones C++ Windows a Solaris (IV)

29/12/2012

Al portar una aplicación C++ para Windows desarrollada en Visual Studio hacia Solaris o entornos Unix, se recomienda utilizar las siguientes conversiones y consejos.

INCLUDES

src/Utils/sEcoCellRange.cpp", line 72: Error: The function "strdup" must have a prototype.
#include <cstring>

Map is not a member of std
#include <map>

size_t len = ::wcslen(wstr); : Error: wcslen is not a member of std.
#include <cwchar>
using std::wcslen;

"../../arguments/arguments.cpp", line 90: Error: The function "find" must have a prototype.
Añadir “using namespace std;”

String is not defined
añadir “using namespace std;”

"src/Utils/strings/StringUtils.cpp", line 20: Error: iswlower is not a member of std.
#include <wctype.h>

Error: size_t is not defined.
#include <stddef.h>

"headers/Utils/Strings/cAnsiString.h", line 187: Error: runtime_error is not a member of std.
#include <stdexcept>

"src/utils/strings/StringUtils.cpp", line 45: Error: The function "iswspace" must have a prototype.
#include  <wctype.h>

"headers/Utils/Math/cholesky.h", line 18: Error: Utils::Math::Cholesky(Utils::DataContainers::cMatrix&, Utils::DataContainers::cVector&) already had a body defined. comprobar que estén los ifndef´s:
#ifndef __CHOLESKY_H__
#define __CHOLESKY_H__
#enfif

"headers/NormDistr2.h", line 21: Error: Multiple declaration for cRandomNumberGenerator.
incluir en el header los ifndef:
#ifndef __NORMDISTR2__
#define __NORMDISTR2__
(…)
#endif

Namespaces cannot be declared in a class scope
comprobar cabecera.

"storage class extern not allowed for a member"
comprobar cabecera.

"../../EcoLibrary3b/src/cXLGreeks.cpp", line 41: Error: ")" expected instead of "&".
ver que esté declarado igual el método tanto en la cabecera como en el src y que los tipos de los parámetros se resuelven.

#ifdef _WIN32
(… código)
#endif

Muchos constructores no se reconocne en el código pese a que vienen en el .h correspondiente. Suele ocurrir que vienen precedidos en el .h de condicionar de que la plataforma sea WIN32. Al portarlo a Solaris u otra plataforma, hay que eliminar esa condición.

h1

Errores portando aplicaciones C++ Windows a Solaris (III)

29/12/2012

Al portar una aplicación C++ para Windows desarrollada en Visual Studio hacia Solaris o entornos Unix, se recomienda utilizar las siguientes conversiones y consejos.

COMPILADOR

"../boost/boost/config/requires_threads.hpp", line 67: Error: #error "Compiler threading support is not turned on. Please set the correct command line options for threading: -mt".

boost.threads.solaris
Tal y como indica, añadir en la configuración del proyecto el parámetro «-mt».

headers/ContractPricing/MarketData/cTimeSeriesBumper.h:27: error: expected type-specifier
headers/ContractPricing/MarketData/cTimeSeriesBumper.h:27: error: expected `)'

solaris.sunstudio.g++
Se está compilando con g++ (como se puede ver en la consola). En la configuración global del proyecto, no en la del fichero a compilar, se está especificando utilizar el compilador GNU, en vez de como sería correcto, el de SunStudio 12.1.

Sparc/src/cTimeSeries.o ../Util3/dist/Debug/SunStudio_12.1-Solaris-Sparc/libutil3.a ../Util3/dist/Debug/SunStudio_12.1-Solaris-Sparc/libutil3.a ld: fatal: relocation error: R_SPARC_H44: file ../Util3/dist/Debug/SunStudio_12.1-Solaris-Sparc/libutil3.a(MathUtils.o): symbol .rodata (section): relocations based on the ABS44 coding model can not be used in building a shared object
Compilar las librerías de manera dinámica, no estática, tanto en modo release como debug.

"../../HestonLib/headers/cHestonCalibrator.h", line 102: Error: hola is not a member of const Utils::DataContainers::cItemDrivenPtrVectorCollection.
revisar que el fichero que define esa clase no esté repetido varias veces en el proyecto, de modo que aunque el IDE resuelva al sitio correcto, el compilador no.

Hint try checking whether the first non-inlined, non-pure virtual function of class is defined.
reordenar las librerías incluídas en el linkado para que al linkar no se encuentre con ausencias.

ld: warning: file /lib/sparcv9/libnsl.so: attempted multiple inclusion of file Undefined first referenced symbol in file
quitar.libsnl.so
Quitar libnsl.so

undefined first referenced symbol in file solaris
probar a recompilar la librería que incluye ese método como dinámica.

"symbol referencing errors"
Comprobar que esa función esté definida en el .h y desarrollada en el .cpp

h1

Errores portando aplicaciones C++ Windows a Solaris (II)

28/12/2012

Al portar una aplicación C++ para Windows desarrollada enVisual Studio hacia Solaris o entornos Unix, se recomienda utilizar las siguientes conversiones y consejos.

CONVERSIÓN VISUAL STUDIO A C++

Tipos equivalentes en Visual Studio y Solaris:

_isnan → isnan
__Int64 →  long long
PVOID pvData; → typedef void *PVOID;
__forceinline double CALERF(double ARG, int JINT) → inline
const BSTR ToBSTR() const throw (Exceptions::cException); → typedef char* BSTR;

"src/Utils/strings/cAnsiString.cpp", line 707: Error: The function "_snprintf" must have a prototype.
Sustituir por «snprintf»

"headers/Utils/cVariant.h", line 12: Error: Could not open include file<oaidl.h>
Prescindir de él (comentarlo), definiendo las variables como LPVARIANT en cVariant.h (e incluir esta cabecera en su lugar).

m_variant.bstrVal = ::SysAllocString(str);, SysAllocString is not a member of file level
sustituir por algo equivalente a:
m_variant.bstrVal = _bstr_t bstrt(str);

struct cTypeFunction {
enum Type
{
MIN,
MAX,
MULT,
SUM,
};
};

sustituir por algo equivalente a:

struct cTypeFunction
{
typedef enum
{
MIN,
MAX,
MULT,
SUM
} Type;
};

Conversiones habituales de tipos:
typedef unsigned short WORD;
typedef short BOOL;
typedef void *LPVOID;
typedef const void *LPCVOID;
typedef unsigned char UCHAR;
typedef unsigned char *PUCHAR;
typedef unsigned short USHORT;
typedef int32_t LONG;
typedef uint32_t ULONG;
typedef ULONG *PULONG;
typedef ULONG DWORD;
typedef DWORD *PDWORD;
typedef LONG RESPONSECODE;
typedef char *LPSTR;
typedef const char *LPCSTR;
typedef const BYTE *LPCBYTE;
typedef BYTE *LPBYTE;
typedef DWORD *LPDWORD;
typedef void *PVOID;

h1

Errores portando aplicaciones C++ Windows a Solaris (I)

28/12/2012

Al portar una aplicación C++ para Windows desarrollada enVisual Studio hacia Solaris o entornos Unix, se recomienda utilizar las siguientes conversiones y consejos:

PROGRAMACIÓN

"src/ImpliedVolsCalculation/cHestonPricerUtils.cpp", line 362: Error: Overloading ambiguity between "DateTime::operator+(const DateTime::cDate&, const DateTime::cPeriod&)" and "built-in operator+(long, const wchar_t*)"
Separar la suma en dos líneas.

Error: Could not find a match for Utils::Strings::CaseInsensitiveCompare(char*const, const wchar_t[4]) needed in static ContractPricing::MarketData::cXLCapletBlackVolatilityMatrixBuilder::ReadCapletStrikes(void**const).:if (Utils::Strings::CaseInsensitiveCompare(var[0][k].ToBSTR(), L"ATM"))
Cambiar L”ATM” (formatoUnicode) por ”ATM”

c++ is multiply defined
Probablemente una variable está duplicada en dos ficheros, empezar buscando que el mismo fichero al que referencia el compilador no esté duplicado…

namespaces cannot be declared in a class scope
Mover los inlines que haya declarados fuera de la clase a dentro de la clase, eliminando los namespaces de esos métodos. Y comprobar que la llave que cierra el namespace NO lleve un “;”

cannot have a using directive in a class
Comentar el using.

String is not defined
Añadir “using namespace std;”

c++ +"is not a static data member"
Comprobar los parámetros (los tipos concretamente, que existan) del constructor.

"src/cHestonAnalyticalSolver.cpp", line 86: Error: Too many arguments in call to "std::complex<double>::real() const".
El método .real() no admite parámetros en Solaris, es necesario salvar los resultados de los cálculos en una nueva variable de nombre distinto y devolver esa.

cannot create a variable for abstract class cAutocallSwapEngine
Ver la clase de la que hereda, pues hay algún parámetro que probablemente falte en sus constructores y virtuales.

"../../Include/Heston/HestonPricingInputData.h", line 269: Error: ")" expected instead of "<".
Añadir el espacio de nombres “using namespace std;”

"template vector is not defined"
añadir “using namespace std”;

h1

Joomla, an error occurred while processing this directive, SHTML Wrapper 500 Server Error

26/12/2012

Si al instalar un sitio con Joomla, se produce este error:

[an error occurred while processing this directive]
SHTML Wrapper - 500 Server Error

es necesario activar la extensión FastCGI de PHP. Si se dispone de un host ajeno (Hostmonster, Dreamspace, etc), se puede hacer accediendo al panel de control o contactando con el departamento de soporte.

PHP 5.2 (FastCGI)
All files with the extension .php will be handled by PHP 5.2 FastCGI processes.
FastCGI for PHP makes all your PHP applications run through mod_fastcgi instead of mod_suphp. This eliminates the overhead of loading the PHP interpreter on every hit. Since it is always in memory ready for the next hit, the responses will be generated faster.