Theodore
Theodore

Reputation: 309

FLTK library with Visual Studio Code

I'm trying to install FLTK library for Chapter 12 from Programming Principles and Practice, but the build command is not recognized. What should I do? Thanks!

PS D:\3. Programming\C++\GUI\fltk-1.3.5> make
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path 
was included, verify that the path is correct and try again.
At line:1 char:1
+ make
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Upvotes: 3

Views: 3427

Answers (2)

Eddymage
Eddymage

Reputation: 1137

I usually feel more comfortable with Makefiles, so I set VS Code for using the Makefile within my projects. I have done the following steps after installing FLTK.

  1. I create a directory containing all my source files, headers and so on. Let's say that I have a FLTK_ex folder with hello.cpp and its Makefile

  2. I open VS Code, then File->Open and I select the folder FLTK_ex

  3. From the Terminal menu, I select Configure Default Build Task...: in the menu that appears I select Create tasks.json file from template and then Others

  4. A default json file appears, I modify it as

    {
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "Make",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
    

    }

  5. For compiling, go to Terminal menu and select Run Build Task...

  6. For running the program, in the Run menu select Run without debugging, C++

  7. A launch.json file appears: modify it as (where myprogram is the executable name)

     {
    
     "version": "0.2.0",
     "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/myprogram",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb"
        }
        ]
    }
    
  8. For effectevely run the program, in Run menu select again Run without debugging.

I have FLTK 1.3.5, macOS Catalina 10.15.5, clang version 11.0.3, VS Code 1.47.


In order to use FLTK in VS Code, I just followed the instruction (in Readme.OSX.txt) for simply installing FLTK library, there is a similar file for Windows systems (README.MSWindows.txt).

The guidelines for writing a Makefile for FLTK are here, if you need more insights on Makefiles you can find a complete guide here or a shorter introduction here.


Upvotes: 3

cup
cup

Reputation: 8299

You haven't specified which version of Visual Studio you are using.

  1. Go to the IDE directory, look for your version of visual studio then look for the fltk solution. Start the solution in Visual Studio.
  2. By default, whenever you start an FLTK solution from the distribution, the solution configuration is Debug Cairo. Change this to Debug or Release
  3. Check the startup project - it should be the one called Demo.
  4. Start the build - it should build all the test executables too.

Upvotes: 1

Related Questions