Moxa PComm.lib with g++ under mingw64: file format not recognized

495 Views Asked by At

I am refactoring an old Borland C/C++98 program. I would like to program it under linux platform but to beginning, as I have severals additionnals boards, I clean the program, remove all GUI OWL and make tests under win7 and mingw64 to use modern gcc/g++.

I actually try to link a sample code that use C320 turbo Moxa multiport serial board. As mentionned in http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use it should link .lib and .dll.

So I tried to link my sample with Moxa PComm.lib for sio_open, sio_read, sio_write… functions as

g++ -m32 -Wall -std=c++14 src/main.cpp src/rs232_c320t.cpp … -L./lib -lPComm

and it returns

./lib/PComm.lib: file not recognized: File format not recognized

Are there any options to allow link windows .lib with gcc/g++ under mingw64?

Thanks

This related "Linking *.lib files with MinGW" question doesn't mention "File format not recognize" error. See also my comments below.

bcag2

1

There are 1 best solutions below

0
On BEST ANSWER

I downloaded last PCommLite for win7 x64.

Copy C:\Program Files\Moxa\PCommLite 1.6\Include\PCOMM.H in my include project folder (lib in my case), and do the same for files PCOMM.dll and PCOMM.lib in C:\Program Files\Moxa\PCommLite 1.6\Lib\x64.

Then I compile with:

g++ -c -std=c++14 -D_hypot=hypot -DWIN32 src/*.cpp -I./lib/

Where -I./lib give access to PCOMM.H and link with:

g++ -shared *.o lib/PCOMM.LIB /c/Windows/System32/msvcr120.dll /c/ProgramData/Anaconda3/python36.dll -o _project.pyd

Of course you can do all in one time and create an .exe:

g++ -o project.exe -Wall -std=c++14 -DWIN32 src/*.cpp -Ilib/ lib/PCOMM.LIB -L./lib/

NO -ansi required as suggested by Moxa support!