Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

building the library for windows #172

Open
abdelrahman1215 opened this issue Sep 21, 2023 · 6 comments
Open

building the library for windows #172

abdelrahman1215 opened this issue Sep 21, 2023 · 6 comments

Comments

@abdelrahman1215
Copy link

abdelrahman1215 commented Sep 21, 2023

I ran configure with the --prefix=/mingw flag and then when i ran make i got this linker error :

libtool: link: gcc -shared  .libs/libconfuse_la-confuse.o   -lintl  -g -O2   -o .libs/libconfuse-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libconfuse.dll.a
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_free:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:1992: undefined reference to cfg_yylex_destroy
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_init_defaults:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:792: undefined reference to fmemopen
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:801: undefined reference to cfg_scan_fp_begin
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:808: undefined reference to cfg_scan_fp_end
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_parse_internal:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:1287: undefined reference to cfg_yylex
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_addopt:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:627: undefined reference to reallocarray
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_parse_fp:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:1677: undefined reference to cfg_scan_fp_begin
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:1679: undefined reference to cfg_scan_fp_end
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_parse_buf:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:1798: undefined reference to fmemopen
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/libconfuse_la-confuse.o: in function cfg_include:
C:/Users/abder/Downloads/confuse-3.3/src/confuse.c:2011: undefined reference to cfg_lexer_include
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Makefile:452: libconfuse.la] Error 1
make[2]: Leaving directory /c/Users/abder/Downloads/confuse-3.3/src
make[1]: *** [Makefile:520: all-recursive] Error 1
make[1]: Leaving directory /c/Users/abder/Downloads/confuse-3.3
make: *** [Makefile:406: all] Error 2
@troglobit
Copy link
Collaborator

There's a windows/mingw/README.TXT did you see that?

@abdelrahman1215
Copy link
Author

abdelrahman1215 commented Sep 21, 2023 via email

@abdelrahman1215
Copy link
Author

abdelrahman1215 commented Sep 21, 2023

I finally solved the proplem
so this is what i had to do if any one else encounters the same proplem :

  1. I moved the definition of HAVE_WINDOWS_H from config.h to fmemopen.c.
  2. I included reallocarray.c in confuse.c.

@troglobit
Copy link
Collaborator

OK, but none of that should be necessary:

  • config.h should be included in fmemopen.c when HAVE_CONFIG_H is set on the command-line, which is done on all other build targets
  • reallocarray.c is built-in to libconfuse for systems where the configure script cannot find reallocarray() in the libc

Exactly how did you autogen.sh + configure + make libconfuse to get to this state? And what version of libconfuse are you using, or are you building directly from the latest master branch on GitHub?

@abdelrahman1215
Copy link
Author

abdelrahman1215 commented Sep 22, 2023

I downloaded the zip file from the releases page yesterday so i think it is the latest release and i configured and built it using
mingw64 bash i tried to build it multiple times but here is what i did the last time

  1. I decompressed the files agian in case it was corrrupted
  2. I ran configure with no arguments
  3. I ran make to build the dll

when i opened fmemopen.c to see what is the proplem config.h was included and it had HAVE_WINDOWS_H set to 1 but for some reason all the definitions of fmemopen where dark which means that it is not activated due to preprocessors so i moved HAVE_WINDOWS_H from config.h to fmemopen and when i ran make the only error i got was a linker error saying that it couldn't find the definition of realloc_array so i included realloc_array.c in confuse.c and I finally was able to build the dll

@troglobit
Copy link
Collaborator

Thanks for detailing your answer. We'll have a look at it later to see if we can figure out what's wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants