Hashlink hlsdl failed to create window - sdl

I'm trying to run a simple hello world script using the haxe language with hashlink and hlsdl on linux.
I've managed to squeeze out more errors from visual code, not just Failed to create window.
Could not start debugger on port 6112ERROR : TypeError: Cannot read property 'stop' of undefined
Called from /home/enchilada/.vscode/extensions/haxefoundation.haxe-hl-0.8.2/adapter.js line 6925 column 12
Called from /home/enchilada/.vscode/extensions/haxefoundation.haxe-hl-0.8.2/adapter.js line 411 column 12
Called from /home/enchilada/.vscode/extensions/haxefoundation.haxe-hl-0.8.2/adapter.js line 350 column 11
Called from events.js line 200 column 13
Called from internal/child_process.js line 1021 column 16
Called from internal/child_process.js line 430 column 11
Called from events.js line 200 column 13
Called from net.js line 586 column 12
Called from module.exports.loopWhile (/home/enchilada/.vscode/extensions/haxefoundation.haxe-hl-0.8.2/node_modules/deasync/index.js line 71 column 23)
Called from /home/enchilada/.vscode/extensions/haxefoundation.haxe-hl-0.8.2/adapter.js line 13907 column 27
The same errors gets printed with the newest 0.9.0 hashlink debugger version.
When i run it from cmd it prints an error at window.hl.hx line 42 which is the following:
window = new sdl.Window(title, width, height);
At this line with a breakpoint height and width gets replaced with huge random numbers.
Here is my full code which is just the sample from the heaps site:
import hxd.App;
import hxd.res.DefaultFont;
class Main extends App
{
override function init(){
var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
tf.text = "hello";
}
static function main()
{
new Main();
}
}
And here is the compile.hxml I run visual code with:
-lib heaps
-lib hlsdl
-hl hello.hl
-main Main
And the generated launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "HashLink (launch)",
"request": "launch",
"type": "hl",
"hxml": "compile.hxml",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
},
{
"name": "HashLink (attach)",
"request": "attach",
"port": 6112,
"type": "hl",
"hxml": "compile.hxml",
"cwd": "${workspaceFolder}",
"preLaunchTask": {
"type": "haxe",
"args": "active configuration"
}
},
{
"name": "Lime",
"type": "lime",
"request": "launch"
}
]
}

Related

how to get output in terminal when debugging a c++ file?

I am learning debugging C++ file from Udemy .I want to debug a code but I was getting output in external console , so I set external terminal to false . Now I am not getting any output while debugging neither in terminal nor in output option . Please help me I am new to debugging
C++ Code
#include<iostream>
using namespace std;
int main(){
int num{100};
cout<<"Hello from Project 2 "<<endl;
cout<<"Enter a Number : ";
cin>>num;
cout<<"The number you entered : "<<num;
return 0;
}
Launch.json
{
// Use IntelliSense to learn
// about possible attributes.
// Hover to view descriptions
// of existing attributes.
// For more information, visit:
// https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "C:\\Users\\mahir\\OneDrive\\Documents\\C++ debugging Udemy\\project2\\main2.exe",
// There I have got error Property keys must be doublequotedjsonc
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname} ",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}

VSCode <error reading variable> when viewing array elements during debugging

I am debugging the following code in VSCode:
int main() {
char arr1[] = {'t', 'e', 's', 't', '\0'};
char arr2[] = "test";
int arr3[] = {1, 2, 3};
double arr4[] = {1.1, 2.2, 3.3};
}
The elements of the first two arrays show as:
116 '<error reading variable>
101 '<error reading variable>
115 '<error reading variable>
116 '<error reading variable>
0 '<error reading variable>
Whereas the elements of the last two arrays show the actual values of the numbers.
The contents of the launch.json file are:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
What can I do so that the first two arrays show the characters in the array?
The following solution resolved the issue:
I found a workaround in this chinese blog
https://blog.csdn.net/m0_46304383/article/details/113487503
(translated with google transator). It seems a Windows 10 UTF-8
problem. I hope it can also help you #georgetian3.
The workaround is: "Windows Settings" -> "Time and Language" ->
"Region" -> "Other Date -> Time and Regional Settings" -> "Change Date
-> Time or Number Format" -> "Manage" -> "Change System Regional Settings" -> Uncheck "Beta version: Use Unicode UTF-8 to provide
global language support" -> restart the computer

How can I make a target 'makefile' in visual studio code?

I'm trying to figure out how to compile my c++ code within the vs code environment.
I'm able to compile using g++ but I haven't been able to figure it out in vs code yet.
I used the answer from BeeOnRope from this question to set up my build command and the associated hotkey.
How do I set up Visual Studio Code to compile C++ code?
The error that comes out is this
make: *** No rule to make target `Makefile'. Stop.
The terminal process terminated with exit code: 2
Edit: After working on my tasks.json it looks like this, however I'm still getting the same error shown above.
{
"version": "2.0.0",
"command": "make",
"tasks":[
{
"label": "Makefile",
"group": "build",
// Show the output window only if unrecognized errors occur.
"presentation": {"reveal": "always"},
// Pass 'all' as the build target
"args": ["all"],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
In your tasks.json, add/edit the "command" and "args" fields to have the build command line you would run manually. That could be g++, make, or whatever. See here:
https://code.visualstudio.com/docs/editor/tasks
Update:
Looking at the tasks.json file that you posted, your command needs to go inside a task. Something like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "My Build",
"group": "build",
"type": "shell",
"command": "g++",
"args": [
"-o", "LexParse", "Lexxy.cpp", "Parzival.cpp"
]
}
]
}
PS, One way to format your code here is to indent it all:
int main
{
[]( auto world ) { return "Hello"s + world; } ( ", World!" );
}
Another way is to wrap it in three backticks (no need to indent, though I do here so I can have backticks within backticks):
```
int main
{
[]( auto world ) { return "Hello"s + world; } ( ", World!" );
}
```

Visual Studio Code Integrated Terminal not Displaying Text

I'm brand new to MacOS and I am attempting to set up a programming environment, my IDE of choice being Visual Studio Code. When the program runs it, by default, prints in output. However, output crashes when asked to gather input. The online solution the I found for that was to output the code through the terminal, yet now nothing is displayed in the terminal.
I'm posting this here instead of a bug report as I'm unsure whether the fault is mine or the program's.
Here is the simple code I am attempting to run:
#include <iostream>
int main()
{
int i;
std::cout << "Enter a number: ";
std::cin >> i;
std::cout << "\n" << i;
return 0;
}
When run through output, it will display the first part, then crash when input is requested. When run through the terminal, the terminal only displays: "cd "(directory location)" && g++ main.cpp -o main && "(directory location)"main" and nothing else.
Below are my tasks.json and launch.json:
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "c++ test program",
"type": "shell",
"command": "g++",
"args": [
"-g", "main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}
The only setting that has been changed would be "code-runner.runInTerminal" which has been set to true.
This is true when using Code Runner
so the solution is:
use Code Runner and then press Ctrl+, to edit settings then search for
code-runner.runInTerminal and set code-runner.runInTerminal to true, like so:
{
"code-runner.runInTerminal": true
}
this works fine for me.
I hope this helps.

C++ for VS code: Unable to start debugging - Program path is missing or invalid

Unable to start debugging. Program path '/home/student/Documents/Visual Studio Code/rectangle' is missing or invalid.
My launch.json looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/rectangle",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": []
},
{
"name": "C++ Attach (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "${workspaceRoot}/rectangle",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": []
}
]
}
My C++ program is this:
#include <iostream>
using namespace std;
int main()
{
double length, width, area;
cout << "Enter the length: ";
cin >> length;
cout << "Enter the width: ";
cin >> width;
area = length * width;
cout << "The area is " << area << endl;
return 0;
}
Is the "rectangle" file your C++ source code mentioned above?
If so, it should - by convention - be renamed to "rectangle.cpp" and then compiled into a binary/runnable program - which could be named "rectangle".
To my knowledge, you must use a compiler external to VSCODE, but can set up a build task (and a file watcher and a problem matcher if you're feeling advanced) that automates the compile proces.
Are you install Cygwin and minGW at the same time or just install Cygwin?
In any above two case, please make sure that VSCODE call g++ and gdb of minGW, you can just add bin path of minGW and remove bin path of Cygwin from system environment.
Because exe build by Cygwin rely on cygwin1.dll which is not the pure win exe, so gdb can't do with this exe well.