User forums > Using Code::Blocks

Howto - Cross Compiling in Linux using MingW32

<< < (22/25) > >>

MortenMacFly:

--- Quote from: Leshyk on November 21, 2012, 03:56:57 pm ---Done. Patch 003373.

--- End quote ---
Nice catch... everything generalising platform differences is usually welcome.

@oBFusCATed: A quick inspection reveals it doens't look bad, indeed. Hence I don't recall what the reBreak_or32 regexp was for. If you test the patch, can you ensure we don't break this particular "thingy"? (It seems a Windows only thing).

oBFusCATed:
I'm not sure too, what type of breakpoints this code is used to detect, so some testing should be done here.
I'll apply this on my work C::B and see if there are problems on linux, for windows somebody else should test it.

eddyq:
This is off topic but I can't find anyplace to make a "new post". Can someone please tell me how to do a "new post"?

markpotts:
Any advice on doing the reverse, i.e. cross-compiling for Linux under Windows?
Mark

71532:
The following is just a very simple program writen in C++ that connects to a MySQL. I compile it with no errors, with the following line
g++ -o main main.cpp  -L/usr/include/mysql -lmysqlclient  -I/usr/include/mysql
that produces an executable that runs perfectly well.
/************************************
the example
*************************************/
#include<iostream>
#include<winsock.h>
#include<mysql.h>
#include<stdio.h>
using namespace std;
#define SERVER    "anilab"
#define USER      "anibal"
#define PASSWORD  "anigug"
#define DATABASE  "virtualsa"

int main() {
MYSQL *connect;
connect=mysql_init(NULL);
if(!connect) { cout<<"MySQL Initialization failed"; return 1;
}
connect=mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
if(connect) {   cout<<"connection Succeeded\n";
}else{           cout<<"connection failed\n";      }

MYSQL_RES *res_set;
MYSQL_ROW row;
mysql_query( connect, "SELECT id,nombre,apellido FROM users;" );
unsigned int i =0;
res_set = mysql_store_result(connect);
unsigned int numrows = mysql_num_rows(res_set);
cout << endl;
cout <<"\t --------------------------------------------------------------------- \t"<< endl;
while (((row= mysql_fetch_row(res_set)) !=NULL )) {
//cout<<" %s\n",row !=NULL?row : "NULL";
cout <<"\t | \t" << row << "\t | \t"<<  row[i+1] << "\t | \t"<< row[i+2] << "\t | \t" << endl;
cout <<"\t --------------------------------------------------------------------- \t"<< endl;
}
mysql_close (connect);
return 0;
}
/*********** end of file ***********/

Question: does anybody know of a way to compile this, using -for example- C::B, that will produce an executable for Windows ?
I had tried the set-up proposed at the top of this thread.
I get the following messages:(taken from the Build log)

i586-mingw32msvc-g++ -I/usr/include/mysql  -DBIG_JOINS=1  -fno-strict-aliasing   -DUNIV_LINUX -DUNIV_LINUX -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -DSTRICT -DHAVE_W32API_H -D__WXMSW__ -D__WINDOWS__   -I/usr/i586-mingw32msvc/include  -c /home/xxxx/cpp/test1/main.cpp -o /home/xxxx/cpp/test1/main.o

i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib  -o /home/xxxx/cpp/test1/main /home/xxxx/cpp/test1/main.o  -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lodbc32 -lwsock32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid  "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient"
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: unrecognized option '-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient'
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
 
This compiler (i586-mingw32msvc-g++ does actually produce a working executable from a simple "hello world" C++ source, so it seems a good compiler). Fact is: don't know how to make it work with MySQL libraries and headers.

Thanks

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version