Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Mac OS » Cannot compile MYSQL project
Cannot compile MYSQL project [message #52949] Sun, 19 January 2020 15:20 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I have a project linked with the MySql library in windows and works as expected.
Now I need to port it under MaC OSX (Mojave).

I have installed the library and set the path but it keep saying
error: unknown type name 'MYSQL'
and many other similar error.

What am I missing? I have even set the flag .MYSQLDLL but I am not sure it should appear under Mac.

Thanks,
Luigi

Re: Cannot compile MYSQL project [message #52962 is a reply to message #52949] Wed, 22 January 2020 12:01 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
The same package compiled and run without problems under Linux (ubuntu 18.10). No need of .MYSQLDLL flag.
On Mac I have followed many discussion about mysql and installed several library but none solved the problem.

Luigi
Re: Cannot compile MYSQL project [message #52970 is a reply to message #52962] Thu, 23 January 2020 08:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
That sounds like mysql.h does not get included.

Check MySql/MySql.h

#ifndef __mysql_h__
#define __mysql_h__

// debian: sudo apt-get install libmysqlclient-dev

#ifndef flagNOMYSQL

#include <Sql/Sql.h>

#ifdef PLATFORM_WIN32
#ifndef IPPROTO_IP
#include <winsock2.h>
#endif
#include <MySql.h>
#endif

#ifdef PLATFORM_POSIX
#include <mysql/mysql.h>
#endif


Perhaps PLATFORM_POSIX is not defined? You can check by removing that last PLATFORM_POSIX....

Is there any guide you have used to install mysql? (I would like to follow it to resolve this issue... Smile

Mirek
Re: Cannot compile MYSQL project [message #52972 is a reply to message #52970] Thu, 23 January 2020 17:39 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello Mirek,

thanks for the reply.
I already tried to remove the PLATFORM_POSIX but no success.

This is the full error message:

/Users/mac/upp.src/uppsrc/mysql/mysql.h (18): warning: non-portable path to file '<MySql/MySql.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (1): In file included from /Users/mac/upp.src/uppsrc/MySql/MySql.cpp:1:
(): #include <mysql/mysql.h>
(): <MySql/MySql.h>
/Users/mac/upp.src/uppsrc/mysql/mysql.h (46): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (75): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (68): error: use of undeclared identifier 'MYSQL_PORT'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (84): error: cannot initialize object parameter of type 'Upp::SqlSession' with an expression of type 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (24): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (26): error: unknown type name 'MYSQL_RES'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (27): error: unknown type name 'MYSQL_ROW'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (39): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (50): error: use of undeclared identifier 'mysql_library_init'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (54): error: use of undeclared identifier 'mysql_library_end'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (59): error: expected expression
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (59): error: use of undeclared identifier 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (64): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (103): error: use of undeclared identifier 'MYSQL_PORT'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (142): error: cannot initialize object parameter of type 'Upp::SqlSession' with an expression of type 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (172): error: out-of-line definition of 'Begin' does not match any declaration in 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (216): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (225): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (234): error: no matching constructor for initialization of 'Upp::Sql'

You get the same if you try to compile the mysql package test case coming with U++.

Googling on internet I did several things (there is no unanimous agreement)

1) upgrade brew

brew update --verbose

it may takes some minute to upgrade everything (at least on my Mac mini)

2) installed several libraries, one by one because each of them didn't work

brew install mysql-connector-cc
brew install mysql-connector-c
brew install mysql-client

At the end I had a MYSQL folder in
/usr/local/Cellar/mysql
/usr/local/Cellar/mysql-client
/usr/local/Cellar/mysql-connector-c++
/usr/local/opt/mysql

each one with their include and lib folder.
I tried to point theide in all includes but with no luck.
I hope this info can be useful.

thanks,
Luigi



Re: Cannot compile MYSQL project [message #52973 is a reply to message #52972] Thu, 23 January 2020 18:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Thu, 23 January 2020 17:39
Hello Mirek,

thanks for the reply.
I already tried to remove the PLATFORM_POSIX but no success.

This is the full error message:

/Users/mac/upp.src/uppsrc/mysql/mysql.h (18): warning: non-portable path to file '<MySql/MySql.h>'; specified path differs in case from file name on disk [-Wnonportable-include-path]
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (1): In file included from /Users/mac/upp.src/uppsrc/MySql/MySql.cpp:1:
(): #include <mysql/mysql.h>
(): <MySql/MySql.h>
/Users/mac/upp.src/uppsrc/mysql/mysql.h (46): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (75): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (68): error: use of undeclared identifier 'MYSQL_PORT'
/Users/mac/upp.src/uppsrc/mysql/mysql.h (84): error: cannot initialize object parameter of type 'Upp::SqlSession' with an expression of type 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (24): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (26): error: unknown type name 'MYSQL_RES'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (27): error: unknown type name 'MYSQL_ROW'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (39): error: unknown type name 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (50): error: use of undeclared identifier 'mysql_library_init'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (54): error: use of undeclared identifier 'mysql_library_end'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (59): error: expected expression
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (59): error: use of undeclared identifier 'MYSQL'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (64): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (103): error: use of undeclared identifier 'MYSQL_PORT'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (142): error: cannot initialize object parameter of type 'Upp::SqlSession' with an expression of type 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (172): error: out-of-line definition of 'Begin' does not match any declaration in 'Upp::MySqlSession'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (216): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (225): error: no matching constructor for initialization of 'Upp::Sql'
/Users/mac/upp.src/uppsrc/MySql/MySql.cpp (234): error: no matching constructor for initialization of 'Upp::Sql'

You get the same if you try to compile the mysql package test case coming with U++.

Googling on internet I did several things (there is no unanimous agreement)

1) upgrade brew

brew update --verbose

it may takes some minute to upgrade everything (at least on my Mac mini)

2) installed several libraries, one by one because each of them didn't work

brew install mysql-connector-cc
brew install mysql-connector-c
brew install mysql-client

At the end I had a MYSQL folder in
/usr/local/Cellar/mysql
/usr/local/Cellar/mysql-client
/usr/local/Cellar/mysql-connector-c++
/usr/local/opt/mysql

each one with their include and lib folder.
I tried to point theide in all includes but with no luck.
I hope this info can be useful.

thanks,
Luigi





I think that clang cannot find the right include and for that reason replaces it with a wrong one.

What are your include paths in the build method? I bet it will be one level off. Include paths must at some point pick mysql/mysql.h from the client library you have installed.

Mirek
Re: Cannot compile MYSQL project [message #52975 is a reply to message #52973] Thu, 23 January 2020 23:12 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Thu, 23 January 2020 18:31


I think that clang cannot find the right include and for that reason replaces it with a wrong one.

What are your include paths in the build method? I bet it will be one level off. Include paths must at some point pick mysql/mysql.h from the client library you have installed.

Mirek


I thought the same and tried several time. I tried once more at several folder level to help clang to locate the mysql.h. Here is my include
index.php?t=getfile&id=5982&private=0
The marked row is where I see a mysql.h file. In both opt and cellar seems to be the same files.

Luigi
Re: Cannot compile MYSQL project [message #52976 is a reply to message #52975] Fri, 24 January 2020 09:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
forlano wrote on Thu, 23 January 2020 23:12
mirek wrote on Thu, 23 January 2020 18:31


I think that clang cannot find the right include and for that reason replaces it with a wrong one.

What are your include paths in the build method? I bet it will be one level off. Include paths must at some point pick mysql/mysql.h from the client library you have installed.

Mirek


I thought the same and tried several time. I tried once more at several folder level to help clang to locate the mysql.h. Here is my include
index.php?t=getfile&id=5982&private=0
The marked row is where I see a mysql.h file. In both opt and cellar seems to be the same files.

Luigi


IMO should be /usr/local/opt/mysql/include

(The include is <mysql/mysql.h> so the include path must be relative to it)

Mirek
Re: Cannot compile MYSQL project [message #52978 is a reply to message #52976] Fri, 24 January 2020 19:51 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Fri, 24 January 2020 09:09

IMO should be /usr/local/opt/mysql/include

(The include is <mysql/mysql.h> so the include path must be relative to it)

Mirek


I tried but without success Confused .
This task is beyond my capability. I do not know if I missed the correct library or there is something wrong in some flag.

Thanks,
Luigi
Re: Cannot compile MYSQL project [message #52984 is a reply to message #52976] Wed, 29 January 2020 14:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
This was tricky one.

The problem is that CLANG treats include files case insensitive. Thus <mysql/mysql.h> in fact included the package's MySql.h recursively...

I have fixed it by redoing the code to:

#ifdef PLATFORM_POSIX
#ifdef PLATFORM_OSX
#include <mysql.h>
#else
#include <mysql/mysql.h>
#endif
#endif


so with MacOS you will need to point to inside that mysql folder. Not nice, but for now it will do.

Mirek
Re: Cannot compile MYSQL project [message #52987 is a reply to message #52984] Wed, 29 January 2020 23:14 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Wed, 29 January 2020 14:05
This was tricky one.

The problem is that CLANG treats include files case insensitive. Thus <mysql/mysql.h> in fact included the package's MySql.h recursively...

I have fixed it by redoing the code to:

#ifdef PLATFORM_POSIX
#ifdef PLATFORM_OSX
#include <mysql.h>
#else
#include <mysql/mysql.h>
#endif
#endif


so with MacOS you will need to point to inside that mysql folder. Not nice, but for now it will do.

Mirek


Thank you very much!
Now I was able to overcome the include problem... but unfortunately I stopped again at the lib. Below are the new complains.

Can I ask you which library you have installed and where point your path lib? I tried with all the library I have but nothing happened. Perhaps I need to set some flag or compiler option.

Luigi
-----------------------

Undefined symbols for architecture x86_64:
"_mysql_affected_rows", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_close", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
Upp::MySqlSession::Close() in MySql.a(MySql.o)
Upp::MySqlSession::Reconnect() in MySql.a(MySql.o)
Upp::MySqlSession::~MySqlSession() in MySql.a(MySql.o)
"_mysql_errno", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
Upp::MySqlSession::MysqlQuery(char const*) in MySql.a(MySql.o)
"_mysql_error", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
Upp::MySqlSession::MysqlQuery(char const*) in MySql.a(MySql.o)
"_mysql_fetch_field_direct", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_fetch_lengths", referenced from:
Upp::MySqlConnection::Fetch() in MySql.a(MySql.o)
"_mysql_fetch_row", referenced from:
Upp::MySqlConnection::Fetch() in MySql.a(MySql.o)
"_mysql_free_result", referenced from:
Upp::MySqlConnection::Fetch() in MySql.a(MySql.o)
Upp::MySqlConnection::FreeResult() in MySql.a(MySql.o)
Upp::MySqlConnection::Cancel() in MySql.a(MySql.o)
"_mysql_init", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
"_mysql_insert_id", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_more_results", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_next_result", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_num_fields", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
"_mysql_query", referenced from:
Upp::MySqlSession::MysqlQuery(char const*) in MySql.a(MySql.o)
"_mysql_real_connect", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
"_mysql_real_escape_string", referenced from:
Upp::MySqlConnection::EscapeString(Upp::String const&) in MySql.a(MySql.o)
"_mysql_server_end", referenced from:
Upp::s__s53_fn() in MySql.a(MySql.o)
"_mysql_server_init", referenced from:
__GLOBAL__sub_I_MySql.cpp in MySql.a(MySql.o)
"_mysql_set_character_set", referenced from:
Upp::MySqlSession::DoConnect() in MySql.a(MySql.o)
"_mysql_store_result", referenced from:
Upp::MySqlConnection::Execute() in MySql.a(MySql.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

[Updated on: Wed, 29 January 2020 23:16]

Report message to a moderator

Re: Cannot compile MYSQL project [message #52992 is a reply to message #52987] Fri, 31 January 2020 14:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
It was a problem in MySql package, missing OSX libraries requirement...

Fixed in trunk.
Re: Cannot compile MYSQL project [message #52996 is a reply to message #52992] Fri, 31 January 2020 20:48 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mirek wrote on Fri, 31 January 2020 14:16
It was a problem in MySql package, missing OSX libraries requirement...

Fixed in trunk.


It works!
Thanks a lot!

Luigi
Previous Topic: [BUG] keyboard shortcuts problem on an AZERTY keyboard
Next Topic: MacOS theide Issue
Goto Forum:
  


Current Time: Thu Apr 18 15:16:46 CEST 2024

Total time taken to generate the page: 0.03442 seconds