Open Avey777 opened 5 months ago
@JalonSolov
Can you help me with this issue? I'm going to change my development machine to MacOS, but the same code doesn't work properly.
Do brew install mariadb-connector-c
. After that, the compilation should succeed.
Do . After that, the compilation should succeed.
brew install mariadb-connector-c
avey@avey vprod % brew install mariadb-connector-c
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
vedic
==> New Casks
blitz-gg font-playwrite-es-deco font-playwrite-nz
font-playwrite-au-nsw font-playwrite-fr-moderne font-playwrite-tz
font-playwrite-au-qld font-playwrite-id font-playwrite-us-modern
font-playwrite-au-sa font-playwrite-ie font-playwrite-us-trad
font-playwrite-au-tas font-playwrite-in font-playwrite-za
font-playwrite-au-vic font-playwrite-it-moderna hopper-disassembler
font-playwrite-ca font-playwrite-it-trad mac-mouse-fix@2
font-playwrite-de-la font-playwrite-mx
font-playwrite-es font-playwrite-ng-modern
==> Fetching mariadb-connector-c
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/mariadb-connector-c-3.3.8.ventura.bo
########################################################################################## 100.0%
==> Pouring mariadb-connector-c-3.3.8.ventura.bottle.tar.gz
🍺 /usr/local/Cellar/mariadb-connector-c/3.3.8: 154 files, 1.4MB
==> Running `brew cleanup mariadb-connector-c`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
avey@avey vprod % v run .
==================
^
/tmp/v_501/vprod.01HYTDZGRX2RM40608QES0N7XJ.tmp.c:35966:6: error: call to undeclared function 'mysql_refresh'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if (mysql_refresh(db->conn, options) != 0) {
^
/tmp/v_501/vprod.01HYTDZGRX2RM40608QES0N7XJ.tmp.c:36018:42: warning: passing 'const char *' to parameter of type 'u8 *' (aka 'unsigned char *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
string _t1 = db__mysql__resolve_nil_str(mysql_info(db->conn));
^~~~~~~~~~~~~~~~~~~~
/tmp/v_501/vprod.01HYTDZGRX2RM40608QES0N7XJ.tmp.c:6966:55: note: passing argument to parameter 'ptr' here
VV_LOCAL_SYMBOL string db__mysql__resolve_nil_str(u8* ptr);
^
/tmp/v_501/vprod.01HYTDZGRX2RM40608QES0N7XJ.tmp.c:36023:26: warning: passing 'const char *' to parameter of type 'u8 *' (aka 'unsigned char *') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
string _t1 = u8_vstring(mysql_get_host_info(db->conn));
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, 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 .
avey@avey vprod %
I have executed brew install mysql-connector-c
before, but I still get this error. It should not be a problem with the mysql environment configuration.
1、
run find /opt/homebrew/ |grep mysql.h$ and paste the results
if that fails, do
find /usr/local/Cellar/ |grep mysql.h$ and paste the results
2、
brew install pkg-config
3、
pkg-config libmariadb --cflags --libs
pkg-config mysqlclient --cflags --libs
4、
brew install mariadb-connector-c
instead of
brew install mysql-clinet
5、
v -cflags '-I/usr/local/Cellar/mariadb-connector-c/3.3.8/include/mariadb/ -L/usr/local/Cellar/mariadb-connector-c/3.3.8/lib/mariadb/ -lmariadb' run main.v
eg: the mysql 8.3 headers lack the mysql_refresh function and some others (they were deprecated)
I'll fix the C driver issue for all 3 DBs today.
The C driver will be included, and none of this will be needed.
I'll fix the C driver issue for all 3 DBs today.
The C driver will be included, and none of this will be needed.
Has this been fixed? I didn't find a similar fix code commit
No, it is not fixed.
The C driver will be included, and none of this will be needed.
It can be done cleanly only for db.sqlite
, since SQLite provides an amalgamation that contains the whole DB. You can use v install sqlite
and then import sqlite
, instead of import db.sqlite
.
This issue however is for mysql, and mysql's client side libraries, are not unfortunately as easy to compile and use, as SQLite ones are, that is why we try to use pkgconfig, so that we can link to the already compiled ones.
Given this strategy, the issue happens, because our version of pkgconfig, on macos looks for /opt/homebrew/lib/pkgconfig
for the .pc files on macos, while brew on macos for Intel, stores its files under /usr/local/Cellar
, not under /opt/homebrew
.
A thing you could do already, is adding the different flags directly in you program.
To give an example of the concept:
// Intel, M1 brew, and MacPorts
#flag darwin -I/usr/local/opt/openblas/include -I/opt/homebrew/opt/openblas/include -I/opt/local/opt/openblas/include
#flag darwin -L/usr/local/opt/openblas/lib -L/opt/homebrew/opt/openblas/lib -L/opt/local/opt/openblas/lib
#flag darwin -L/usr/local/opt/lapack/lib -L/opt/homebrew/opt/lapack/lib -L/opt/local/opt/lapack/lib
The above is taken from: https://github.com/vlang/vsl/blob/main/vlas/cflags_d_vsl_vlas_cblas.v:
Also checking for the existence of a pkg-config is possible:
$if $pkgconfig('mysqlclient') {
#pkgconfig mysqlclient
} $else $if $pkgconfig('mariadb') {
#pkgconfig mariadb
}
V doctor:
What did you do?
v -run main.v
What did you expect to see?
What did you see instead?