Compiling and connecting to the database (Oracle, MySql) with Qt 4.8 in Mac system)

Source: Internet
Author: User

The MySql and Oracle Database plug-in drivers are compiled on Mac, but unfortunately they cannot be loaded in the program or connect to the database. Set QT_DEBUG_PLUGINS = 1 in the environment variable. After the program is started, Qt will report some debugging information for loading the plug-in. It can be seen that this is caused by incompatibility of the plug-in, that is, the Build Key issue mentioned in this document. It is mentioned in this document that you may need to clear the plug-in cache. It should be in a file defined by QSettings, but I did not find it. Instead, delete and reinstall the QtSDK, start from scratch, and finally succeed. The detailed process is recorded below for future reference.

1. First install QtSDK 1.2 and install it in ~ /In the QtSDK directory, select the source code 4.8.0 for installation; otherwise, the plug-in cannot be compiled later;

2. download the dynamic database connecting MySql and Oracle databases. You can download it from the official website. Pay attention to the appropriate version for your system. Here is the Max OSX 10.7.3 64bit1_mysqldownload mysql-connector-c-6.0.2-osx10.5-x86-64bit.tar.gz, in oracle, The instantclient basic package and the instantclient SDK package are required.

3. decompress the downloaded database document to a local directory, and record the file directory. Decompress MySql ~ The/bin/mysql directory contains the include and lib sub-directories. Extract the two oracle packages ~ /Bin/oracle Directory, which contains the library files and sdk directories;

4. After the preparation is complete, compile and generate the Qt library. First, execute the command (the last three lines are a command, which is displayed by a long branch)

  1. Cd ~ /QtSDK/QtSources/4.8.0
  2. ./Configure-opensource-prefix/Users/lutx/QtSDK/Desktop/Qt/4.8.0/gcc-plugin-SQL-mysql-plugin-SQL-oci
  3. -Plugin-SQL-odbc-plugin-SQL-sqllite-I/Users/lutx/bin/mysql/include-I/Users/lutx/bin/oracle/sdk/include
  4. -L/Users/lutx/bin/mysql/lib-L/Users/lutx/bin/oracle

In the above command, prefix is the definition of the compiled installation directory, the default is installed to the/usr/local/Trolltech/Qt-4.8.0 directory, I here to define the installation to the QtSDK directory, this avoids subsequent configuration of the version in QtCreator or using install_name_tools to modify the dynamic library name. After a period of time (several minutes), The makefile file in the entire source directory is generated. The system should display

  1. Qt is now configured for building. Just run 'make '.
  2. Once everything is built, you must run 'make install '.
  3. Qt will be installed into/Users/[xxxx]/QtSDK/Desktop/Qt/4.8.0/gcc
  4. To reconfigure, run 'make confclean' and 'configure '.

The above [xxxx] should be your system login user name, the same below.

5. the compilation process starts below. It should be very simple. Just execute the make command directly under the directory just now, www.bkjia.com, but here I will see errors when compiling TO THE QtWebkit library, therefore, we will skip this library and continue to compile the subsequent library. The error is:

  1. Fileapi/FileReaderLoader. cpp: In member function 'void WebCore: FileReaderLoader: convertToDataURL ()':
  2. Fileapi/FileReaderLoader. cpp: 307: error: 'base64encode' was not declared in this scope
  3. Make [3]: *** [. obj/debug-static/FileReaderLoader. o] Error 1
  4. Make [2]: *** [debug-all] Error 2
  5. Make [1]: *** [sub-WebCore-make_default-ordered] Error 2

I don't know why, but I don't understand it.

5. You can see through the Makefile file that scripttools and plugins (this is the main purpose) are behind Webkit, and each library is compiled one by one using commands.

  1. Cd src/scripttools; make; cd .. /plugins; make; cd .. /imports; make; cd .. /tools; make; cd .. /translations; make; cd .. /..
  2. Make install

Because it is not necessary, the examples and demos directories are not compiled at last.

The compilation is successful. In addition, you need to add the lib directory of mysql and the lib directory of oracle to the environment variable DYLD_LIBRARY_PATH when running the program. Otherwise, the database plug-in driver cannot be loaded.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.