peterGraf / pbl

PBL is an MIT License open source C-language library of functions that can be used in a C or C++ project. PBL is highly portable and compiles warning free on Linux gcc, MAC OS X and Windows Microsoft Visual C++ 2010 Express Edition.
http://www.mission-base.com/peter/source/
MIT License
40 stars 12 forks source link

Support MinGW-W64 on Windows? #8

Open dbgrgl opened 1 year ago

dbgrgl commented 1 year ago

After I cloned the repo I found there is no CMakeLists.txt but only a Microsoft Visual Studio solution. I went back to github to read README.md again and it's clear that you only support Visual Studio on Windows. Please consider support MinGW-W64, it's very popular and widely used. I have no idea why you didn't support MinGW-W64 in the first place as it's very similar to Linux GCC.

dbgrgl commented 1 year ago

@peterGraf Turns out you have a makefile located deep in src/src: https://github.com/peterGraf/pbl/blob/master/src/src/makefile

With this makefile it's built out of the box on Cygwin but is problematic on MSYS2 MinGW-W64. I have to add these lines to pblCgi.c to have it compile:

#ifdef __MINGW32__
#include <share.h>
#endif

There are many redefine warnings:

gcc -Wall -O3 -I. -DPBLTEST   -c -o pblkftst.o pblkftst.c
pblkftst.c:968: warning: "KFTST_SHOW_MAIN" redefined
  968 | #define KFTST_SHOW_MAIN 1
      |
pblkftst.c:960: note: this is the location of the previous definition
  960 | #define KFTST_SHOW_MAIN
      |
gcc -O2 -o pblkftst pblkftst.o libpbl.a
gcc -Wall -O3 -I. -DPBLTEST   -c -o pbliftst.o pbliftst.c
pbliftst.c:1067: warning: "_SHOW_ISAM_MAIN" redefined
 1067 | #define _SHOW_ISAM_MAIN 1
      |
pbliftst.c:1059: note: this is the location of the previous definition
 1059 | #define _SHOW_ISAM_MAIN

Finally, it failed at linking:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libpbl.a(pblCgi.o):pblCgi.c:(.text+0x373): undefined reference to `__imp__dupenv_s'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libpbl.a(pblCgi.o):pblCgi.c:(.text+0x6db): undefined reference to `__imp__dupenv_s'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libpbl.a(pblCgi.o):pblCgi.c:(.text+0x2b07): undefined reference to `__imp__dupenv_s'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libpbl.a(pblCgi.o):pblCgi.c:(.text+0x3a7d): undefined reference to `__imp__dupenv_s'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:67: pblPerform] Error 1
djancak commented 1 year ago

i had this issue as well at least got the library itself working now if only i can figure out how to actually use the functions😖