libmodbus in MFC

2020-05-07 23:57发布

问题:

I am trying to integrate modbus library given by libmodbus into a custom MFC project in Visual Studio 2010.

The steps that I have followed till now are as follows:

1) I have created project in Visual Studio 2010 as shown in snapshots below:

2) I have edited the code to include a small hello world code just to check if it compiles.

3) I have copied .c and .h files from src folder of libmodbus-3.0.3 to Visual Studio project folder as shown below and included them in the project.

4) When I try to compile, it gives me following error:

My doubts are as follows:

1) Have I included libmodbus correctly in my project? Or is there a better or correct way to do the same?

2) How to eliminate the error that is coming: Cannot open include file: 'config.h'. No such file or directory.
I have seen that there is no config.h file in the libmodbus-3.0.3 that I have downloaded from http://libmodbus.org/download/
How to proceed ahead?

Thank you.

回答1:

Latest version of libmodbus provides Visual Studio project files.

https://github.com/stephane/libmodbus/tree/master/src/win32