User forums > Using Code::Blocks

Howto - Cross Compiling in Linux using MingW32

<< < (23/25) > >>

stahta01:

--- Quote from: 71532 on August 09, 2014, 12:35:47 am ---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

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


--- End quote ---

Where did you enter "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" in Code::Blocks?
Did you enter the double quotes or CB?

I suggest trying the "For your project :" section of this FAQ.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

71532:
Hi ! Thanks for the quick reply.
The string "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" (without quotes), was entered at the Linker Settings tab ->Link libraries in C::B (I am running a Linux version of C::B)
I got it issuing a mysql_config --cflags and mysql_config --libs to get the compilation and linking "recommended" switches for the MySQL server installed.
I had seen the link you suggested, I already set up the C::B as advised at the top of this post.
It seems that I need to continue searching to see if someone, somewhere, sometime, had ever cross-compiled a C++ source code to obtain a Windows binary executable format able to run on Windows and connect to a MySQL database running elsewhere. I did it, around 15 years ago, with some stuff I do not have anymore (not even a clue). Now I need to do it but I don't know how...
Thanks
Bye

stahta01:

--- Quote from: 71532 on August 09, 2014, 01:24:16 am ---Hi ! Thanks for the quick reply.
The string "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient" (without quotes), was entered at the Linker Settings tab ->Link libraries in C::B (I am running a Linux version of C::B)
I got it issuing a mysql_config --cflags and mysql_config --libs to get the compilation and linking "recommended" switches for the MySQL server installed.
I had seen the link you suggested, I already set up the C::B as advised at the top of this post.
It seems that I need to continue searching to see if someone, somewhere, sometime, had ever cross-compiled a C++ source code to obtain a Windows binary executable format able to run on Windows and connect to a MySQL database running elsewhere. I did it, around 15 years ago, with some stuff I do not have anymore (not even a clue). Now I need to do it but I don't know how...
Thanks
Bye

--- End quote ---

That is the wrong location for most of this "-Wl,-Bsymbolic-functions -rdynamic -L/usr/lib/mysql -lmysqlclient"
The "mysqlclient" should be in the Link libraries.
The rest should be in other places.
This "/usr/lib/mysql" in linker search folder/path.
This "-Wl,-Bsymbolic-functions" in linker extraother settings.
No idea where "-rdynamic" should be; but, a good guess is linker extraother settings.

Edit: Remember to use the correct tick marks around `mysql_config --cflags` and `mysql_config --libs`
My guess of where they belong.
Other linker settings: `mysql_config --libs`
Other compiler settings: `mysql_config --cflags`

Note: I have been told both that CB needs exited and restarted for things in "`" ticks to be reread and that CB does NOT need exited.

Tim S.

71532:
OK Tim.
I already stated where did I get the compiler and linker options, they are in my reply to your reply.
The switches, or compiler and linker options, were obtained from the command line, hence, no need for back-ticks, though they can be called adding for example $(mysql_config --link) whenever the compiler is called from a single line, from a command line or from a shell script.
Now, I will follow your idea of "simpler" link options, although, if you take a look, I already put -lmysqlclient as a switch in the linker tab, as I showed in my last post. Perhaps, simpler options yield a solution.
Fact is, I can produce an executable for Windows (without calling mysql stuff) and an executable for Linux (with mysql stuff) but fail to produce a running Windows binary with mysql abilities...
I wonder if someone (besides me) had ever did it ... It seems hard to me to think that nobody had ever tried it before... Even the people at Code::Blocks...
Anyway, thanks for your attention.
Regards

stahta01:
Please explain why the build log has double quotes around  the part that is causing the error.

Tim S.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version