Hi All,I'd like to write some program with mysql cluster API(NDB API & MGMAPI) in windows, but I failed all the time. Please help me...1, Got the MySQL Cluster 7.2.5 from http://dev.mysql.com/downloads/cluster/.
1.1, Got "Windows (x86, 32-bit), MSI Installer 7.2.5 56.8M", installed even include development components but no cluster API library. Failed!
1.2, Got "Windows (x86, 32-bit), ZIP Archive   7.2.5 32.8M", it seeems be source code, I only found the NDB examples here, no cluster API library. Failed!
1.3, Got "Windows (x86, 32-bit), ZIP Archive   7.2.5 228.9M", it seems be a no install version.
 I can find the nndb api "include files" & "lib files" here. The patchs are as "include\storage\ndb\mgmapi" & "include\storage\ndb\ndbapi" and "lib". 2, Config vs2008
2.1, Project->Properties, set "C/C++ -> General -> Additional Include Directories"
D:\MySQL\mysqlc\include\storage\ndb\mgmapi
D:\MySQL\mysqlc\include\storage\ndb\ndbapi
D:\MySQL\mysqlc\include\storage\ndb
D:\MySQL\mysqlc\include
2.2, Project->Properties, set "Linker -> General -> Additional Library Directories"
D:\MySQL\mysqlc\lib
2.3, Project->Properties, set "Linker -> Input -> Additional Dependencies"
libmysql.lib ndbcclient.lib3, used vs2008 to run an example which is from the pdf of <<MySQL Cluster API Developer Guide Version 3.0>>
#include <stdio.h>
#include <stdlib.h>
#include <NdbApi.hpp>
#include <mysql.h>
#include <mgmapi.h>
Ndb_cluster_connection* connect_to_cluster();
void disconnect_from_cluster(Ndb_cluster_connection *c);
Ndb_cluster_connection* connect_to_cluster()
{
Ndb_cluster_connection* c;
if(ndb_init())
exit(EXIT_FAILURE);
c= new Ndb_cluster_connection();
if(c->connect(4, 5, 1))
{
fprintf(stderr, "Unable to connect to cluster within 30 seconds.\n\n");
exit(EXIT_FAILURE);
}
if(c->wait_until_ready(30, 0) < 0)
{
fprintf(stderr, "Cluster was not ready within 30 seconds.\n\n");
exit(EXIT_FAILURE);
}
return c;
}
void disconnect_from_cluster(Ndb_cluster_connection *c)
{
delete c;
ndb_end(2);
}
int main(int argc, char* argv[])
{
Ndb_cluster_connection *ndb_connection= connect_to_cluster();
printf("Connection Established.\n\n");
disconnect_from_cluster(ndb_connection);
return EXIT_SUCCESS;
}4, Built solution
1>------ Build started: Project: NdbApiTest, Configuration: Release Win32 ------
1>Compiling...
1>Test02.cpp
1>d:\mysql\mysqlc\include\storage\ndb\ndbapi\NdbReceiver.hpp(279) : warning C4800: 'Uint32' : forcing value to bool 'true' or 'false' (performance warning)
1>d:\mysql\mysqlc\include\storage\ndb\ndbapi\NdbReceiver.hpp(279) : warning C4800: 'Uint32' : forcing value to bool 'true' or 'false' (performance warning)
1>d:\mysql\mysqlc\include\mysql_com.h(291) : error C2146: syntax error : missing ';' before identifier 'fd'
1>d:\mysql\mysqlc\include\mysql_com.h(291) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\mysql\mysqlc\include\mysql_com.h(291) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\mysql\mysqlc\include\mysql_com.h(470) : error C2065: 'SOCKET' : undeclared identifier
1>d:\mysql\mysqlc\include\mysql_com.h(470) : error C2146: syntax error : missing ')' before identifier 's'
1>d:\mysql\mysqlc\include\mysql_com.h(471) : error C2059: syntax error : ')'
1>Build log was saved at "file://d:\25_Study\12_C++\Excises\NdbApiTest\NdbApiTest\Release\BuildLog.htm"
1>NdbApiTest - 6 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========5, Added <Windows.h> head file before <mysql.h>, solved compile errors, but there are some linker errors happened
1>------ Build started: Project: NdbApiTest, Configuration: Release Win32 ------
1>Compiling...
1>Test02.cpp
1>d:\mysql\mysqlc\include\storage\ndb\ndbapi\NdbReceiver.hpp(279) : warning C4800: 'Uint32' : forcing value to bool 'true' or 'false' (performance warning)
1>d:\mysql\mysqlc\include\storage\ndb\ndbapi\NdbReceiver.hpp(279) : warning C4800: 'Uint32' : forcing value to bool 'true' or 'false' (performance warning)
1>Linking...
1>Test02.obj : error LNK2001: unresolved external symbol "public: int __thiscall Ndb_cluster_connection::wait_until_ready(int,int)" (?wait_until_ready@Ndb_cluster_connection@@QAEHHH@Z)
1>Test02.obj : error LNK2001: unresolved external symbol "public: int __thiscall Ndb_cluster_connection::connect(int,int,int)" (?connect@Ndb_cluster_connection@@QAEHHHH@Z)
1>Test02.obj : error LNK2001: unresolved external symbol "public: __thiscall Ndb_cluster_connection::~Ndb_cluster_connection(void)" (??1Ndb_cluster_connection@@QAE@XZ)
1>Test02.obj : error LNK2001: unresolved external symbol "public: __thiscall Ndb_cluster_connection::Ndb_cluster_connection(char const *)" (??0Ndb_cluster_connection@@QAE@PBD@Z)
1>Test02.obj : error LNK2001: unresolved external symbol _ndb_end
1>Test02.obj : error LNK2001: unresolved external symbol _ndb_init
1>D:\25_Study\12_C++\Excises\NdbApiTest\Release\NdbApiTest.exe : fatal error LNK1120: 6 unresolved externals
1>Build log was saved at "file://d:\25_Study\12_C++\Excises\NdbApiTest\NdbApiTest\Release\BuildLog.htm"
1>NdbApiTest - 7 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========I searched the linker error online, but I have not found the solution. But a little tips online, maybe rebuild mysql cluster myself will be helpful. 
Please give me a hand if you know something. Thanks!

解决方案 »

  1.   

    for your os is windows,i adivse that you really need to re-bulid your mysql,which is the useful way.the error:
    ?wait_until_ready@Ndb_cluster_connection@@QAEHHH@Z
    from your un-full-installed mysql
      

  2.   

    sorry  , I don't know
      

  3.   

    Rebuild MySQL cluster on windows and link ndbapi.lib libmysql.lib mysqlclient.lib ndbclient.lib strings.lib mysys.lib /NODEFAULTLIB:libcmt.lib in project. This question is solved.