News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

what linker options we must use?

Started by cambalinho, November 11, 2023, 02:00:13 PM

Previous topic - Next topic

cambalinho

heres the Build Log:
"-------------- Clean: Debug in classcontrols (compiler: GNU GCC Compiler)---------------

Cleaned "classcontrols - Debug"

-------------- Build: Debug in classcontrols (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -g  -c C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp -o obj\Debug\main.o
g++.exe  -o bin\Debug\classcontrols.exe obj\Debug\main.o  -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32  -lgdi32 -luser32 -lkernel32 -lcomctl32 "..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libmsimg32.a" "..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libwinmm.a" "..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libgdiplus.a" "..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libgdi32.a" "C:\Program Files (x86)\CodeBlocks\MinGW\i686-w64-mingw32\lib\libbgi.a" -mwindows
In file included from C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp:1:
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h: In static member function 'static LRESULT label::WndProcLabel(HWND, UINT, WPARAM, LPARAM)':
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h:2077:43: warning: comparison of integer expressions of different signedness: 'color' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
                     if (inst->clrBackColor==-1)
                         ~~~~~~~~~~~~~~~~~~^~~~
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h: In member function 'void form::setParent(HWND)':
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h:2949:118: warning: passing NULL to non-pointer argument 1 of 'HWND__* CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)' [-Wconversion-null]
                                   CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, mod, this);
                                                                                                                      ^
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h: In static member function 'static LRESULT form::WndProcForm(HWND, UINT, WPARAM, LPARAM)':
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h:2994:24: warning: unused variable 'KeyDownCount' [-Wunused-variable]
             static int KeyDownCount=0;
                        ^~~~~~~~~~~~
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp: At global scope:
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp:9:14: error: redefinition of 'std::__cxx11::wstring towstring(const string&)'
std::wstring towstring(const std::string& v)
              ^~~~~~~~~
In file included from C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp:1:
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\cambalinho.h:359:14: note: 'std::__cxx11::wstring towstring(const string&)' previously defined here
std::wstring towstring(const std::string& v)
              ^~~~~~~~~
C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp:19:7: error: redefinition of 'class image'
class image
       ^~~~~
In file included from C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp:1:
"
theres much more.. but it's too big :(
i did these project before and i know that it's working.. but maybe, now, the problem is the Linker Options.
what you can advice me?

stahta01

#1
My guess is you are mixing two compiler toolchains together; that can result in weird errors like you got.
Link to how to use code tags https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Edit: The reason I think two tool chains are being used.
C:\Program Files (x86)\CodeBlocks\MinGW\i686-w64-mingw32\lib
"..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libwinmm.a"

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cambalinho

1st warning:
hwnd = CreateWindowEx(NULL, classname, strCaption.c_str(),WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, nullptr, mod, this);


"cambalinho.h|2949|warning: passing NULL to non-pointer argument 1 of 'HWND__* CreateWindowExA(DWORD, LPCSTR, LPCSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID)' [-Wconversion-null]|"

1st error:
std::wstring towstring(const std::string& v)
{
    std::wstring out(v.size()+1,L'\0');

    int size = MultiByteToWideChar(CP_UTF8, 0, v.c_str(), -1, &out[0], out.size());

    out.resize(size-1);
    return out;
}

"main.cpp|9|error: redefinition of 'std::__cxx11::wstring towstring(const string&)'|"

stahta01

Decide which toolchain you wish to use; then only use that one!

Re-read my last post, I edited it.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cambalinho

yes... was on Project Build Options... i change it. thanks for that.
but the same errors\warnings continues

stahta01

#5
Please post the build log with at least the first error and up to three warning above it and post the next two lines down[below the error].
You cutting up the build log makes it impossible to help you!

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cambalinho

heres the log and messages on zip file and the H file.


stahta01

You have to stop using libraries from two different toolchains.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

Is the g++.exe from 64 or 32 bit mingw compiler?

Are you using an 64 bit or 32 bit CB?

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cambalinho


cambalinho

i found some errors that i didn't notice: the image class, for exemple, is redefinided.
i can fix these ;)

stahta01

Please try using this way to do static library usage
$(TARGET_COMPILER_DIR)/i686-w64-mingw32/lib/libmsimg32.a
Instead of doing this way!
"..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libmsimg32.a"

You need to use *only* a single toolchain!!!!

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

stahta01

Quote from: cambalinho on November 11, 2023, 03:03:40 PM
i found some errors that i didn't notice: the image class, for exemple, is redefinided.
i can fix these ;)

Yes, fix those errors and then try my prior post suggestion.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

cambalinho

done!!
now lets go to another error:
a.KeyDown=[](int key, int repeat)
    {
        if(CombinationKeys({'A','S'},{'W'},{'R','T'}, {'O','P'})==true)
        {
            a.Text="hello world";
            MessageBox(NULL,"hi", "hello",MB_OK);
        }

        if(key==VK_ESCAPE)
            End();

    };

'a' it's from 'form' class:
//KeyBoard events:
        event(KeyDown, (int *Key, int repeat)) = [](int *Key, int repeat) {;};

from:
#define event(EventName, ... ) std::function<void(__VA_ARGS__ )> EventName
now i get the error here:
a.KeyDown=[](int key, int repeat)
    {
        if(CombinationKeys({'A','S'},{'W'},{'R','T'}, {'O','P'})==true)
        {
            a.Text="hello world";
            MessageBox(NULL,"hi", "hello",MB_OK);
        }

        if(key==VK_ESCAPE)
            End();

    };

"C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp|73|error: no match for 'operator=' (operand types are 'std::function<void(int*, int)>' and 'WinMain(HINSTANCE, HINSTANCE, LPSTR, int)::<lambda(int, int)>')|"
what i'm doing wrong?

stahta01

Quote from: cambalinho on November 11, 2023, 03:43:36 PM
"C:\Users\Utilizador\Documents\CodeBlocks\classcontrols\main.cpp|73|error: no match for 'operator=' (operand types are 'std::function<void(int*, int)>' and 'WinMain(HINSTANCE, HINSTANCE, LPSTR, int)::<lambda(int, int)>')|"
what i'm doing wrong?

I can not help you with that; I have forgotten more C++ than I remember.

And, that is a C++ type problem, my skill is fixing build issues.

I still have problems with the idea that others can not understand build errors that are simple to me.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]