1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

QtSharp コンパイル(Windows,2017/05/25)

Last updated at Posted at 2015-10-06

概要

QtSharpはCppSharpを用いて生成されるC#向けQtです。
現在githubで開発されています。
Github

今年の最初にコンパイル方法を紹介しましたが、バージョンアップされていたので
最新版でのコンパイル方法について紹介します。

ちなみに、Qtの不具合によりQtのヘッダファイルを編集する必要があるので、コンパイル自体に興味なければ、公式からコンパイル済みのバイナリをダウンロードしたほうがいいです。

Releases

Qtのインストール、編集

まず、
Qt 5.8.0 for Windows 32-bit (MinGW 5.3)をダウンロードしてインストールします。インストール先を<QtRoot>とします。


Qtの不具合を無理やり修正します。

### qtmultimediadefs.h

[Bug](https://bugreports.qt.io/browse/QTBUG-58432)

修正前

include "../../src/multimedia/qtmultimediadefs.h"


修正後

// #include "../../src/multimedia/qtmultimediadefs.h"


### qopenglversionfunctions.h

[Bug](https://bugreports.qt.io/browse/QTBUG-55951)

修正前

void init()

修正後

void init() {}

## QtSharpの実行

```git clone https://github.com/ddobrev/QtSharp.git```
を実行しQtSharpをクローンします。

QtSharp.slnを開き、QtSharp.CLIを実行します。
実行時の引数に、

\5.8\mingw53_32\bin\qmake.exe \Tools\mingw53_32\bin\mingw32-make.exe

を指定します。

Debugで実行すると、

```QtSharp.CLI\bin\Debug\ ```

に

QtCore.Sharp.dll
QtWidgets.Sharp.dll
QtGui.Sharp.dll

といったQtに対応するファイル、

```QtSharp.CLI\bin\Debug\release\ ```

に

QtCore-inlines.dll
QtWidgets-inlines.dll
QtGui-inlines.dll


といったQtに対応するファイルが生成されます。

## サンプルの実行

```QtSharp.CLI\bin\Debug\ ``` から

QtCore.Sharp.dll
QtWidgets.Sharp.dll
QtGui.Sharp.dll

をコピーします。

```QtSharp.CLI\bin\Debug\release\ ``` から

QtCore-inlines.dll
QtWidgets-inlines.dll
QtGui-inlines.dll


をコピーします。

さらにQtにパスを通してQtのDLLを参照できるように、と言いたいところですが既に他のアプリでQtが使用されており、そちらを参照してしまう可能性があるため、以下のファイルを```<QtRoot>\5.8\mingw53_32\bin\```からコピーします。

libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll

そして以下のファイルを参照に加えます。

QtCore.Sharp.dll
QtWidgets.Sharp.dll
QtGui.Sharp.dll


それ以外のファイルはプロジェクトに追加し、実行ファイルのディレクトリに、常にコピーするようにします。

そして、以下のようなコードを記述するとウインドウが表示されます。

class Program
{
[STAThread]
static void Main(string[] args)
{
unsafe
{
int count = 0;
var qapp = new QtWidgets.QApplication(ref count, null);

		var window = new QtWidgets.QWidget();
		window.Show();

		
		QtGui.QGuiApplication.Exec();
	}
}

}


他のサンプルとして、ここが参考になります。

[QtSharp.TestApps](https://github.com/grbd/QtSharp.TestApps)

初期化部分はここにあるコードが参考になります。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?