Skip to content

Commit

Permalink
Merge pull request #4539 from NREL/MinGWbuild
Browse files Browse the repository at this point in the history
Fix third-party library builds on MinGW.
  • Loading branch information
jasondegraw committed Feb 27, 2015
2 parents bcc3d7a + 0b5170c commit e5c9e89
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 65 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
7 changes: 6 additions & 1 deletion src/EnergyPlus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/EnergyPlusPgm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions third_party/BCVTB/utilSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
/// [email protected]
///
Expand All @@ -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.
Expand All @@ -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 <windows.h>
#include <winsock.h>

Expand All @@ -120,7 +120,7 @@ derivative works thereof, in binary and source code form.
#include <arpa/inet.h>
#include <sys/socket.h>
//#include <netinet/in.h>
#include <netdb.h>
#include <netdb.h>
#endif

#include <stdio.h>
Expand Down Expand Up @@ -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.
Expand All @@ -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);


Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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[]);
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions third_party/Expat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down
2 changes: 2 additions & 0 deletions third_party/FMI/fmumini.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@
#define MAXFILENAME (256)

#ifdef _WIN32
#ifndef __MINGW32__
#define USEWIN32IOAPI
#include <zlib/contrib/minizip/iowin32.h>
#endif
#endif
/*
mini unzip, demo of unzip package
Expand Down
84 changes: 42 additions & 42 deletions third_party/FMI/main.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
/* -------------------------------------------------------------------------
/* -------------------------------------------------------------------------
///////////////////////////////////////////////////////
/// \file main.h
///
/// \author Thierry Stephane Nouidui,
/// Simulation Research Group,
/// Simulation Research Group,
/// LBNL,
/// [email protected]
///
/// \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 <windows.h>
#define WINDOWS 1
#else
Expand All @@ -38,95 +38,95 @@
#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{
int index;
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);
Expand Down
2 changes: 1 addition & 1 deletion third_party/FMI/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///
///////////////////////////////////////////////////////

#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>
#define WINDOWS 1
#else
Expand Down
2 changes: 2 additions & 0 deletions third_party/FMUParser/fmumini.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@
#define MAXFILENAME (256)

#ifdef _WIN32
#ifndef __MINGW32__
#define USEWIN32IOAPI
#include <zlib/contrib/minizip/iowin32.h>
#endif
#endif
/*
mini unzip, demo of unzip package
Expand Down
4 changes: 2 additions & 2 deletions third_party/FMUParser/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <stdlib.h>
#include <string.h>

#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>
#define WINDOWS 1
#else
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion third_party/FMUParser/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///
///////////////////////////////////////////////////////

#ifdef _MSC_VER
#ifdef _WIN32
#include <windows.h>
#define WINDOWS 1
#else
Expand Down

7 comments on commit e5c9e89

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - x86_64-MacOS-10.9-clang: OK (1119 of 1119 tests passed)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - i386-Windows-7-VisualStudio-12: OK (1122 of 1122 tests passed)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - x86_64-Linux-Ubuntu-14.04-gcc-4.8: OK (1122 of 1122 tests passed)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-UnitTestsCoverage-Debug: OK (622 of 622 tests passed)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - Win64-Windows-7-VisualStudio-12: OK (1122 of 1122 tests passed)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jasondegraw) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-IntegrationCoverage-Debug: OK (1121 of 1122 tests passed)

Build Badge Test Badge Coverage Badge

Please sign in to comment.