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 » Community » Newbie corner » MySQL example compile issue
MySQL example compile issue [message #35882] Fri, 30 March 2012 23:55 Go to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
Hello.
I'm trying to compile MySql example from examples provided with U++ and I have the same problem as it was mentioned here:
http://www.ultimatepp.org/forum/index.php?t=msg&goto=181 24&&srch=mysql+example#msg_18124

So far for me it looks like I'm not including the correct mysql.h file. The one that is included is that from U++ and I need the one from MySql server include folder.

Sadly I don't know how to force U++ to use other mysql.h.
While looking in sources in example it looks like MySql.cpp is including mysql.h which includes itself(?), here's code:

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

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

I'm a bit confused, I know i did something wrong, but I can't find out what?

Thank you for your attention Smile
Cheers
Re: MySQL example compile issue [message #35883 is a reply to message #35882] Sat, 31 March 2012 09:11 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Hello

you have to install MySql development files (headers and libraries) from MySql.

if you do that your mysql install directory, contains:
a folder called include that contain mysql.h and others .h files
a folder called lib that contain libs files (.lib or .a)


the rest is here:

http://www.ultimatepp.org/srcdoc$MySql$NativeMySql$en-us.htm l


Omari


regards
omari.
Re: MySQL example compile issue [message #35884 is a reply to message #35883] Sat, 31 March 2012 10:01 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
Thanks for your reply.
I have already set up everything like in this example, because the same file can be found as a Help in one of examples. I also have installed MySql dev package, so include/lib directories are present and I also add them to TheIDE, but still got the same problem.
Re: MySQL example compile issue [message #35886 is a reply to message #35884] Sat, 31 March 2012 14:27 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
I am using MySql 5.1.51 and U++ 4690,
i can compile SQL_MySql example without problem.

i propose you to try with SQL_MySql example, if you have a probleme to compile it, let me know the error message.

Omari


regards
omari.
Re: MySQL example compile issue [message #35888 is a reply to message #35886] Sat, 31 March 2012 15:19 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
----- Core ( MT MSC10 DEBUG SHARED DEBUG_FULL BLITZ WIN32 MSC ) (1 / 5)
----- MySql ( MT MYSQLDLL MSC10 DEBUG SHARED DEBUG_FULL BLITZ WIN32 MSC ) (2 / 5)
----- plugin/z ( MT MSC10 DEBUG SHARED DEBUG_FULL BLITZ WIN32 MSC ) (3 / 5)
MySql.cpp
----- Sql ( MT MSC10 DEBUG SHARED DEBUG_FULL BLITZ WIN32 MSC ) (4 / 5)
----- SQL_MySql ( MT MYSQLDLL MAIN MSC10 DEBUG SHARED DEBUG_FULL BLITZ WIN32 MSC ) (5 / 5)
C:\Users\fkmd\upp\uppsrc\MySql\MySql.h(44) : error C2143: syntax error : missing ';' before '*'
C:\Users\fkmd\upp\uppsrc\MySql\MySql.h(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\fkmd\upp\uppsrc\MySql\MySql.h(44) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\fkmd\upp\uppsrc\MySql\MySql.h(57) : error C2833: 'operator MYSQL' is not a recognized operator or type
C:\Users\fkmd\upp\uppsrc\MySql\MySql.h(57) : error C2059: syntax error : 'newline'

It's
MYSQL *mysql;

Re: MySQL example compile issue [message #35890 is a reply to message #35888] Sat, 31 March 2012 15:49 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
sorry, i can't reproduce your error!

regards
omari.

[Updated on: Sat, 31 March 2012 16:16]

Report message to a moderator

Re: MySQL example compile issue [message #35893 is a reply to message #35890] Sat, 31 March 2012 16:59 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
ffndev:

Please refer to this article:

http://www.ultimatepp.org/app$ide$ConfiguringPackagesAssembl ies$en-us.html

Starting from "Package build settings" section. Or you can read the whole article. This will teach you how to add extra include directories and library directories and many more.
Re: MySQL example compile issue [message #35895 is a reply to message #35882] Sat, 31 March 2012 18:50 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
Still no success Sad
I have everything setup like in this example:
http://www.ultimatepp.org/srcdoc$MySql$NativeMySql$en-us.htm l

but it still looks like it's not including MySql.h from MySql Server\include directory.

Does it make any difference that in this package there's a package called MySql with MySql.h inside? Maybe it's including MySql.h from UPP and skips MySql.h from MySql Server\include dir?

When i deleted MySqlServer\Include directory from build options nothing changed, so it looks like it's doesn't matter if they are included or not, so maybe my above statement makes sense??
Re: MySQL example compile issue [message #35897 is a reply to message #35895] Sat, 31 March 2012 22:35 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi ffbdev,

What you need to compile a MySql project is:

1- Install MysQl Server from MySql Website http://www.mysql.fr/downloads/mysql/

2- Set paths to MySql Server files in U++ build configuration (U++ Menu "Setup" and "Build methods"):

In Tab "Path-Executables directories": ..\MySql Server\bin
In Tab "Include directories": ..\MySql Server\include
In Tab "Lib directories": ..\MySql Server\lib

3- Add MySql package to your project in the TheIde by clicking right on the name of your project and choose "add package" in the pop-up menu. Choose MySql interface from the uppscr package.

4-In header file of your U++ project, just include MysSql<MySql.h> as in the following code example from one of my personal project (QSkills):

#ifndef _QSkills_QSkills_h
#define _QSkills_QSkills_h

#include <CtrlLib/CtrlLib.h>
#include <GridCtrl/GridCtrl.h>
#include <SysInfo/SysInfo.h>
#include <SysExec/SysExec.h>
#include <MySql/MySql.h>
#include <Controls4U/Controls4U.h>
#include <Functions4U/Functions4U.h>
#include <Report/Report.h>
#include <plugin/png/png.h>

.......


5- Do not forget to settle the "Main Package Organization" to GUI.MYSQLDLL. This can be done through the TheIde main menu "Project".

When installing your application, libMySql.dll file must be copied in Windows\System32 directory or in the same directory as the application exe file for dynamic linkage.

Hope this could be helpful Smile


Biobytes

Re: MySQL example compile issue [message #35898 is a reply to message #35882] Sat, 31 March 2012 23:35 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
First of all I would like to thank you all for such a great feedback.

Sadly MySQL example still not running.
Biobytes thanks for your hints, but while I'm compiling project from examples I have to set CONSOLE_APP.

I think I have made one step closer, in SQL_MySql example there's a package called MySql which Biobytes mentioned needs to be add to every project that uses MySql. Great. But inside MySql.h in lines:

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

there is this "#include <MySql\MySql.h>" this supposed to include file from MySql Serever\include directory, right?But inside include\mysql there's no mysql.h it's one level higher.
When I changed
#include <MySql\MySql.h>
to
#include <MySql.h>
in MySql\Mysql.h (I think it's UPP namespace) everything compiles great, but I get errors during linking ;/
I have copied mysqllib.dll to Windows\system32 and even \system.
Compiled using All static\shared\all shared but still nothing.
When I compile as release I get some error which looks like this:
MySql.cpp
C:\Users\fkmd\upp\uppsrc\MySql\MySql.cpp(275) : error C2018: unknown character '0x40'

it's placed here:
if(result) {
--> DDUMP(rows);
int fields = mysql_num_fields(result);

Re: MySQL example compile issue [message #35902 is a reply to message #35898] Sun, 01 April 2012 16:02 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 526
Registered: March 2007
Contributor
Quote:


there is this "#include <MySql\MySql.h>" this supposed to include file from MySql Serever\include directory, right?But inside include\mysql there's no mysql.h it's one level higher.
When I changed
#include <MySql\MySql.h>
to
#include <MySql.h>
in MySql\Mysql.h (I think it's UPP namespace) everything compiles great,



That probably means you didn't set the include path correct in Build Method settings. (Should be one level up). But as long as it compiles after you remove the MySql\ part, you can leave it as it is for now.


Quote:


but I get errors during linking ;/


That's most likely because you didn't set your link (library) path correctly. Look for no where else other than mentioned in above posts. eg.

Quote:


In Tab "Lib directories": ..\MySql Server\lib



If you link successfully, but cannot run, that could be resulted from inappropriately set executable path, or wrong version of library, etc.
Re: MySQL example compile issue [message #35906 is a reply to message #35902] Sun, 01 April 2012 21:57 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi ffndev,

I agree with Lance. You should check up your link paths to Mysql headers, bin and lib.

Could you show screenshots of your build paths as set in U++,IDE ?

Perhaps it could give more information for helping you.

Regards

Biobytes

Re: MySQL example compile issue [message #35910 is a reply to message #35882] Mon, 02 April 2012 15:40 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
Hi again.
Sorry for such a late answer I was installing Linux Wink and guess what, MySql example compiles/builds well on it, but that's not the reason why I installed of course Wink

Talking about Windows I don't have one but I will soon setup a VM and try again building this example in almost the same conditions (the same windows and so on) I think the fact that it would be running on VM doesn't make any difference.
I will post any results soon

Smile

Cheers
Re: MySQL example compile issue [message #35918 is a reply to message #35882] Mon, 02 April 2012 23:46 Go to previous messageGo to next message
ffndev is currently offline  ffndev
Messages: 7
Registered: March 2012
Location: Poland
Promising Member
Hello again, as I promised I'm posting some results.
So I prepared a VM but with WinXPSP3 so far. Installed all the stuff (upp, mysql) and the MySQL example compiled and built well.
There was one issue, when I was compiling "Debug" it was looking for "\Debug\libmysql.lib" but the lib was one level higher, copied it and works fine.
Tommorow I will setup another VM with Win7 and check everything again but I think I had something incorrectly set up in my previous OS.

I have one more question, when compiling "Release" there's an error (I posted it earlier) about incorrect letter (0x40) somewhere in code, what's wrong with that? Does it mean I can't build release version (Is it MySql lib fault?)

Goodnight.
Re: MySQL example compile issue [message #35919 is a reply to message #35918] Tue, 03 April 2012 07:37 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

ffndev wrote on Mon, 02 April 2012 23:46

I have one more question, when compiling "Release" there's an error (I posted it earlier) about incorrect letter (0x40) somewhere in code, what's wrong with that? Does it mean I can't build release version (Is it MySql lib fault?)

This usually means someone has uploaded a code with temporary debug only logging enabled - in release it is defined to be '@' in order to trigger compiler error (so someone notices it removes the logging). Just have a look somewhere near the place the compiler reports the error should be *LOG or *DUMP macro that causes it.

IMHO it is not very good idea to make compiler spit out this error that tells nothing about the reasons and it happens quite often that code with those logs is committed into the svn, confusing poeple who don't know that it is just a trick :-/

Best regards,
Honza
Previous Topic: Parsing xml..
Next Topic: Moving to Linux dev from Win
Goto Forum:
  


Current Time: Fri Mar 29 00:17:15 CET 2024

Total time taken to generate the page: 0.01818 seconds