diff --git a/CMakeLists.txt b/CMakeLists.txt index dceeb3d61df..6f8122e83f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,10 @@ if (MSVC) set(gtest_force_shared_crt ON) endif() +if (MINGW) + set(CMAKE_SHARED_LIBRARY_PREFIX "") +endif () + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Products" ) diff --git a/src/EnergyPlus/CMakeLists.txt b/src/EnergyPlus/CMakeLists.txt index 4b13272f869..6d1570cd127 100644 --- a/src/EnergyPlus/CMakeLists.txt +++ b/src/EnergyPlus/CMakeLists.txt @@ -570,7 +570,12 @@ install( TARGETS energyplusapi LIBRARY DESTINATION ./ ) -if (CMAKE_COMPILER_IS_GNUCXX AND ENABLE_LTO) +if (MINGW) + target_link_libraries( energypluslib2 energypluslib ) + target_link_libraries( energypluslib energypluslib2 ) + add_executable( energyplus main.cc ) + target_link_libraries( energyplus energyplusapi ) +elseif (CMAKE_COMPILER_IS_GNUCXX AND ENABLE_LTO) target_link_libraries( energypluslib2 energypluslib ) target_link_libraries( energypluslib energypluslib2 ) add_executable( energyplus main.cc "EnergyPlusPgm.cc" "public/EnergyPlusPgm.hh" ) diff --git a/src/EnergyPlus/EnergyPlusPgm.cc b/src/EnergyPlus/EnergyPlusPgm.cc index 7dd3ce5ec77..d937ab28f5b 100644 --- a/src/EnergyPlus/EnergyPlusPgm.cc +++ b/src/EnergyPlus/EnergyPlusPgm.cc @@ -239,9 +239,9 @@ EnergyPlusPgm( std::string const & filepath ) #endif #endif -#ifdef _WIN32 +#ifdef _MSC_VER #ifndef _DEBUG - // If WIN32 and not debug then prevent dialogs on error + // If _MSC_VER and not debug then prevent dialogs on error SetErrorMode(SEM_NOGPFAULTERRORBOX); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); diff --git a/third_party/BCVTB/utilSocket.h b/third_party/BCVTB/utilSocket.h index 0d4190ca895..e32474681a6 100644 --- a/third_party/BCVTB/utilSocket.h +++ b/third_party/BCVTB/utilSocket.h @@ -48,7 +48,7 @@ modification, are permitted provided that the following conditions are met: 3. Neither the name of the University of California, Lawrence Berkeley National Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -83,7 +83,7 @@ derivative works thereof, in binary and source code form. /// using BSD sockets. /// /// \author Michael Wetter, -/// Simulation Research Group, +/// Simulation Research Group, /// LBNL, /// MWetter@lbl.gov /// @@ -94,7 +94,7 @@ derivative works thereof, in binary and source code form. /// This file provides methods that allow clients to /// establish a socket connection. Clients typically call /// the method \c establishclientsocket() -/// once, and then call the method +/// once, and then call the method /// \c exchangedoubleswithsocket() in each time step. /// At the end of the simulation, a client should call /// \c closeipc() to close the socket connection. @@ -108,7 +108,7 @@ derivative works thereof, in binary and source code form. /////////////////////////////////////////////////////// #ifndef _UTILSOCKET_H_ #define _UTILSOCKET_H_ -#ifdef _MSC_VER // Microsoft compiler +#ifdef _WIN32 // Windows compiler #include #include @@ -120,7 +120,7 @@ derivative works thereof, in binary and source code form. #include #include //#include -#include +#include #endif #include @@ -180,7 +180,7 @@ int assembleBuffer(int flag, /// Gets an integer and does the required error checking. /// ///\param nptr Pointer to character buffer that contains the number. -///\param endptr After return, this variable contains a pointer to the +///\param endptr After return, this variable contains a pointer to the /// character after the last character of the number. ///\param base Base for the integer. ///\param The value contained in the character buffer. @@ -192,11 +192,11 @@ int getIntCheckError(const char *nptr, char **endptr, const int base, /// Gets a double and does the required error checking. /// ///\param nptr Pointer to character buffer that contains the number. -///\param endptr After return, this variable contains a pointer to the +///\param endptr After return, this variable contains a pointer to the /// character after the last character of the number. ///\param The value contained in the character buffer. ///\return 0 if no error occurred. -int getDoubleCheckError(const char *nptr, char **endptr, +int getDoubleCheckError(const char *nptr, char **endptr, double* val); @@ -286,7 +286,7 @@ int establishclientsocket(const char *const docname); ///\param boolValWri Boolean values to write. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send, or a negative value if an error occured. -int writetosocket(const int *sockfd, +int writetosocket(const int *sockfd, const int *flaWri, const int *nDblWri, const int *nIntWri, const int *nBooWri, double *curSimTim, @@ -303,7 +303,7 @@ int writetosocket(const int *sockfd, /// +1: simulation reached end time. /// -1: simulation terminates due to an (unspecified) error. /// -10: simulation terminates due to error during initialization. -/// -20: simulation terminates due to error during time integration. +/// -20: simulation terminates due to error during time integration. /// ///\param sockfd Socket file descripter ///\param flaWri Flag to be sent to the BCVTB @@ -353,7 +353,7 @@ int getrequiredbufferlength(const int nDbl, const int nInt, const int nBoo); ///\param intValRea Integer values read from socket. ///\param boolValRea Boolean values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) -int readfromsocket(const int *sockfd, int *flaRea, +int readfromsocket(const int *sockfd, int *flaRea, int *nDblRea, int *nIntRea, int *nBooRea, double *curSimTim, double dblValRea[], int intValRea[], int booValRea[]); @@ -393,7 +393,7 @@ int readbufferfromsocket(const int *sockfd, ///\param boolValRea Boolean values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangewithsocket(const int *sockfd, +int exchangewithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, const int *nIntWri, const int *nBooWri, int *nDblRea, int *nIntRea, int *nBooRea, @@ -417,7 +417,7 @@ int exchangewithsocket(const int *sockfd, ///\param dblValRea Double values read from socket. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangedoubleswithsocket(const int *sockfd, +int exchangedoubleswithsocket(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, @@ -444,7 +444,7 @@ int exchangedoubleswithsocket(const int *sockfd, ///\param flaexport Flag for FMUExport. ///\sa int establishclientsocket(uint16_t *portNo) ///\return The exit value of \c send or \c read, or a negative value if an error occured. -int exchangedoubleswithsocketFMU(const int *sockfd, +int exchangedoubleswithsocketFMU(const int *sockfd, const int *flaWri, int *flaRea, const int *nDblWri, int *nDblRea, diff --git a/third_party/Expat/CMakeLists.txt b/third_party/Expat/CMakeLists.txt index 2450ea81f81..2259f5e48d3 100644 --- a/third_party/Expat/CMakeLists.txt +++ b/third_party/Expat/CMakeLists.txt @@ -14,9 +14,9 @@ lib/xmltok_impl.c lib/xmltok_ns.c ) -if(WIN32) +if(MSVC) set(epexpat_SRCS ${epexpat_SRCS} lib/libexpat.def) -endif(WIN32) +endif(MSVC) IF( MSVC ) ADD_DEFINITIONS( "/w" ) diff --git a/third_party/FMI/fmumini.c b/third_party/FMI/fmumini.c index 3f41484e071..0de3b1ba2cf 100644 --- a/third_party/FMI/fmumini.c +++ b/third_party/FMI/fmumini.c @@ -77,9 +77,11 @@ #define MAXFILENAME (256) #ifdef _WIN32 +#ifndef __MINGW32__ #define USEWIN32IOAPI #include #endif +#endif /* mini unzip, demo of unzip package diff --git a/third_party/FMI/main.h b/third_party/FMI/main.h index ff75305b135..90abc34a3f5 100644 --- a/third_party/FMI/main.h +++ b/third_party/FMI/main.h @@ -1,30 +1,30 @@ -/* ------------------------------------------------------------------------- +/* ------------------------------------------------------------------------- /////////////////////////////////////////////////////// /// \file main.h /// /// \author Thierry Stephane Nouidui, -/// Simulation Research Group, +/// Simulation Research Group, /// LBNL, /// TSNouidui@lbl.gov /// /// \date 2011-10-11 /// -/// This files contains the definition of all -/// energyplus functions that are needed to mapped +/// This files contains the definition of all +/// energyplus functions that are needed to mapped /// to fmiFunctions /// This file is based on main.h that is copyrighted by -/// QTronic GmbH and that is distributed under the BSD license. -/// Function types for all FMU functions and a struct to wrap a FMU dll. -/// Copyright 2010 QTronic GmbH. All rights reserved. +/// QTronic GmbH and that is distributed under the BSD license. +/// Function types for all FMU functions and a struct to wrap a FMU dll. +/// Copyright 2010 QTronic GmbH. All rights reserved. /// ------------------------------------------------------------------------- */ #ifndef main_h #define main_h -// Use windows.h only for Windows -#ifdef _MSC_VER +// Use windows.h only for Windows +#ifdef _WIN32 #include #define WINDOWS 1 #else @@ -38,27 +38,27 @@ #include "xml_parser_cosim.h" #include "eplusModelFunctions.h" -typedef const char* (*fGetTypesPlatform)(); +typedef const char* (*fGetTypesPlatform)(); typedef const char* (*fGetVersion)(); -typedef fmiComponent (*fInstantiateSlave)(fmiString instanceName, fmiString GUID, - fmiString fmuLocation, fmiString mimeType, fmiReal timeout, - fmiBoolean visible, fmiBoolean interactive, - fmiCallbackFunctions functions, fmiBoolean loggingOn); -typedef void (*fFreeSlaveInstance) (fmiComponent c); -typedef fmiStatus (*fResetSlaveInstance) (fmiComponent c); +typedef fmiComponent (*fInstantiateSlave)(fmiString instanceName, fmiString GUID, + fmiString fmuLocation, fmiString mimeType, fmiReal timeout, + fmiBoolean visible, fmiBoolean interactive, + fmiCallbackFunctions functions, fmiBoolean loggingOn); +typedef void (*fFreeSlaveInstance) (fmiComponent c); +typedef fmiStatus (*fResetSlaveInstance) (fmiComponent c); typedef fmiStatus (*fSetDebugLogging) (fmiComponent c, fmiBoolean loggingOn); typedef fmiStatus (*fSetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiReal value[]); typedef fmiStatus (*fSetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiInteger value[]); typedef fmiStatus (*fSetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiBoolean value[]); typedef fmiStatus (*fSetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, const fmiString value[]); -typedef fmiStatus (*fInitializeSlave)(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop); +typedef fmiStatus (*fInitializeSlave)(fmiComponent c, fmiReal tStart, fmiBoolean StopTimeDefined, fmiReal tStop); typedef fmiStatus (*fGetReal) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]); typedef fmiStatus (*fGetInteger)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiInteger value[]); typedef fmiStatus (*fGetBoolean)(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiBoolean value[]); typedef fmiStatus (*fGetString) (fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiString value[]); -typedef fmiStatus (*fDoStep) (fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, +typedef fmiStatus (*fDoStep) (fmiComponent c, fmiReal currentCommunicationPoint, fmiReal communicationStepSize, fmiBoolean newStep); // Zuo: add for co-sim typedef struct FMU{ @@ -66,67 +66,67 @@ typedef struct FMU{ fmiString modelID; fmiString modelGUID; ModelDescription* modelDescription; - HANDLE dllHandle; - fGetTypesPlatform getTypesPlatform; - fGetVersion getVersion; - fInstantiateSlave instantiateSlave; - fFreeSlaveInstance freeSlaveInstance; - fResetSlaveInstance resetSlaveInstance; + HANDLE dllHandle; + fGetTypesPlatform getTypesPlatform; + fGetVersion getVersion; + fInstantiateSlave instantiateSlave; + fFreeSlaveInstance freeSlaveInstance; + fResetSlaveInstance resetSlaveInstance; fSetDebugLogging setDebugLogging; fSetReal setReal; fSetInteger setInteger; fSetBoolean setBoolean; fSetString setString; - fInitializeSlave initializeSlave; + fInitializeSlave initializeSlave; fGetReal getReal; fGetInteger getInteger; fGetBoolean getBoolean; fGetString getString; - fDoStep doStep; + fDoStep doStep; } FMU; fmiComponent fmiEPlusInstantiateSlave(char* fmuResFolder, - fmiInteger *sizefmuResFolder, fmiReal *timeOut, fmiInteger *visible, + fmiInteger *sizefmuResFolder, fmiReal *timeOut, fmiInteger *visible, fmiInteger *interactive, fmiInteger *loggingOn, fmiInteger *index); -fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance, +fmiStatus fmiEPlusInitializeSlave(fmiComponent *fmuInstance, fmiReal *tStart, fmiInteger *newStep, fmiReal *tStop, fmiInteger *index); -fmiStatus fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef [], +fmiStatus fmiEPlusGetReal(fmiComponent *fmuInstance, const fmiValueReference valRef [], fmiReal outValue[], fmiInteger *numOutputs, fmiInteger *index); -fmiStatus fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], +fmiStatus fmiEPlusSetReal(fmiComponent *fmuInstance, const fmiValueReference valRef[], fmiReal inpVal[], fmiInteger *numInputs, fmiInteger *index); -fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint, +fmiStatus fmiEPlusDoStep(fmiComponent *fmuInstance, fmiReal *curCommPoint, fmiReal *commStepSize, fmiInteger *newStep, fmiInteger *index); fmiStatus fmiEPlusFreeSlave(fmiComponent *fmuInstance, fmiInteger *index); -fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index); +fmiStatus fmiEPlusResetSlave(fmiComponent *fmuInstance, fmiInteger *index); -fmiInteger fmiEPlusUnpack(char* fmuName, char* fmuOutputWorkingFolder, - fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder); +fmiInteger fmiEPlusUnpack(char* fmuName, char* fmuOutputWorkingFolder, + fmiInteger *sizefmuName, fmiInteger *sizefmuOutputWorkingFolder); -fmiInteger addLibPathCurrentWorkingFolder(char* trimfmuOutputWorkingFolder_wLiB, - char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, +fmiInteger addLibPathCurrentWorkingFolder(char* trimfmuOutputWorkingFolder_wLiB, + char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, fmiInteger *index); -fmiInteger getValueReferenceByNameFMUInputVariables(char* variableName, +fmiInteger getValueReferenceByNameFMUInputVariables(char* variableName, fmiInteger *sizeVariableName, fmiInteger *index); -fmiInteger getValueReferenceByNameFMUOutputVariables(char* variableName, +fmiInteger getValueReferenceByNameFMUOutputVariables(char* variableName, fmiInteger *sizeVariableName, fmiInteger *index); -fmiInteger model_ID_GUID(char* fmuWorkingFolder, - fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs, +fmiInteger model_ID_GUID(char* fmuWorkingFolder, + fmiInteger *sizefmuWorkingFolder, fmiInteger *numInputs, fmiInteger *numOutputs); -fmiInteger addFMURootFolderName(char* fmuOutputWorkingFolder, +fmiInteger addFMURootFolderName(char* fmuOutputWorkingFolder, char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder); -fmiInteger getfmiEPlusVersion(char* fmuWorkingFolder, +fmiInteger getfmiEPlusVersion(char* fmuWorkingFolder, fmiInteger *sizefmuWorkingFolder, char *fmiVersionNumber, fmiInteger *index); fmiInteger checkOperatingSystem(char* errorMessage); diff --git a/third_party/FMI/util.h b/third_party/FMI/util.h index 337012de589..9c78e2939a1 100644 --- a/third_party/FMI/util.h +++ b/third_party/FMI/util.h @@ -15,7 +15,7 @@ /// /////////////////////////////////////////////////////// -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else diff --git a/third_party/FMUParser/fmumini.c b/third_party/FMUParser/fmumini.c index bca5931eb81..06eb1db804a 100644 --- a/third_party/FMUParser/fmumini.c +++ b/third_party/FMUParser/fmumini.c @@ -69,9 +69,11 @@ #define MAXFILENAME (256) #ifdef _WIN32 +#ifndef __MINGW32__ #define USEWIN32IOAPI #include #endif +#endif /* mini unzip, demo of unzip package diff --git a/third_party/FMUParser/parser.h b/third_party/FMUParser/parser.h index cf89a776ba2..0863f0cfd78 100644 --- a/third_party/FMUParser/parser.h +++ b/third_party/FMUParser/parser.h @@ -24,7 +24,7 @@ #include #include -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else @@ -77,7 +77,7 @@ typedef fmiStatus (*fGetNominalContinuousStates)(fmiComponent c, fmiReal x_nomin typedef fmiStatus (*fGetStateValueReferences) (fmiComponent c, fmiValueReference vrx[], size_t nx); typedef fmiStatus (*fTerminate) (fmiComponent c); -typedef enum {opt_printidf, opt_delete, opt_unpack, opt_help} option; +typedef enum {opt_printidf, opt_delete, opt_unpack, opt_help} option; typedef struct { diff --git a/third_party/FMUParser/util.h b/third_party/FMUParser/util.h index 337012de589..9c78e2939a1 100644 --- a/third_party/FMUParser/util.h +++ b/third_party/FMUParser/util.h @@ -15,7 +15,7 @@ /// /////////////////////////////////////////////////////// -#ifdef _MSC_VER +#ifdef _WIN32 #include #define WINDOWS 1 #else