Qt 4.8 compilation and connection database (Oracle, MySql) under Mac system

    Yesterday, the database plug-in drivers of MySql and Oracle were successfully compiled under Mac, but unfortunately these two drivers could not be loaded in the program anyway, and the database could not be connected. Set QT_DEBUG_PLUGINS=1 in the environment variable, and after starting the program, Qt will report some debugging information of the loaded plug-in, which can be seen from the incompatibility of the plug-in, which is the problem of Build Key mentioned in the document. It is mentioned that the plugin cache may need to be cleared, which should be in a file defined by QSettings, but I didn't find it. In desperation, I deleted and reinstalled QtSDK, started from scratch, and finally succeeded. The detailed process is recorded below for future reference.

1. First install QtSDK 1.2, install it in the ~/QtSDK directory, choose to install the source code of 4.8.0 when installing, otherwise the plugin cannot be compiled later;

2. Download the dynamic library of MySql and Oracle database connection; it can be downloaded from the official website, pay attention to choose the appropriate version for your system, here is Max OSX 10.7.3 64bit; MySql download is mysql-connector-c-6.0. 2-osx10.5-x86-64bit.tar.gz, the instantclient basic package and the instantclient SDK package are required under oracle.

3. Unzip the downloaded database file to the local directory, and record the file directory; MySql is unzipped in the ~/bin/mysql directory, and there will be include and lib subdirectories below; the two Oracle packages are extracted to ~/bin/ In the oracle directory, there are library files and sdk directories in the directory;

4. After the preparations are completed, start compiling and generating the Qt library; first execute the command (the next 3 lines are a command, because it is too long to display in a separate line)

cd ~/QtSDK/QtSources/4.8.0
./configure -opensource -prefix /Users/lutx/QtSDK/Desktop/Qt/4.8.0/gcc -plugin-sql-mysql -plugin-sql-oci
 -plugin-sql-odbc -plugin-sql-sqllite -I/Users/lutx/bin/mysql/include -I/Users/lutx/bin/oracle/sdk/include
 -L/Users/lutx/bin/mysql/lib -L/Users/lutx/bin/oracle

In the above command, the prefix is ​​to define the compiled installation directory. By default, it is installed in the /usr/local/Trolltech/Qt-4.8.0 directory. I will install the definition in the QtSDK directory here, so as to avoid the subsequent installation in QtCreator. in the configuration version, or use install_name_tools to modify the dynamic library name and other operations. After waiting for a while (several minutes), the makefiles under the entire source directory are generated. The system should show

Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /Users/[xxxx]/QtSDK/Desktop/Qt/4.8.0/gcc

To reconfigure, run 'make confclean' and 'configure'.
The above [xxxx] should be your system login user name, the same below.

5. It should be very simple to start the compilation process below, just continue to execute the make command in the directory just now, but I will have errors when compiling to the QtWebkit library, so I will skip this library and continue compiling the following ones. library. The error that comes up is:

fileapi/FileReaderLoader.cpp: In member function ‘void WebCore::FileReaderLoader::convertToDataURL()’:
fileapi/FileReaderLoader.cpp:307: error: ‘base64Encode’ was not declared in this scope
make[3]: *** [.obj/debug-static/FileReaderLoader.o] Error 1
make[2]: *** [debug-all] Error 2
make[1]: *** [sub-WebCore-make_default-ordered] Error 2
make: *** [sub-webkit-make_default-ordered] Error 2
I don't know the reason here, I don't understand.

5. Knowing through the Makefile file, there are scripttools and plugins behind Webkit (this is the main purpose), and then use commands to compile each library one by one.

cd src/scripttools;make;cd ../plugins;make;cd ../imports;make;cd ../tools;make;cd ../translations;make;cd ../..
make install
Because it is not necessary, the examples and demos directories are not compiled at the end.

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325747487&siteId=291194637