When trying to statically link a program build with this library (-cflags static) it produces a C error on both clang and GCC with mingw.
v -cc gcc -d sokol_d3d11 -cflags "-static" .
================== C compilation error (from gcc): ==============
cc: cc1.exe: note: unrecognized command-line option '-Wno-incompatible-function-pointer-types' may have been intended to silence earlier diagnostics
cc: collect2.exe: error: ld returned 1 exit status
...
cc: collect2.exe: error: ld returned 1 exit status
(note: the original output was 295 lines long; it was truncated to its first 2 lines + the last line)
=================================================================
v -cc gcc -d sokol_d3d11 -cflags "-static -Wno-error -Wno-incompatible-pointer-types" .
================== C compilation error (from gcc): ==============
cc: cc1.exe: note: unrecognized command-line option '-Wno-incompatible-function-pointer-types' may have been intended to silence earlier diagnostics
cc: collect2.exe: error: ld returned 5 exit status
...
cc: collect2.exe: error: ld returned 5 exit status
(note: the original output was 295 lines long; it was truncated to its first 2 lines + the last line)
=================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
v -cc clang -d sokol_d3d11 -cflags "-static -Wno-error -Wno-incompatible-pointer-types" .
================== C compilation error (from clang): ==============
cc: C:/Users/me/AppData/Local/msys2/ucrt64/bin/ld: C:/Users/me/AppData/Local/msys2/ucrt64/lib\libpangoft2-1.0.a(pangofc-decoder.c.obj):(.text+0x1de): undefined reference to `g_return_if_fail_warning'
cc: clang: error: linker command failed with exit code 1 (use -v to see invocation)
...
cc: clang: error: linker command failed with exit code 1 (use -v to see invocation)
(note: the original output was 4263 lines long; it was truncated to its first 2 lines + the last line)
===================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
================== C compiler bug report ==============
Sent C compiler bug report to https://bugs.vlang.io/bug-report.
Report id: 25f2e0d6-be39-4c32-abca-05c9082ae2d7
Delete this report from the server with:
curl -X DELETE "https://bugs.vlang.io/bug-report/25f2e0d6-be39-4c32-abca-05c9082ae2d7?token=9d8b37a8-4a80-4b6d-8ee4-4091831be10f"
Generated C lines sent from C:\Users\local_me\Temp\v_0\emailconv.01KWTDSP8SFXEBK31M7AKPPM99.tmp.c:89346:
89341 |
89342 | #line 338 "C:\\Users\\me\\Downloads\\v_windows\\v\\vlib\\net\\mbedtls\\ssl_connection.c.v"
89343 | VV_LOC void net__mbedtls__SSLListener_init_sni(net__mbedtls__SSLListener* l, _result_net__mbedtls__SSLCerts_ptr (*get_cert_callback)(net__mbedtls__SSLListener* _d1, string _d2)) {
89344 |
89345 | #line 342 "C:\\Users\\me\\Downloads\\v_windows\\v\\vlib\\net\\mbedtls\\ssl_connection.c.v"
> 89346 | mbedtls_ssl_conf_sni(&l->conf, builtin__closure__closure_create_with_data(anon_fn_d6c6ea8a7d32f13e_564_voidptr_ref_C__mbedtls_ssl_context_ref_u8_usize__int_11059, (struct _V_anon_fn_d6c6ea8a7d32f13e_564_voidptr_ref_C__mbedtls_ssl_context_ref_u8_usize__int_11059_Ctx*) builtin__memdup(&(struct _V_anon_fn_d6c6ea8a7d32f13e_564_voidptr_ref_C__mbedtls_ssl_context_ref_u8_usize__int_11059_Ctx){.get_cert_callback = get_cert_callback,
89347 | .l = l,
89348 | }, sizeof(struct _V_anon_fn_d6c6ea8a7d32f13e_564_voidptr_ref_C__mbedtls_ssl_context_ref_u8_usize__int_11059_Ctx)), true), &l->conf);
89349 | GC_reachable_here(&l);
89350 | GC_reachable_here(&get_cert_callback);
89351 | }
Corresponding V lines sent from C:\Users\me\Downloads\v_windows\v\vlib\net\mbedtls\ssl_connection.c.v:342:
337 | // setup SNI callback
338 | fn (mut l SSLListener) init_sni(get_cert_callback fn (mut SSLListener, string) !&SSLCerts) {
339 | $if trace_ssl ? {
340 | eprintln(@METHOD)
341 | }
> 342 | C.mbedtls_ssl_conf_sni(&l.conf, fn [get_cert_callback, mut l] (p_info voidptr, ssl &C.mbedtls_ssl_context, name &u8, lng usize) int {
343 | host := unsafe { name.vstring_literal_with_len(int(lng)) }
344 | if certs := get_cert_callback(mut l, host) {
345 | return C.mbedtls_ssl_set_hs_own_cert(ssl, &certs.client_cert, &certs.client_key)
346 | } else {
347 | return -1
=======================================================
builder error:
==================
C error found while compiling generated C code.
It looks like a C++ header was included with `#include` (for example one that contains `namespace`).
Use a C-compatible header (for HDF5 use `hdf5.h` instead of `H5File.h`), or compile/link the C++ code separately.
v -cc clang -d sokol_d3d11 -cflags "-static" .
================== C compilation error (from clang): ==============
cc: | ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc: C:\Users\me\Downloads\v_windows\v\thirdparty\vschannel/vschannel.c:898:3: error: incompatible pointer types passing 'SOCKADDR_STORAGE *' (aka 'struct sockaddr_storage *') to parameter of type 'LPSOCKADDR' (aka 'struct sockaddr *') [-Wincompatible-pointer-types]
cc: 898 | &local_address, &remote_address_length, &remote_address, &tv, NULL) == FALSE) {
cc: | ^~~~~~~~~~~~~~
cc: C:/Users/me/AppData/Local/msys2/ucrt64/include/winsock2.h:1226:14: note: passing argument to parameter 'LocalAddress' here
cc: 1226 | LPSOCKADDR LocalAddress,
cc: | ^
cc: In file included from C:\\Users\\LOCAL_~4\\Temp\\v_0\\EMB02E~1.C:3987:
cc: C:\Users\me\Downloads\v_windows\v\thirdparty\vschannel/vschannel.c:898:43: error: incompatible pointer types passing 'SOCKADDR_STORAGE *' (aka 'struct sockaddr_storage *') to parameter of type 'LPSOCKADDR' (aka 'struct sockaddr *') [-Wincompatible-pointer-types]
cc: 898 | &local_address, &remote_address_length, &remote_address, &tv, NULL) == FALSE) {
cc: | ^~~~~~~~~~~~~~~
cc: C:/Users/me/AppData/Local/msys2/ucrt64/include/winsock2.h:1228:14: note: passing argument to parameter 'RemoteAddress' here
...
cc: 77 warnings and 11 errors generated.
(note: the original output was 477 lines long; it was truncated to its first 12 lines + the last line)
===================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
================== C compiler bug report ==============
Sent C compiler bug report to https://bugs.vlang.io/bug-report.
Report id: b4ccc62f-aef9-4b33-a0b6-42236ddd4e8c
Delete this report from the server with:
curl -X DELETE "https://bugs.vlang.io/bug-report/b4ccc62f-aef9-4b33-a0b6-42236ddd4e8c?token=bdacb4ac-c1e0-420e-a393-85ecbf369473"
Generated C lines sent from C:\Users\local_me\Temp\v_0\emailconv.01KWTD7SCDZAHX4D0AVMZ037KQ.tmp.c:0:
(no source lines available)
Corresponding V lines sent from C:\Users\me\Downloads\v_windows\v\thirdparty\vschannel/vschannel.c:898:
893 |
894 | WCHAR service_name[10];
895 | int res = wsprintf(service_name, L"%d", port_number);
896 |
897 | if(WSAConnectByNameW(Socket,connect_name, service_name, &local_address_length,
> 898 | &local_address, &remote_address_length, &remote_address, &tv, NULL) == FALSE) {
899 | INT err_code = WSAGetLastError();
900 | vschannel_set_last_error(tls_ctx, err_code);
901 | closesocket(Socket);
902 | return err_code;
903 | }
=======================================================
builder error:
==================
C error found while compiling generated C code.
This can be caused by invalid C interop code, C compiler flags, or a V compiler bug.
If your code is pure V and this still happens, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
When trying to statically link a program build with this library (
-cflags static) it produces a C error on both clang and GCC with mingw.v -cc gcc -d sokol_d3d11 -cflags "-static" .v -cc gcc -d sokol_d3d11 -cflags "-static -Wno-error -Wno-incompatible-pointer-types" .v -cc clang -d sokol_d3d11 -cflags "-static -Wno-error -Wno-incompatible-pointer-types" .v -cc clang -d sokol_d3d11 -cflags "-static" .