删除Netbeans

时间:2018-06-15 21:21:31

标签: c++ netbeans build g++

我目前正在使用Netbeans 8.2,g ++,QT 5.11以及一个名为IBPP的库,用于FireBird服务器上的数据库访问。 我的主要问题是,IBPP程序无法使用unicode字符集构建。当我构建一个普通的C ++应用程序时,这是没有问题的,标准的构建命令是(从控制台复制):

g++    -c -g -I../../IBPP -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp

现在我想在QT项目中使用IBPP,但项目使用以下参数自动构建:

g++ -c -fno-keep-inline-dllexport -g -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -Inbproject -I. -I../../IBPP/ -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/include -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/include/QtWidgets -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/include/QtGui -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/include/QtANGLE -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/include/QtCore -I. -I. -IC:/Qt/Qt5.11.0/5.11.0/mingw53_32/mkspecs/win32-g++  -o build/Debug/MinGW-Windows/main.o main.cpp

正如您所看到的,构建命令具有参数 -DUNICODE 和-D_UNICODE,我猜这些参数是我目前遇到的构建问题的原因。

如何编辑这些标准构建参数,或者如何从运行命令中删除这些特定的两个选项?项目设置菜单中没有选项。

更新:

我想测试的代码非常简约,它只包含库。

#define IBPP_WINDOWS = true
#define IBPP_GCC = true

#include <cstdlib>
#include "core/all_in_one.cpp"

using namespace std;

int main(int argc, char** argv) {

    return 0;
}

当我将这个项目构建为普通的&#34; C ++应用程序&#34;项目,使用第一个运行命令,它工作正常。

但是,当我将其构建为&#34; QT应用程序&#34;使用第二个命令,我从包含的库中得到以下错误:

In file included from ../../IBPP/core/all_in_one.cpp:35:0,
                 from main.cpp:19:
../../IBPP/core/_ibpp.cpp: In member function 'ibpp_internals::GDS* ibpp_internals::GDS::Call()':
../../IBPP/core/_ibpp.cpp:142:39: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
     mHandle = LoadLibrary(path.c_str());
                                       ^
../../IBPP/core/_ibpp.cpp:162:58: error: cannot convert 'char*' to 'LPWSTR {aka wchar_t*}' for argument '2' to 'DWORD GetModuleFileNameW(HINSTANCE, LPWSTR, DWORD)'
    int len = GetModuleFileName(NULL, fbdll, sizeof(fbdll));
                                                          ^
../../IBPP/core/_ibpp.cpp:170:35: error: cannot convert 'char*' to 'LPWSTR {aka wchar_t*}' for argument '1' to 'WCHAR* lstrcatW(LPWSTR, LPCWSTR)'
     lstrcat(fbdll, "\\fbembed.dll");// Local copy could be named fbembed.dll
                                   ^
../../IBPP/core/_ibpp.cpp:171:32: error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
     mHandle = LoadLibrary(fbdll);
                                ^
../../IBPP/core/_ibpp.cpp:175:37: error: cannot convert 'char*' to 'LPWSTR {aka wchar_t*}' for argument '1' to 'WCHAR* lstrcatW(LPWSTR, LPCWSTR)'
      lstrcat(fbdll, "\\fbclient.dll"); // Or possibly renamed fbclient.dll
                                     ^
../../IBPP/core/_ibpp.cpp:176:33: error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
      mHandle = LoadLibrary(fbdll);
                                 ^
../../IBPP/core/_ibpp.cpp:186:30: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)'
     KEY_READ, &hkey_instances) == ERROR_SUCCESS)
                              ^
../../IBPP/core/_ibpp.cpp:192:15: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '2' to 'LONG RegQueryValueExW(HKEY, LPCWSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD)'
        &buflen) == ERROR_SUCCESS && keytype == REG_SZ)
               ^
../../IBPP/core/_ibpp.cpp:194:40: error: cannot convert 'char*' to 'LPWSTR {aka wchar_t*}' for argument '1' to 'WCHAR* lstrcatW(LPWSTR, LPCWSTR)'
      lstrcat(fbdll, "bin\\fbclient.dll");
                                        ^
../../IBPP/core/_ibpp.cpp:195:33: error: cannot convert 'char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
      mHandle = LoadLibrary(fbdll);
                                 ^
../../IBPP/core/_ibpp.cpp:204:40: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
    mHandle = LoadLibrary("fbclient.dll");
                                        ^
../../IBPP/core/_ibpp.cpp:209:38: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'HINSTANCE__* LoadLibraryW(LPCWSTR)'
     mHandle = LoadLibrary("gds32.dll");

我已经读过这些错误可以通过unicode字符集来实现,所以我猜测错误是由第二个运行命令中的两个标志引起的。

谢谢你,祝你有愉快的一天

1 个答案:

答案 0 :(得分:0)

该问题与Windows中使用Unicode有关。在这种情况下,将自动使用函数lstrcatW代替od lstrcatA,该函数用作带有char *参数的ANSI函数。一种可能的解决方案是将源代码修改为A函数,即lstrcatA,LoadLibraryA等。