Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Visual Studio project from scratch

$
0
0

@Jordi wrote:

Usually, it is preferable to clone the empty example or use project generator, but sometimes I wanted to know what are the exact steps to turn a VS C++ project into an OF project.
So here we go:

Visual Studio OF project from scratch

From now on Visual Studio(VS), Openframeworks (OF).

  1. Create a folder to host a set of projects. (optional)
    go to your openframeworks/apps folder.
    mkdir newSetOfProjects

  2. Create Visual Studio project
    File -> new -> project
    Visual C++/Win32 Console Application
    Create Subdirectory must be unchecked
    Name: newProject
    Location: openFrameworks\apps\newSetOfProjects\newProject\
    OK
    next
    check empty project
    finish

  3. Copy "src" folder from empty example:
    In terminal:
    cd newProject
    cp -r ../../../examples/empty/emptyExample/src ./src

  4. Import sources to project.
    Go to VS:
    Delete automatically created filers in project (Headers, Resource files, Source)
    Add new filter "src": Right Click on project, add.../filter-> src
    Add files located at src: Right click on filter src, add, existing items... main, ofApp.h, ofApp.cpp
    At this point trying to compile will throw:

    Error C1083 Cannot open include file: 'ofMain.h': No such file or directory

    This is because this project has no openframeorks yet.
    Close VS.

  5. Import OF project to solution.
    Open newProject.sln in a text editor and add openframeworks project. To do so, add these lines right after "EndProject", and before "Global".

    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}"
    EndProject

    Save and Close.

  6. Link OF project to our project.
    Open newProject.vcxproj in a text editor, and right after:

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

    Add these lines:

    <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksRelease.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksRelease.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksDebug.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksDebug.props" />
      </ImportGroup>

    Then, at the end of the file, after the last:

    </ItemGroup>

    add these:

      <ItemGroup>
        <ProjectReference Include="$(OF_ROOT)\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj">
          <Project>{5837595d-aca9-485c-8e76-729040ce4b0b}</Project>
        </ProjectReference>
      </ItemGroup>

    Save and Close.

  7. Finally, to build and run:
    Open VS
    Right click on NewProject -> Set as Startup Project.
    Press F5 to build and run.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles