私の C++ ソリューションには DLL があります。私の DLL は Octave C++ クラスを使用し、Octave を「組み込み」エンジンとしても使用しています。次の手順 (最初の方法) を使用することで、C++ ソリューションをビルドし、ビルドされた実行可能ファイルを実行して、出力結果をいくつかのテキスト ファイルに問題なく取得できます。
The steps of using Octave Libraries in Visual Studio C++ 2008:
1- Download Octave 3.6.1 for Visual Studio 2008 by the following link.
Notice that there two options for download, one for VS2010 and one for VS2008, you should download the VS2008 option.
http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.1%20for%20Windows%20Microsoft%20Visual%20Studio/
2- Install the Octave 3.6.1 on your system in the following directory (which contains NO white spaces):
C:\Software\Octave-3.6.1
3- While installing, on the installation wizard, select all the available packages of the Octave 3.6.1 to be installed, also select "gnuplot.exe" as graphics engine.
4- After installing Octave 3.6.1, include the Octave 3.6.1 header files in your C++ code like below:
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/config.h>
5- Configure your VS2008:
Add the following directories to "Property Pages > Configuration Properties > C/C++ > General >Additional Include Directories:"
C:\Software\Octave-3.6.1\include
C:\Software\Octave-3.6.1\include\octave-3.6.1
6- Configure your VS2008:
Add the following directories to "Property Pages > Configuration Properties > Linker > General > Additional Library Directories:"
C:\Software\Octave-3.6.1\lib
C:\Software\Octave-3.6.1\lib\octave\3.6.1
7- Configure your VS2008:
Change the "Property pages > Configuration Properties > Linker > General > Enable Incremental Linking" to "No."
8- Configure your VS2008:
Add the following files to "Property Pages > Configuration Properties > Linker > Input > Additional Dependencies:"
octave.lib
octinterp.lib
cruft.lib
9- Configure your VS2008:
Enter the following path to "Property Pages > Configuration Properties > Debugging >
Environment:"
PATH=%PATH%;C:\Software\Octave-3.6.1\bin;
10- Use the following command before loading my DLL:
SetDllDirectory((LPCWSTR)L"C:\\Software\\Octave-3.6.1\\bin\\");
しかし、次の手順 (2 番目の方法) を使用しようとすると、問題が発生します (問題について説明します)。
The steps of using Octave Libraries in Visual Studio C++ 2008:
1- Download Octave 3.6.1 for Visual Studio 2008 by the following link.
Notice that there two options for download, one for VS2010 and one for VS2008, you should download the VS2008 option.
http://sourceforge.net/projects/octave/files/Octave%20Windows%20binaries/Octave%203.6.1%20for%20Windows%20Microsoft%20Visual%20Studio/
2- Install the Octave 3.6.1 on your system in the following directory (which contains NO white spaces):
C:\Software\Octave-3.6.1
3- While installing, on the installation wizard, select all the available packages of the Octave 3.6.1 to be installed, also select "gnuplot.exe" as graphics engine.
4- After installing Octave 3.6.1, copy the folder "Octave-3.6.1" at the address "C:\Software\Octave-3.6.1" next to the solution file of visual studio 2008 project (*.sln) and then include the Octave 3.6.1 header files in your C++ code like below:
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/config.h>
5- Configure your VS2008:
Add the following directories to "Property Pages > Configuration Properties > C/C++ > General >Additional Include Directories:"
..\Octave-3.6.1\include
..\Octave-3.6.1\include\octave-3.6.1
6- Configure your VS2008:
Add the following directories to "Property Pages > Configuration Properties > Linker > General > Additional Library Directories:"
..\Octave-3.6.1\lib
..\Octave-3.6.1\lib\octave\3.6.1
7- Configure your VS2008:
Change the "Property pages > Configuration Properties > Linker > General > Enable Incremental Linking" to "No."
8- Configure your VS2008:
Add the following files to "Property Pages > Configuration Properties > Linker > Input > Additional Dependencies:"
octave.lib
octinterp.lib
cruft.lib
9- Configure your VS2008:
Enter the following path to "Property Pages > Configuration Properties > Debugging > Environment:"
PATH=%PATH%;..\Octave-3.6.1\bin;
10- Use the following command before loading my DLL:
SetDllDirectory((LPCWSTR)L"..\\Octave-3.6.1\\bin\\");
問題は、2番目の方法を使用すると、インストールフォルダーをそのままにしておく限り、完全に機能することC:\Software\Octave-3.6.1
です。つまり、インストール フォルダの名前を変更したり、削除したり、Octave をアンインストールしたりすると、ソリューションは実行可能ファイルをコンパイルしてビルドしますが、実行可能ファイルを実行しても結果は生成されません (結果は一連のテキスト ファイルと出力ファイルは空になります)。どなたか原因と解決策をご存じの方がいらっしゃれば幸いです。ありがとう。