Jump to content

It seems to be hard to start with C++


Recommended Posts

Today I feel good to start learning new thing in Leadwerks, that is C++ with long time bought Professional DLC (I did this before but not successful)

I remember that now Leadwerks 4.4 support VS2017 then I do some simple steps

  1. Create a Blank Project in Leadwerks Editor
  2. Open Projects/Windows/TestBlankProject.sln by VS2017
  3. Goto Build > Build Solution F7

then I get this

image.thumb.png.8e887c6d90efe2a288cd3c0c43fb81f9.png

This is what I found https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2019?f1

But I don't understand anything on that page to find the solution (what a long content)

I just want to start with a simple "Hello world" test for my new thing, but It seems not to be smooth as I expected.. Please help :)

Link to comment
Share on other sites

Not sure how to help with your error but try this and let me know if it works:

Create a new project
Open the SLN file
Remove App.h and App.cpp from the Solution Explorer (under Source and Header Files folders)
Replace the contents of main.cpp with this example:

#include "Leadwerks.h"

using namespace Leadwerks;

int main(int argc, const char *argv[])
{
        Leadwerks::Window* window = Leadwerks::Window::Create();
        Context* context = Context::Create(window);
        
        while (true)
        {
                if (window->Closed() || window->KeyHit(Key::Escape)) break;

                context->SetColor(0.0, 0.0, 1.0);
                context->Clear();

                //Draw some text centered on the screen
                std::string text = "Hello!";

                Font* font = context->GetFont();

                int x = context->GetWidth() / 2;
                int y = context->GetHeight() / 2;

                x -= font->GetTextWidth(text) / 2;
                y -= font->GetHeight() / 2;

                context->SetBlendMode(Blend::Alpha);
                context->SetColor(1.0, 1.0, 1.0);
                context->DrawText(text, x, y);
                context->SetBlendMode(Blend::Solid);

                context->Sync();
        }
        return 0;
}

Right click on your project name in the Solution Explorer tab, click on Properties at the bottom.  The Property Pages window should come up.  Change the Configuration on the top left to All Configurations.

Under Configuration Properties, General, you may have to change Windows SDK Version to 8.1
In the same window, under Debugging, Working Directory remove the two dots at the end so that it just says "$(SolutionDir)\..\..\"  (I hope Josh fixes this eventually)
Click OK.  I then also switch to Release version near the top instead of Debug

Does that run for you and print Hello! on a blue screen or do you get an error still?

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You're almost there!  That's the error you get when Leadwerks can't find the shader because the path is incorrect.  Did you change the folder under Debugging, Working Directory to $(SolutionDir)\..\..\

workingdirectory.jpg.a8889cd5307fbcc30c3dd51f6b236659.jpg

(I forgot to specify Working Directory earlier but it was in the Debugging section.  I edited my other post to clarify.)

The good news is that should be the last thing to set up the project and you only need to do it when you start a new project.  It doesn't take long once you know what you need to do.
 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Honestly it does annoy me in a way aswell.
But have no fear i got a solution for you guys.
The question tipforeveryone had about templates actually made me think about a permanent solution for this.
It involves editing the Common Template though, which can cause problems if/when the Template gets an official update.

Sorry for the windows only answer i have no experience with Linux.

Open folder "Leadwerks/Templates/Common/Projects/Windows".

Open file "$PROJECT_NAME.vcxproj.user" with your favorite text editor (i like notepad++).
Change all instances of "$(SolutionDir)\..\..\.."  to  "$(SolutionDir)\..\..\".

Open file "$PROJECT_NAME.vcxproj" with your favorite text editor.
Change all instances of "$(SolutionDir)..\..\"  to  "$(SolutionDir)\..\..\".

!!_WARNING_!!
Making these changes lets the editor think there has been an update so ALL your projects would need to be updated.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...