Error building application using Mysql connector - c++

I have a problem with building a hello world application with MYSQL connector under c++.
Here is the build log:
"/usr/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/data/c++/MySqlConnectorHW'
"/usr/bin/make" -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/mysqlconnectorhw.exe
make[2]: Entering directory `/c/data/c++/MySqlConnectorHW'
mkdir -p dist/Release/MinGW-Windows
g++.exe -v -d -v -L C:\Program Files\MySQL\MySQL Connector C++ 1.1.0\lib\opt\mysqlcppconn.dll -o dist/Release/MinGW-Windows/mysqlconnectorhw build/Release/MinGW-Windows/main.o -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.0/lib/opt -L/C/boost/libs -L/C/Program\ Files/MySQL/MySQL\ Connector\ C\ 6.0.2/lib/opt
g++.exe: Files\MySQL\MySQL: No such file or directory
g++.exe: Connector: No such file or directory
g++.exe: C++: No such file or directory
g++.exe: 1.1.0\lib\opt\mysqlcppconn.dll: No such file or directory
Using built-in specs.
COLLECT_GCC=C:\MinGW\bin\g++.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
make[2]: Leaving directory `/c/data/c++/MySqlConnectorHW'
make[1]: Leaving directory `/c/data/c++/MySqlConnectorHW'
make[2]: *** [dist/Release/MinGW-Windows/mysqlconnectorhw.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 21s)
Can someone help me with this issue? Thanks.

I've only used g++ under Unix, so some of this is based around the example you've given (and may be wrong).
You have several problems. You're getting some weird behaviour from g++ because it is treating this C:\Program Files\MySQL\MySQL Connector C++ 1.1.0\lib\opt\mysqlcppconn.dll as different arguments (seperated by space) C:\Program, Files\MySQL\MySQL, Connector, C++ and 1.1.0\lib\opt\mysqlcppconn.dll. This could be overcome by quoting the string "C:\Program Files\MySQL\MySQL Connector C++ 1.1.0\lib\opt\mysqlcppconn.dll".
However, the -L parameter passed to g++ is used to specify the search paths for libraries, so I wouldn't expect you to specify the name of the dll at this point. I'd expect you to pass -L"C:\Program Files\MySQL\MySQL Connector C++ 1.1.0\lib\opt". Based on your similar -L arguments, it would also appear that it's possible to achieve this by escaping codes in the string,, in which case you end up with: -L/C/Program\ Files/MySQL/MySQL\ Connector\ C++\ 1.1.0/lib/opt, which as it happens you're already passing.
Conclusion:, it seems likely that this: -L C:\Program Files\MySQL\MySQL Connector C++ 1.1.0\lib\opt\mysqlcppconn.dll is really supposed to be specifying a library to link with, not a search path. If this is the case, then you should be using -l, not -L it should simply be: -lmysqlcppconn (at least that's how it would work in Unix, under windows you may need to specify an extension i.e. -lmsqlcppcon.lib).
g++ will then try to resolve missing links by searching in all of the paths specified by -L parameters, to see if they have any libraries matching the supplied -l parameter.
I would suggest opening up the makefile: nbproject/Makefile-Release.mk and having a look to see where this parameter is coming from and update it accordingly.
Looking at the rest of your parameters, it's worth noting that you may have a similar problem when it gets to your output, since it also has a space in it that doesn't appear to be escaped:
-o dist/Release/MinGW-Windows/mysqlconnectorhw build/Release/MinGW-Windows/main.o

Several comments can be found on the internet of how to link the binary version of mysql-connector with your own code: http://dev.mysql.com/doc/refman/5.0/en/building-clients.html
A different route would be to build the source code of mysql-connector-c and mysql-connector-c++. The official version does not support MinGW as a target. However, the following post includes a link to adapted code versions for MinGW: http://forums.mysql.com/read.php?117,425191,425191#msg-425191

Related

Build curl lib with Mingw compiler

I want to use the curl lib in my project (c++ QT creator on windows), I download the zip lib file from the website https://curl.se/download.html (Version 7.82.0)
and I wanted to build it using the Makefile with this commend
mingw32-make mingw32 as described in the documentation https://curl.se/docs/install.html
but unfortunately, I am getting an error
mingw32-make mingw32
[....]
gcc -s -m32 -static -o curl.exe curl.res slist_wc.o tool_binmode.o tool_bname.o
tool_cb_dbg.o tool_cb_hdr.o tool_cb_prg.o tool_cb_rea.o tool_cb_see.o tool_cb_wrt.o
tool_cfgable.o tool_dirhie.o tool_doswin.o tool_easysrc.o tool_filetime.o tool_findfile.o
tool_formparse.o tool_getparam.o tool_getpass.o tool_help.o tool_helpers.o tool_hugehelp.o
tool_libinfo.o tool_listhelp.o tool_main.o tool_msgs.o tool_operate.o tool_operhlp.o
tool_panykey.o tool_paramhlp.o tool_parsecfg.o tool_progress.o tool_strdup.o tool_setopt.o
tool_sleep.o tool_urlglob.o tool_util.o tool_vms.o tool_writeout.o tool_writeout_json.o
tool_xattr.o strtoofft.o nonblock.o warnless.o curl_ctype.o curl_multibyte.o version_win32.o
dynbuf.o -L../lib -lcurl -lwldap32 -lws2_32
../lib\libcurl.a: error adding symbols: Archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
make[1]: *** [curl.exe] Fehler 1
make[1]: Leaving directory `D:/Dev/API/curl-7.82.0/src'
make: *** [mingw32] Fehler 2
I tried to run ranlib lib\libcurl.a but the issue is still there,
does anyone have an idea about it?
One more question: is it possible also to build it with mingw64?

Xerces no library found after install

I'm trying to run Xerces on Mac. I us
./configure CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64"
./configure --prefix=/opt
sudo make (this builds the library)
sudo make install (this installs the library)
I also include the libxerces-c.dylib on linker in NetBeans
Here is the error
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/xerces
mkdir -p build/Debug/GNU-MacOSX/_ext/619588065
rm -f "build/Debug/GNU-MacOSX/_ext/619588065/SAXCount.o.d"
g++ -c -g -I/opt/lib/libxerces-c.dylib -MMD -MP -MF "build/Debug/GNU-MacOSX/_ext/619588065/SAXCount.o.d" -o build/Debug/GNU-MacOSX/_ext/619588065/SAXCount.o ../../Documents/xerces-c-3.1.2/samples/src/SAXCount/SAXCount.cpp
In file included from ../../Documents/xerces-c-3.1.2/samples/src/SAXCount/SAXCount.cpp:26:
../../Documents/xerces-c-3.1.2/samples/src/SAXCount/SAXCount.hpp:26:10: fatal error: 'xercesc/util/PlatformUtils.hpp' file not found
#include <xercesc/util/PlatformUtils.hpp>
^
1 error generated.
make[2]: *** [build/Debug/GNU-MacOSX/_ext/619588065/SAXCount.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 128ms)
Any idea how to fix this??
Thanks!
Select Project in projects window.
Right-click for pop-up menu.
Select Properties in pop-up menu.
Select C++ Compiler under Build in Categories list on the left side of dialog.
Add a directory to Include Directories. The new directory should have PlatformUtils.hpp in the xercesc/util/ subdirectory of that directory. From your options I am guessing /opt/include/
Update
To Resolve
ld: library not found for -lxerces-c
Select Linker under Build in Categories list on the left side of dialog.
Add the directory containing libxerces-c.dylib and/or libxerces-c.a which appears to be /opt/lib/ to Additional Library Directories field.

Error building and compiling GCC 5.2.0 from scratch on Vortex86DX

In order to upgrade a VortexDX86 custom linux with a gcc 3.2.3 compiler, I´m trying to built the GCC 5.2.0 compiler to support the latest C++ 11 standard.
I have downloaded its source code from gcc.gnu.org and did the standard linux package builder based on this link.
$ mkdir ../gcc-build
$ cd ../gcc-build
$ ../gcc-5.2.0/configure --prefix=/usr --disable-multilib --with-system-zlib --enable-languages=c,c++
The configuration runs fine. The I do:
$ make
And I´m getting the following error:
make[3]: Entering directory `/home/ftp/pub/gcc-5.2.0/host-i586-pc-linux-gnu/gcc'
g++ -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -fno-common -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../.././gcc -I../.././gcc/build -I../.././gcc/../include -I../.././gcc/../libcpp/include \
-o build/genmddeps.o ../.././gcc/genmddeps.c
cc1plus: warning: -Wmissing-format-attribute ignored without -Wformat
In file included from ../../gcc/genmddeps.c:19:
../../gcc/system.h:201:19: string: No such file or directory
../../gcc/system.h:218:22: algorithm: No such file or directory
../../gcc/system.h:219:20: cstring: No such file or directory
../../gcc/system.h:220:20: utility: No such file or directory
../../gcc/system.h:249:19: cstdlib: No such file or directory
make[3]: *** [build/genmddeps.o] Error 1
make[3]: Leaving directory `/home/ftp/pub/gcc-5.2.0/host-i586-pc-linux-gnu/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/ftp/pub/gcc-5.2.0'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/ftp/pub/gcc-5.2.0'
make: *** [all] Error 2
After that the make procedure aborts. I´ve installed all the dependencies (tcl, expect, dejagnu, perl, m4, gmp, mpfr and mpc) and I don´t know what is missing.
As said, the original Vortex linux has a gcc 3.2.3 compiler version.
I need to solve that but I don´t know where to start from. It seens to have confusion with the own gcc libraries....
Help appreciated to solve that.
You need a working C++ compiler to build recent releases of GCC, and you don't seem to have that (your GCC 3.2.3 seems to be missing the C++ standard library headers).
I suggest that you use the existing compiler to build GCC 4.7.4 (which can still be built by a C compiler) to get a working C++ compiler. Then use GCC 4.7.4 to build GCC 5.2
Bad. This did not solved the issue.... I´ve followed all the steps and the same error remains...
It happens maybe because you do not know enough your Operating System or maybe because you don't know to much about gcc
Here is step-by-step how to compile GCC-5.2.0 from scratches On Ubuntu.
1)
mkdir $HOME/gcc-5.2.0
2)
cd gcc-5.2.0/
3)
sudo apt-get install libmpfr-dev libgmp3-dev libmpc-dev flex bison gcc-multilib texinfo
4)
wget http://ftp.gnu.org/gnu/gcc/gcc-5.2.0/gcc-5.2.0.tar.gz
5)
tar -xzvf gcc-5.2.0.tar.gz
6)
cd gcc-5.2.0/
7)
mkdir build
8)
cd build/
9)
../configure --enable-multilib --disable-checking --enable-languages=c,c++ \
--enable-multiarch --enable-shared --enable-threads=posix \
--program-suffix=5.2 --with-gmp=/usr/local/lib --with-mpc=/usr/lib \
--with-mpfr=/usr/lib --without-included-gettext --with-system-zlib \
--with-tune=generic \
--prefix=$HOME/install/gcc-5.2.0
10)
make -j4
11)
make install

Netbeans C/C not compiling

I installed the NetBeans IDE 7.3.1 almost a week ago and still haven't been able to get it to compile anything.
I'm using the Cygwin's compiler for C/C++, and I get the following error message for a simple "Hello World" program:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_1-Windows/hello_world.exe
make[2]: Entering directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
mkdir -p build/Debug/Cygwin_1-Windows
rm -f build/Debug/Cygwin_1-Windows/main.o.d
gcc -c -g -MMD -MP -MF build/Debug/Cygwin_1-Windows/main.o.d -o build/Debug/Cygwin_1-Windows/main.o main.c
make[2]: gcc: Command not found
nbproject/Makefile-Debug.mk:66: recipe for target `build/Debug/Cygwin_1-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_1-Windows/main.o] Error 127
make[2]: Leaving directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
nbproject/Makefile-Debug.mk:59: recipe for target `.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Users/CaptFuzzyboots/Documents/NetBeansProjects/Hello World'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 472ms)
EDIT
I fixed this by just making a new toolkit and adding the base directory as Cygwin -> bin.
The problem now is that I keep getting
Unable to start pty process
gcc: Command not found
You should check whether you have installed gcc (plus gdb and make)
via MinGW:
MinGW+NetBeans (just look at the screenshots, you don't have to understand Hungarian)
via Cygwin:
http://www.eecg.utoronto.ca/~aamodt/ece242/cygwin.html
You should also check whether paths are correct in NetBeans:
Tools > Options > C/C++ > Build Tools:
(At the time of creating the screenshot, I had MinGW installed in C:\Programs\MinGW, BUT if you have it installed in C:\MinGW (which is the default), this correct, too! The only important thing is that you should install MinGW in a path which doesn't contain whitespaces.)
This is what it looks like when paths are incorrect, letters are red:
Note: I have MinGW installed, but it doesn't change the fact that you should check whether YOUR paths are correct.
You should also take care the right Configuration is selected in project Properties (right click on project) > Build - The right "Tool collection" has to be selected (on which the paths above are correct):
Unable to start pty process
Related answer: Can build, but can't run C code in netbeans (but it works in command line)
So right click on the project, Properties > Run > Console Type > External Terminal (instead of e.g. "Internal Terminal"). Here is a screenshot:
Here is your problem:
gcc: Command not found
Cygwin is not a compiler, it's a unix-like environment for Windows. Gcc is the compiler. You have to install gcc with Cygwin before it will work.

Compiling Qt 4.8.5 using mingw32 on windows7: "no such file or directory"

I'm trying to build qt-4.8.5 (opensource) from source using mingw32 compiler on windows 7.
"configure" works fine, but compilation (mingw32-make) fails with this output:
D:\development\qt-4.8.5-mingw>mingw32-make
cd src/tools/bootstrap/ && D:/development/MinGW/bin/mingw32-make.EXE -f Makefile
mingw32-make.EXE[1]: Entering directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
D:/development/MinGW/bin/mingw32-make.EXE -f Makefile.Release
mingw32-make.EXE[2]: Entering directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -fexceptions -mthreads -Wall -Wextra -DUNICODE -DQT_BOOTSTRAPPED -DQT_LITE_UNICODE -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_CODECS -DQT_NO_DATASTREAM -DQT_NO_GEOM_VARIANT -DQT_NO_LIBRARY -DQT_NO_QOBJECT -DQT_NO_STL -DQT_NO_SYSTEMLOCALE -DQT_NO_TEXTSTREAM -DQT_NO_THREAD -DQT_NO_UNICODETABLES -DQT_NO_USING_NAMESPACE -DQT_NO_DEPRECATED -DQT_NODLL -I'../../../include' -I'../../../include/QtCore' -I'../../../include/QtXml' -I'../../3rdparty/zlib' -I'd:/development/MSVS2008EXP/VC/INCLUDE' -I'd:/development/Microsoft SDKs/Windows/v6.1/include' -I'd:/development/MSVS2008EXP/VC/lib/' -I'd:/development/MS_SDKs/Windows/v6.1/Lib' -I'd:/DXSDK/Lib/x86' -I'../../../mkspecs/win32-g++-4.6' -o tmp/obj/release_shared/qisciicodec.o ../../corelib/codecs/qisciicodec.cpp
g++: error: CreateProcess: No such file or directory
Makefile.Release:333: recipe for target 'tmp/obj/release_shared/qisciicodec.o' failed
mingw32-make.EXE[2]: *** [tmp/obj/release_shared/qisciicodec.o] Error 1
mingw32-make.EXE[2]: Leaving directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
Makefile:34: recipe for target 'release' failed
mingw32-make.EXE[1]: *** [release] Error 2
mingw32-make.EXE[1]: Leaving directory 'd:/development/qt-4.8.5-mingw/src/tools/bootstrap'
Makefile:68: recipe for target 'sub-tools-bootstrap-make_default-ordered' failed
mingw32-make.EXE: *** [sub-tools-bootstrap-make_default-ordered] Error 2
I.e.:
g++: error: CreateProcess: No such file or directory
Because g++ DOESN'T print which file it can't find, I'm not certain what could be causing this.
I can call g++, gcc and mingw32-make from command line and they're in Path.
I've removed VC directories, MS SDK directories, and this doesn't fix the problem either.
This is a clean "install", I extracted tar.gz contents, and run configure without modifying anything. Adding mingw include path via -I switch to configure doesn't fix the problem.
How do I fix this?
Additional info:
g++ version: 4.7.1
mingw32-make version: 3.82.90
Figured it out. (Well, I still don't know what was causing this, but I know how to make it work).
Solution:
Place qt.conf into qt "bin" directory.
[Paths]
Prefix = d:/development/qt-4.8.5-mingw
Prefix is path of your qt installation (notice forward slashes).
Configure and compile using bat files:
To configure:
set QTDIR=D:\development\qt-4.8.5-mingw
set QMAKESPEC=win32-g++
set PATH=D:\development\MinGW\bin;D:\development\tools\Perl32\bin;D:\development\qt-4.8.5-mingw\bin
set PATH=%PATH%;c:\Windows\system32
set INCLUDE=
set LIB=
set CPATH=
set CPLUS_INCLUDE_PATH=
set LANG=en
configure -opensource -openssl
You should put into path bin directory of 32bit perl, bin directory of mingw32 installation, and bin directory of qt installation. -openssl key is optional (I need this one).
To compile:
set QTDIR=D:\development\qt-4.8.5-mingw
set QMAKESPEC=win32-g++
set PATH=D:\development\MinGW\bin;D:\development\tools\Perl32\bin;D:\development\qt-4.8.5-mingw\bin
set PATH=%PATH%;c:\Windows\system32
set INCLUDE=
set LIB=
set CPATH=
set CPLUS_INCLUDE_PATH=
set LANG=en
mingw32-make