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

Fix for compilation error in ppx_cstubs examples #6

Merged
merged 1 commit into from
Aug 13, 2021

Conversation

sidkshatriya
Copy link
Contributor

When issuing make in the ppx_cstubs examples subfolder the following problem is encountered:

ocamlfind: [WARNING] Package `threads': Linking problems may arise because of the missing -thread or -vmthread switch

This eventually ends up in a compiler error:

File "ftw.ml", line 1:
Error: No implementations provided for the following modules:
         Thread referenced from [ETC. ETC.]/_opam/lib/ctypes/ctypes-foreign.cmxa(Foreign)
         Mutex referenced from [ETC. ETC]/_opam/lib/ctypes/ctypes-foreign.cmxa(Foreign)

Other examples e.g. inline.exe etc. also complain about missing -thread

This PR fixes the compilation problem by adding -thread to examples/Makefile


Additionally, I receive the following c-compiler warnings while running make in the examples folder:

ftw_stubs.c: In function ‘ppxc_ftw_c_bf_ftw’:
ftw_stubs.c:75:26: warning: passing argument 2 of ‘ftw’ from incompatible pointer type [-Wincompatible-pointer-types]
   75 |   ppxc__7 = ftw(ppxc__1, ppxc__3, ppxc__5);
      |                          ^~~~~~~
      |                          |
      |                          ppxc_ftw_c_bf_typedef {aka int (*)(char *, void *, int)}
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/limits.h:194,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/9/include/limits.h:34,
                 from [ETC. ETC.]/o412/_opam/lib/ctypes/ctypes_primitives.h:11,
                 from [ETC. ETC.]/o412/_opam/lib/ctypes/ctypes_cstubs_internals.h:13,
                 from ftw_stubs.c:2:
/usr/include/ftw.h:140:12: note: expected ‘__ftw_func_t’ {aka ‘int (*)(const char *, const struct stat *, int)’} but argument is of type ‘ppxc_ftw_c_bf_typedef’ {aka ‘int (*)(char *, void *, int)’}
  140 | extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func,
      |            ^~~~~~~~~~

Are these warnings harmless?

When issuing `make` in the ppx_cstubs `examples` subfolder the following problem is encountered:

ocamlfind: [WARNING] Package `threads': Linking problems may arise because of the missing -thread or -vmthread switch

This eventually ends up in a compiler error:

File "ftw.ml", line 1:
Error: No implementations provided for the following modules:
         Thread referenced from [ETC. ETC.]/_opam/lib/ctypes/ctypes-foreign.cmxa(Foreign)
         Mutex referenced from [ETC. ETC]/_opam/lib/ctypes/ctypes-foreign.cmxa(Foreign)

Other examples e.g. inline.exe etc. also complain about missing -thread
@fdopen fdopen merged commit a175b91 into fdopen:master Aug 13, 2021
@fdopen
Copy link
Owner

fdopen commented Aug 13, 2021

Thanks. I've forgot to update it after
yallop/ocaml-ctypes#651

The warning is currently unavoidable, because ctypes doesn't support cv type qualifiers:
yallop/ocaml-ctypes#134

@sidkshatriya
Copy link
Contributor Author

Thanks for the super-quick merge!

There is something a bit confusing about getting the examples to work. When you try to run make, it complains about ctypes.foreign library being missing. This can be confusing to someone new to ctypes because the user thinks "Hey I already installed the ctypes package!?".

I needed to google this and the fix, of course, is to install the virtual package ctypes-foreign which enables the ctypes.foreign library in the current switch...

Mentioning this here for anybody's future reference. It would also be great if we somehow made this clear in a README.md or automated this in some other way...

fdopen added a commit that referenced this pull request Mar 13, 2022
Fix for compilation error in ppx_cstubs examples
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

Successfully merging this pull request may close these issues.

2 participants