Coder Social home page Coder Social logo

Macos uses db.mysql,C error found about v HOT 8 OPEN

Avey777 avatar Avey777 commented on September 23, 2024
Macos uses db.mysql,C error found

from v.

Comments (8)

medvednikov avatar medvednikov commented on September 23, 2024 4

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.

from v.

ttytm avatar ttytm commented on September 23, 2024 3

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
}

from v.

Avey777 avatar Avey777 commented on September 23, 2024 1

Do . After that, the compilation should succeed.brew install mariadb-connector-c

@spytheman

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.

from v.

Avey777 avatar Avey777 commented on September 23, 2024 1

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)

from v.

Avey777 avatar Avey777 commented on September 23, 2024

@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.

from v.

spytheman avatar spytheman commented on September 23, 2024

Do brew install mariadb-connector-c . After that, the compilation should succeed.

from v.

Avey777 avatar Avey777 commented on September 23, 2024

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

from v.

spytheman avatar spytheman commented on September 23, 2024

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 .

from v.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.