Compilation failure on Windows with libmodbus-3.1.10_VS2008_X64.zip

12 views
Skip to first unread message

Gerard Schipper

unread,
Oct 28, 2024, 10:37:42 AM10/28/24
to libmodbus
Hello,

I try to compile the example program of the Getting Started on Windows but it fails so far with unknown typedefs. Modbus.h also can not find the corrects typedefs located in stdint.h or cstdint.

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include\cstdint(21,25): error C2039: 'int8_t': is not a member of '`global namespace''

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\include\cstdint(21,13): error C2873: 'int8_t': symbol cannot be used in a using-declaration

and many more errors

typedefs_fail.jpg
The folder C:/Program Files/libmodbus/include/ contains:
 - modbus.h
- modbus-rtu.h
- modbus-tcp.h
- modbus-version.h
- stdint.h

The folder C:/Program Files/libmodbus/lib/x64/Release/ contains:
 - modbus.dll
 - modbus.lib

My CMakeLists.txt look s like.
```
cmake_minimum_required(VERSION 3.20)

set(PROJECT_NAME modbusTcp)

project(${PROJECT_NAME} VERSION 0.1)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

link_directories("C:/Program Files/libmodbus/lib/x64/Release/")
include_directories("C:/Program Files/libmodbus/include/")

add_executable(${PROJECT_NAME}
src/main.cpp)

target_link_libraries(${PROJECT_NAME} wsock32 ws2_32)
target_link_libraries(${PROJECT_NAME} libmodbus)
```
Any idea how to solve the problem and compile correctly?




Emrah Ali PEKDEMİR

unread,
Dec 12, 2024, 5:38:19 AM12/12/24
to libmodbus
stdint.h contains those datatypes.
Reply all
Reply to author
Forward
0 new messages