Author Topic: hello world for linux in C++  (Read 27308 times)

0 Members and 8 Guests are viewing this topic.

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #25 on: September 12, 2024, 06:44:11 pm »
I think it is necessary to mention:
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: nl
Re: hello world for linux in C++
« Reply #26 on: September 12, 2024, 06:50:37 pm »
I thought Windoze CE was obsolete 15+ years ago, (but I haven't kept up with stuff from microsoft)

For embedded stuff, I'd also much rather donate money to some Linux distribution then pay for each windoze license.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12463
  • Country: us
    • Personal site
Re: hello world for linux in C++
« Reply #27 on: September 12, 2024, 06:53:02 pm »
It is obsolete. The screenshot (what it even supposed to show?) is from 23 year old document. It must be nice to live in the past, but some of us need to be in the present.
Alex
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #28 on: September 12, 2024, 06:58:35 pm »
I don't understand, my screenshot is about outdated software, but this software works like a clock. You are discussing "new products" that are childish attempts to copy this and nothing works properly. What's the point?
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: nl
Re: hello world for linux in C++
« Reply #29 on: September 12, 2024, 07:19:57 pm »
I don't understand, my screenshot is about outdated software, but this software works like a clock. You are discussing "new products" that are childish attempts to copy this and nothing works properly. What's the point?

Maybe you'll find out after you attempt to feed hay to your electric car.

Windoze CE did not even work in windoze itself, have never attempted to use it under Linux. I don't even want to think about what sort of mess that would be.

QT apparently has libraries that work both in regular QT (windows, Linux, maybe the fruit brand too) and for embedded systems. But as far as I know that stuff is not free. They may even be dabbling into android, but as I wrote before, I quit from QT some time ago.
« Last Edit: September 12, 2024, 07:23:30 pm by Doctorandus_P »
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: 00
Re: hello world for linux in C++
« Reply #30 on: September 12, 2024, 07:39:29 pm »
[The most straightforward way to do cross platform graphical applications is Qt, but their licensing and pricing sucks.

Huh? Qt is open source and available under the lgpl license. Even if you want to write closed source software,
you can use Qt for free on the condition that you don't link static with the Qt libraries.
So, what about Qt licensing sucks exactly?
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #31 on: September 12, 2024, 07:42:38 pm »
... Windoze CE did not even work in windoze itself, ...
Everything works, I can post you the documentation, but you won't have time to read it because in the next 5 years you'll be burying your head in QT or some other crap.
And based on your knowledge you will do the same shit that you don't like from others now.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3909
  • Country: it
Re: hello world for linux in C++
« Reply #32 on: September 12, 2024, 08:06:55 pm »
... Windoze CE did not even work in windoze itself, ...
Everything works, I can post you the documentation, but you won't have time to read it because in the next 5 years you'll be burying your head in QT or some other crap.
And based on your knowledge you will do the same shit that you don't like from others now.

Is there new hardware that deploys Windows CE? Or windows 7 while we're at it... I must have missed something!
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #33 on: September 12, 2024, 09:04:22 pm »
.... I must have missed something!
You missed to look at my screenshot above, on the left.
Windows CE API is identical to Windows 98, with some simplification. Almost any project for Windows 98 can be compiled for Windows CE. As for "deploy on new hardware" - you need to compare binary compatibility, since Windows CE exists for the old version of ARM. But if there is no binary compatibility - then, as I already said, you can use a Windows emulator, which will provide the necessary API.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3909
  • Country: it
Re: hello world for linux in C++
« Reply #34 on: September 12, 2024, 09:35:19 pm »
But does new hardware come out with Windows CE? can i put out new hardware with Windows CE?
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #35 on: September 12, 2024, 09:48:06 pm »
But does new hardware come out with Windows CE? can i put out new hardware with Windows CE?
I had a portable translator running Windows CE, and you have no idea what's inside Windows CE - it's not mentioned anywhere. You can release new hardware for anything. Using hardware encryption, you can steal any software and install it on your device.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12463
  • Country: us
    • Personal site
Re: hello world for linux in C++
« Reply #36 on: September 12, 2024, 10:01:23 pm »
This thread turned into some sort of absurd theater.
Alex
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #37 on: September 12, 2024, 10:05:37 pm »
This thread turned into some sort of absurd theater.
This branch is just not for you yet. You will learn over time.

However, I appreciate your experience with Microchip controllers.
« Last Edit: September 12, 2024, 10:21:53 pm by Postal2 »
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 5730
  • Country: Earth
Re: hello world for linux in C++
« Reply #38 on: September 12, 2024, 10:37:09 pm »
Windows CE API is identical to Windows 98, with some simplification. Almost any project for Windows 98 can be compiled for Windows CE.

I just wonder, can you run OpenGL ES app in Windows CE on Raspberry Pi Zero 2w? :)

Bad advise. C and C++ are two very different languages, even though they have a very similar syntax. The thoughts behind oject oriented programming is also quite different.

Why is it bad? Yes, they are different, but C++ is based on C and is more complex for beginners. That's why it's better to start with C, learn procedural programming, and then move on to OOP in C. Having experience with OOP in C provides a good background for learning C++.
« Last Edit: September 12, 2024, 11:00:00 pm by radiolistener »
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #39 on: September 12, 2024, 10:42:38 pm »
...I just wonder, can you run OpenGL ES app in Windows CE on Raspberry Pi Zero 2w? :)
If it were a more powerful device, I would use Wine, create a driver that would forward calls, and everything would work.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 5730
  • Country: Earth
Re: hello world for linux in C++
« Reply #40 on: September 12, 2024, 10:50:27 pm »
If it were a more powerful device, I would use Wine, create a driver that would forward calls, and everything would work.

So it will run on Linux through an additional layer. But what's the point if you can run it directly on Linux and make direct calls?

RPI02W has only 512 MB of RAM, so it's highly undesirable to load any additional code.
« Last Edit: September 12, 2024, 10:54:25 pm by radiolistener »
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #41 on: September 12, 2024, 11:06:07 pm »
So it will run on Linux through an additional layer. But what's the point if you can run it directly on Linux and make direct calls?

RPI02W has only 512 MB of RAM, so it's highly undesirable to load any additional code.
If you are doing something small on a small controller, you will be forced to engage in perversions, this is a classic approach. As for multiplatform applications, I considered the opposite situation - emulation of the Linux graphical environment by Windows. That is, you create a project on Raspberry, and use it on Windows. Or is it better the other way around?
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 5730
  • Country: Earth
Re: hello world for linux in C++
« Reply #42 on: September 12, 2024, 11:19:12 pm »
If you create an X11 app, you can run it on the RPI02W, but it requires starting X11, which will consume all available RAM.

If you implement your app with Windows CE and run it on the RPI02W using Wine, it will consume even more RAM.

However, if you implement it with ImGui and the SDL2 backend, it won't require X11 to run, leaving all the RAM available for your app. Additionally, you can compile and run your ImGui app for Windows CE without needing to change the code, no need for additional drivers and call translators. Isn't that a reason to use ImGui?
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #43 on: September 12, 2024, 11:43:17 pm »
I understand. But I don't understand ImGui. I know how to use MFC, ataradov knows how to use the Turbo Pascal 7.0 shell. And everyone will pull in their own direction and argue. That's normal.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 5302
  • Country: nl
Re: hello world for linux in C++
« Reply #44 on: September 13, 2024, 12:01:22 am »
This thread turned into some sort of absurd theater.
I'm guessing that mad russian is worse then Faringdon.
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 5730
  • Country: Earth
Re: hello world for linux in C++
« Reply #45 on: September 13, 2024, 12:22:39 am »
But I don't understand ImGui.

it's pretty easy, for example here is the code:
Code: [Select]
ImGui::Text("Hello, world %d", 123);
if (ImGui::Button("Save"))
    MySaveFunction();
ImGui::InputText("string", buf, IM_ARRAYSIZE(buf));
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);

You should run this code for every frame and get this result:


It already handle mouse and keyboard, so when you press the button it leads to trigger the condition
Code: [Select]
if (ImGui::Button("Save"))
And the main loop of app looks like this:
Code: [Select]
// Main loop
    bool done = false;
    while (!done)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            ImGui_ImplSDL2_ProcessEvent(&event);
            if (event.type == SDL_QUIT)
                done = true;
            if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
                done = true;
        }

        // Start the Dear ImGui frame
        ImGui_ImplOpenGL2_NewFrame();
        ImGui_ImplSDL2_NewFrame();
        ImGui::NewFrame();

        // here you call your UI code
        // ....

        // Rendering
        ImGui::Render();
        glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
        glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
        SDL_GL_SwapWindow(window);
}

Here is another example of code:
Code: [Select]
// Create a window called "My First Tool", with a menu bar.
ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar);
if (ImGui::BeginMenuBar())
{
    if (ImGui::BeginMenu("File"))
    {
        if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ }
        if (ImGui::MenuItem("Save", "Ctrl+S"))   { /* Do stuff */ }
        if (ImGui::MenuItem("Close", "Ctrl+W"))  { my_tool_active = false; }
        ImGui::EndMenu();
    }
    ImGui::EndMenuBar();
}

// Edit a color stored as 4 floats
ImGui::ColorEdit4("Color", my_color);

// Generate samples and plot them
float samples[100];
for (int n = 0; n < 100; n++)
    samples[n] = sinf(n * 0.2f + ImGui::GetTime() * 1.5f);
ImGui::PlotLines("Samples", samples, 100);

// Display contents in a scrolling region
ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff");
ImGui::BeginChild("Scrolling");
for (int n = 0; n < 50; n++)
    ImGui::Text("%04d: Some text", n);
ImGui::EndChild();
ImGui::End();

and result:
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #46 on: September 13, 2024, 12:40:28 am »
... it's pretty easy, for example here is the code:
Well, yeah, not bad. It's a pure C.

I need to unpack the disk structure now, can ImGui make a treeview?
« Last Edit: September 13, 2024, 01:29:38 am by Postal2 »
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 5730
  • Country: Earth
Re: hello world for linux in C++
« Reply #47 on: September 13, 2024, 03:11:19 am »
I need to unpack the disk structure now, can ImGui make a treeview?

it has imgui_demo.cpp with examples for different widgets.

Just include this file into project and call ImGui::ShowDemoWindow(NULL); to show demo window:




Here is example of a typical ImGui UI app:

« Last Edit: September 13, 2024, 03:23:18 am by radiolistener »
 

Offline Postal2

  • Frequent Contributor
  • **
  • !
  • Posts: 826
  • Country: 00
Re: hello world for linux in C++
« Reply #48 on: September 13, 2024, 04:38:12 am »
Yes, this interface solves the "Hello world" issue for Linux. As for graphics, it can be used instead of MFC. Of course, MFC contains different classes, not only graphics. But I downloaded and looked - this ImGui is really a good thing. Many thanks for the information. I'll try to use it under Windows, it's interesting.
 

Offline djsb

  • Super Contributor
  • ***
  • Posts: 1121
  • Country: gb
Re: hello world for linux in C++
« Reply #49 on: September 13, 2024, 05:31:30 am »
Sorry if this confuses the original poster even more.
I'm a dinosaur and I use BCX BASIC to C convertor (very useful for trying out ideas and algorithms and a wonderful forum) and Free BASIC (same helpful forum for beginners) for playing around with console and Windows GUI prototype code on Windows.
I've not tried coding on Linux. Anything I do on microcontrollers I either use Great Cow basic, Arduino C/C++ or CCS C or XC8 on PIC micro's. I've dabbled with WxWidgets but have only followed one YouTube tutorial.
I just can't get along with C++ at all, even though I keep trying.
For me, it ALL comes down to how I take to any of the tutorials that I try. Anyway, I keep on trying and I suppose that's something.
David
Hertfordshire, UK
University Electronics Technician, London, PIC16/18, CCS PCM C, Arduino UNO, NANO,ESP32, KiCad V10+, Altium Designer 21.4.1, Alibre Design Expert 28 & FreeCAD beginner. LPKF S103,S62 PCB router Operator, Electronics instructor. Credited KiCad French to English translator.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf