ラベル Visual Studio 2012 の投稿を表示しています。 すべての投稿を表示
ラベル Visual Studio 2012 の投稿を表示しています。 すべての投稿を表示

2014年4月5日土曜日

[Visual Studio] 複數版本的Visual Studio共存

Visual Studio 多個版本共存的筆記。

雖然這麼說,不過是VC++的東西。

在C++的開發中,include directory 和 library directory 雖然可以在每個專案中各自設定,

但也可以全域的方式設定。

此篇筆記是在記錄以全域方式設定 include directory 和 library directory,

使所有的專案都可以使用這樣的設定。

在 Visual Studio 中,2010、2012、2013這三個版本的MS Build都沒有改變,

所以基本上這三個版本都是共用這一個 Property sheet 設定。

在預設路徑下, property sheet 可以在下方的路徑中找到

32位元的專案
C:\Users\<user-name>\AppData\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props
64位元的專案
C:\Users\<user-name>\AppData\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props
用來區分VS版本的方法為 Condition 屬性,

直接將 Condition 屬性增加到 IncludePath 和 LibraryPath 下即可。

<?xml version="1.0" encoding="utf-8"?> 

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ImportGroup Label="PropertySheets">
  </ImportGroup>
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup />
  <PropertyGroup>
    <IncludePath>$(IncludePath);C:\opencv248\build\include</IncludePath>
  </PropertyGroup>
  <PropertyGroup>
    <LibraryPath Condition=" '$(VisualStudioVersion)' == '11.0'">$(LibraryPath);C:\opencv248\build\x86\vc11\lib</LibraryPath>
    <LibraryPath Condition=" '$(VisualStudioVersion)' == '12.0'">$(LibraryPath);C:\opencv248\build\x86\vc12\lib</LibraryPath>
  </PropertyGroup>
  <ItemDefinitionGroup />
  <ItemGroup />

</Project>

VisualStudioVersion 10.0 為 VS 2010

VisualStudioVersion 11.0 為 VS 2012

VisualStudioVersion 12.0 為 VS 2013

事實上 Condition 屬性也可以直接加在 PropertyGroup 標籤中。




來源: http://www.rainyman.net/nest/?p=759

2013年12月3日火曜日

[OpenGL] Windows 8.1 64bit 下的 OpenGL 於 Visual Studio 2012 的開發環境配置

跟 windows 7 的配置是一樣的。

這裡下載 glut-3.7.6-bin.zip。

解壓縮後將檔案如下方動作放至各資料夾中。

glut.h → C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\GL

glut.lib → C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib

glut32.dll → C:\Windows\SysWOW64


source file 中加入

#include <GL/gult.h>


應該就可以用了。

-----

另外是 freeglut的配置

這裡下載 freeglut 2.8.1 MSVC Package

配置方法同上方的OpenGL。


=====

troubleshoot

0xc000007b

The application was unable to start correctly (0xc000007b). Click OK to close the application.

檢查配置的 dll 是否正確。

32bit 的應用程式需對應 32bit 的 dll 檔,

64bit 的應用程式需對應 64bit 的 dll 檔。

但從下載來的freeglut中配置時出現錯誤的解法卻是將 32bit 的 dll 放入 64bit 的資料夾。

2013年11月19日火曜日

[OpenCV] Windows 8.1 64bit 下的 OpenCV 2.4.7 用於 Visual Studio 2012 的開發環境配置


OpenCV在2.4.4版開始支援Visual Studio 2012,下面記錄環境配置的步驟。

配置方式有很多種,這邊只用最簡單的方式。

1.  從這裡下載 Windows 版的 OpenCV。

2.  執行 OpenCV-2.4.7.exe,將解壓縮路徑指到 C:\

3.  將 C:\ 下的 opencv 變更名稱為 opencv247

4.  開發專案 x64 --> 在系統環境變數 Path 中增加 C:\opencv247\build\x64\vc11\bin;

    開發專案 win32 --> 在系統環境變數 Path 中增加 C:\opencv247\build\x86\vc11\bin;

5.  開發專案 x64 -->
     在 C:\Users\使用者名\AppData\Local\Microsoft\MSBuild\v4.0\ 資料夾下的 Microsoft.Cpp.x64.user.props 中增加下面的敘述


  <PropertyGroup>
    <IncludePath>$(IncludePath);C:\opencv247\build\include</IncludePath>
  </PropertyGroup>
  <PropertyGroup>
    <LibraryPath>$(LibraryPath);C:\opencv247\build\x64\vc11\lib</LibraryPath>
  </PropertyGroup>

    開發專案 win32 -->
     在 C:\Users\使用者名\AppData\Local\Microsoft\MSBuild\v4.0\ 資料夾下的 Microsoft.Cpp.win32.user.props 中增加下面的敘述


  <PropertyGroup>
    <IncludePath>$(IncludePath);C:\opencv247\build\include</IncludePath>
  </PropertyGroup>
  <PropertyGroup>
    <LibraryPath>$(LibraryPath);C:\opencv247\build\x86\vc11\lib</LibraryPath>
  </PropertyGroup>

加完後,看起來會像下圖一樣



















6. 在 Visual Studio 2012中新增一個C++的空專案加入下面的程式碼做測試

#include <opencv2\opencv.hpp>

#ifdef _DEBUG
#pragma comment(lib,"opencv_imgproc247d.lib")
#pragma comment(lib,"opencv_core247d.lib")
#pragma comment(lib,"opencv_highgui247d.lib")
#pragma comment(lib,"opencv_calib3d247d.lib")
#else
#pragma comment(lib,"opencv_imgproc247.lib")
#pragma comment(lib,"opencv_core247.lib")
#pragma comment(lib,"opencv_highgui247.lib")
#pragma comment(lib,"opencv_calib3d247.lib")
#endif

int main()
{
  cv::Mat img = cv::imread("圖片路徑");
  cv::imshow("test", img);
  cv::waitKey(0);
  return 0;
}


沒意外的話應該這樣就完成了(*・ω・)ノ