Refs #1270. Switched to building 64-bit versions of the PC tools under Windows. Starting with this commit and the to-be-released OpenBLT version 1.14, the included Windows binaries are all 64-bit. Note that building 32-bit versions is also still supported. Instructions for this can be found on the OpenBLT Wiki.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@941 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2022-02-10 12:10:49 +00:00
parent 6706102797
commit 01e1504737
14 changed files with 91 additions and 37 deletions

Binary file not shown.

Binary file not shown.

View File

@ -73,15 +73,27 @@ set(LIBOPENBLT_LIB ${PROJECT_OUTPUT_DIRECTORY})
#****************************************************************************************
# Compiler flags
#****************************************************************************************
# Set platform specific compiler macro PLATFORM_XXX
# Set platform specific compiler macros PLATFORM_XXX
if(WIN32)
if(CMAKE_C_COMPILER_ID MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
if(CMAKE_C_COMPILER_ID MATCHES GNU)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS")
endif()
endif()
elseif(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -pthread -std=gnu99")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_32BIT -pthread -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_64BIT -pthread -std=gnu99")
endif()
endif(WIN32)
# Configure a statically linked run-time library for msvc

View File

@ -85,15 +85,27 @@ endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
#****************************************************************************************
# Compiler flags
#****************************************************************************************
# Set platform specific compiler macro PLATFORM_XXX
# Set platform specific compiler macros PLATFORM_XXX
if(WIN32)
if(CMAKE_C_COMPILER_ID MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
if(CMAKE_C_COMPILER_ID MATCHES GNU)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS")
endif()
endif()
elseif(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -pthread -std=gnu99")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_32BIT -pthread -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_64BIT -pthread -std=gnu99")
endif()
endif(WIN32)
# Configure a statically linked run-time library for msvc

View File

@ -32,9 +32,9 @@ These run-time libraries can be found in the ./Host directory of the OpenBLT boo
### Configure platform target
Under Microsoft Windows, the LibOpenBLT shared library (**libopenblt.dll**) is 32-bit. For this reason you need to build your own C# program as a 32-bit application as well.
Under Microsoft Windows, the LibOpenBLT shared library (**libopenblt.dll**) is 64-bit ever since OpenBLT version 1.14. For this reason you need to build your own C# program as a 64-bit application as well. To configure this, go to your project's properties in Microsoft Visual Studio. In the *Build* settings, set the **Platform target** to **x64**.
To configure this, go to your project's properties in Microsoft Visual Studio. In the *Build* settings, set the **Platform target** to **x86**.
If you use the LibOpenBLT shared library from before OpenBLT version 1.14 or if you rebuilt it yourself as 32-bit, then you need to build your own C# program as a 32-bit application. To configure this, go to your project's properties in Microsoft Visual Studio. In the *Build* settings, set the **Platform target** to **x86**.
### Example program

View File

@ -41,8 +41,15 @@ namespace OpenBLT
/// </summary>
/// <remarks>
/// Note that under Microsoft Windows, the LibOpenBLT shared library (libopenblt.dll)
/// is 32-bit. For this reason, whatever project uses this wrapper class needs to
/// be built as a 32-bit application.
/// is 64-bit, ever since OpenBLT version 1.14 . For this reason, whatever project
/// uses this wrapper class needs to be built as a 64-bit application.
///
/// To configure this, go to your project's properties in Microsoft Visual Studio.
/// In the "Build" settings, set "Platform target" to "x64".
///
/// When using LibOpenBLT from before OpenBLT version 1.14 or if you rebuild the
/// LibOpenBLT shared library yourself as 32-bit, then your project that uses this
/// wrapper class needs to be built as a 32-bit application.
///
/// To configure this, go to your project's properties in Microsoft Visual Studio.
/// In the "Build" settings, set "Platform target" to "x86".

View File

@ -27,11 +27,9 @@ These run-time libraries can be found in the ./Host directory of the OpenBLT boo
### Lazarus and Delphi specifics on Windows
Under Microsoft Windows, the LibOpenBLT shared library (**libopenblt.dll**) is 32-bit. This means that the application you develop needs to build as a 32-bit application as well.
Under Microsoft Windows, the LibOpenBLT shared library (**libopenblt.dll**) is 64-bit ever since OpenBLT version 1.14. This means that the application you develop needs to build as a 64-bit application as well. When using Lazarus, an easy solution is to install the [64-bit version of Lazarus](https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20bits/). That way your own application automatically builds as a 64-bit application as well. When using Delphi, go to the *Project Manager* and configure just **64-bit Windows platform** for setting **Target Platforms**.
When using Lazarus, an easy solution is to install the 32-bit version of Lazarus. That way your own application automatically builds as a 32-bit application as well. If you already installed the 64-bit version of Lazarus, then you can go to the *Project Options* and set **Target OS** to **Win32** and **Target CPU Family** to **i386**.
When using Delphi, go to the *Project Manager* and configure just **32-bit Windows platform (Win32)** for setting **Target Platforms**.
If you use the LibOpenBLT shared library from before OpenBLT version 1.14 or if you rebuilt it yourself as 32-bit, you need to build your Lazarus application as a 32-bit application. If you install the [32-bit version of Lazarus](https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/), your application by default builds as a 32-bit. When using Delphi, go to the *Project Manager* and configure just **32-bit Windows platform** for setting **Target Platforms**.
### Lazarus specifics on Linux
When running your program under Linux, you will most likely get the following error:

View File

@ -42,4 +42,6 @@ These run-time libraries can be found in the ./Host directory of the OpenBLT boo
Specific on Windows
------------------
Under Microsoft Windows, the LibOpenBLT shared library (libopenblt.dll) is 32-bit. Therefore you need to run your Python application, that makes use of LibOpenBLT, using the 32-bit Python interpreter.
Under Microsoft Windows, the LibOpenBLT shared library (libopenblt.dll) is 64-bit ever since OpenBLT version 1.14. Therefore you need to run your Python application, that makes use of LibOpenBLT, using the 64-bit Python interpreter.
If you use the LibOpenBLT shared library from before OpenBLT version 1.14 or if you rebuilt it yourself as 32-bit, you need to run your Python application using the 32-bit Python interpreter.

View File

@ -35,16 +35,15 @@
#include <stdbool.h> /* for boolean type */
#include <string.h> /* for string library */
#include "candriver.h" /* Generic CAN driver module */
#if defined(PLATFORM_WIN32)
#if defined(PLATFORM_LINUX)
#include "socketcan.h" /* SocketCAN interface */
#else
#include "pcanusb.h" /* Peak PCAN-USB interface */
#include "leaflight.h" /* Kvaser Leaf Light v2 interface */
#include "canusb.h" /* Lawicel CANUSB interface */
#include "xldriver.h" /* Vector XL driver interface */
#include "vcidriver.h" /* Ixxat VCI driver interface */
#endif
#if defined(PLATFORM_LINUX)
#include "socketcan.h" /* SocketCAN interface */
#endif
/****************************************************************************************
@ -83,7 +82,12 @@ void CanInit(tCanSettings const * settings)
/* Determine the pointer to the correct CAN interface, based on the specified
* device name.
*/
#if defined(PLATFORM_WIN32)
#if defined(PLATFORM_LINUX)
/* On Linux, the device name is the name of the SocketCAN link, so always link
* the SocketCAN interface to the CAN driver.
*/
canIfPtr = SocketCanGetInterface();
#else
if (strcmp(settings->devicename, "peak_pcanusb") == 0)
{
canIfPtr = PCanUsbGetInterface();
@ -104,12 +108,6 @@ void CanInit(tCanSettings const * settings)
{
canIfPtr = IxxatVciGetInterface();
}
#endif
#if defined(PLATFORM_LINUX)
/* On Linux, the device name is the name of the SocketCAN link, so always link
* the SocketCAN interface to the CAN driver.
*/
canIfPtr = SocketCanGetInterface();
#endif
/* Check validity of the interface. */
assert(canIfPtr != NULL);

View File

@ -113,6 +113,14 @@
#define _M_BITS 32
#define _M_IX86_ _M_IX86
#define _M_BYTE_ORDER _LITTLE_ENDIAN
#elif !defined(_M_X64_) && defined(_M_X64)
#define _M_BITS 64
#define _M_X64_ _M_X64
#define _M_BYTE_ORDER _LITTLE_ENDIAN
#elif !defined(_M_AMD64_) && defined(_M_AMD64)
#define _M_BITS 64
#define _M_AMD64_ _M_AMD64
#define _M_BYTE_ORDER _LITTLE_ENDIAN
#endif
#endif

View File

@ -589,9 +589,14 @@ static void CanUsbLibLoadDll(void)
canUsbLibFuncStatusPtr = NULL;
canUsbLibFuncSetReceiveCallBackPtr = NULL;
/* Attempt to load the library and obtain a handle to it. */
/* Attempt to load the library and obtain a handle to it. Note that the 32-bit DLL
* has a different name than the 64-bit one.
*/
#ifdef PLATFORM_32BIT
canUsbDllHandle = LoadLibrary("canusbdrv");
#else
canUsbDllHandle = LoadLibrary("canusbdrv64");
#endif
/* Assert libary handle. */
assert(canUsbDllHandle != NULL);

View File

@ -69,15 +69,27 @@ endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
#****************************************************************************************
# Compiler flags
#****************************************************************************************
# Set platform specific compiler macro PLATFORM_XXX
# Set platform specific compiler macros PLATFORM_XXX
if(WIN32)
if(CMAKE_C_COMPILER_ID MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
if(CMAKE_C_COMPILER_ID MATCHES GNU)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS -std=gnu99")
endif()
elseif(CMAKE_C_COMPILER_ID MATCHES MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WIN32 -D_CRT_SECURE_NO_WARNINGS")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_32BIT -D_CRT_SECURE_NO_WARNINGS")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_WINDOWS -DPLATFORM_64BIT -D_CRT_SECURE_NO_WARNINGS")
endif()
endif()
elseif(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -pthread -std=gnu99")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_32BIT -pthread -std=gnu99")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPLATFORM_LINUX -DPLATFORM_64BIT -pthread -std=gnu99")
endif()
endif(WIN32)
# Configure a statically linked run-time library for msvc

Binary file not shown.

Binary file not shown.