Skip to main content

SDK not using Visual studio

Answered

Comments

5 comments

  • Official comment
    TDY_Demos
    Community team
    Expert (Gold)

    Hi Emily,

    I am not an expert in VSCode, and just looked at it now, so excuse me if my findings have some gaps.

    I believe this mostly comes down to the tasks and launch json files that you need to create in order to properly build the application.  I had some issue that I worked around, like permission issues in the Program Files folder as well as not being able to include spaces in the library path.

    I first set up initial configuration as mentioned in Configure Visual Studio Code for Microsoft C++.

    Assuming you have installed VSCode and the C++ extensions, I had to do the following with a clean installation of Spinnaker 4.0:

    1.  We compile with the CL compiler, not make, g++, mingw, etc.  You can likely make the others work if you set the parameters properly, but I just worked with CL.

    2.  Due to permission issues with where we install Spinnaker (Program Files folder), and the fact that VSCode can not be run with elevated permissions, I installed or copied Spinnaker into a write friendly area of my PC (my desktop).

    3.  In order to compile, you need to launch VSCode from a Developers Command Prompt.  Assuming you have installed C++ build tools from Visual Studio, you can find this by typing for example "x64 Native Tools Command Prompt for Visual Studio 2022" in your start menu.  Once you open up the prompt, you can browse to your project folder (for example C:\Users\droussin\Desktop\test\Spinnaker\src\Acquisition) and start VSCode with "code ."

    4.  Once VSCode has opened the appropriate folder, you need to make the configuration json files under a .vscode folder.  I can not add attachments to the forum, so below are the files I created.  You will need to change the include and library paths to match where your files are:

    tasks.json:

    {
        "tasks": [
            {
                "type": "cppbuild",
                "label": "C/C++: cl.exe build active file",
                "command": "cl.exe",
                "args": [
                    "/Zi",
                    "-IC:/Program Files/Teledyne/Spinnaker/include",
                    "/EHsc",
                    "/nologo",
                    "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                    "${file}",
                    "/link", "/LIBPATH:${workspaceFolder}\\..\\..\\lib64\\vs2015", "Spinnaker_v140.lib"
                ],
                "options": {
                    "cwd": "${fileDirname}"
                },
                "problemMatcher": [
                    "$msCompile"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "detail": "Task generated by Debugger."
            }
        ],
        "version": "2.0.0"
    }
     
    c_cpp_properties.json:
     
    {
        "configurations": [
            {
                "name": "win32",
                "includePath": [
                    "${workspaceFolder}/**",
                    "C:/Program Files/Teledyne/Spinnaker/include/**"
                ],
                "defines": [
                    "_DEBUG",
                    "UNICODE",
                    "_UNICODE"
                ],
                "windowsSdkVersion": "10.0.19041.0",
                "compilerPath": "cl.exe",
                "cStandard": "c17",
                "cppStandard": "c++14",
                "intelliSenseMode": "windows-msvc-x64"
            }
        ],
        "version": 4
    }
     
    5.  Once the json files are created, I can select the Acqusition.cpp file, and select the debug/run button in the top right of the screen.  This should compile and run the example, which in this case grabs and saves 10 images from the camera.
     
    I believe this can help you compile and run a basic example, which would help ensure you have the right build environment set up.
     
    Troubleshooting:
    - I ran into an architecture mismatch when I was building against 64-bit libraries as I had opened the initial Developer Command Prompt" using the 32-bit shortcut.  Under this, I could build 32-bit projects by pointing my LIBPATH to the lib folder instead of the lib64 folder.
    - There must be a way, but I could not find a way to point LIBPATH to the Program Files folder due to the space in the path.  I added quotes and escape characters, but I could not find a way.  If you find a better method, please let me know.
    - If I tried doing all this just by running VSCode from the start menu, I could not compile as I received a warning that cl.exe could only be run if VSCode is started from Developer Command prompt.  As above, there may be a better way, but I have not used VSCode before so I just documented what I could find that worked.
     
    I hope the above helps you build using VS Code.  The main thing seems to be setting up the correct build files, so the above files should give you a good starting point.  Please help verify if this worked for you so it could help future potential users of the forum if they have similar questions.
     
    Thank you,
    Demos
  • TDY_Demos
    Community team
    Expert (Gold)

    Hello Emily,

    Thank you for the message.  We have not used VSCode for building any of our applications.  I started following some of the Microsoft tutorials that step you through extensions and files required to build existing Visual Studio projects in VS Code, but I have not found a working solution yet.  I think it should be possible, but it seems more about setting up the proper build environment and files.

    Which language are you trying to use?  We can try to document the required steps to build one of our basic examples in VS Code for your language of choice, using one of our basic C, C++, C#, or VB examples that we provide.

    Demos

    0
  • emily123

    Hi! Thanks for the quick response. I've been trying in C++.

    0
  • emily123

    Hey Demos,

    Your tutorial works great! The only modification I needed to make to add the exe file for acquisition to the src acquisition folder and then it worked like a charm. 

    Thank you so much for all the help!

    1
  • TDY_Demos
    Community team
    Expert (Gold)

    Great to hear Emily!  I am glad it worked for you to get started in building with VSCode.

    Demos

    0

Please sign in to leave a comment.

Powered by Zendesk