Author Topic: what linker options we must use?  (Read 2969 times)

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
what linker options we must use?
« on: November 11, 2023, 02:00:13 pm »
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?

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #1 on: November 11, 2023, 02:19:39 pm »
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.
Code
C:\Program Files (x86)\CodeBlocks\MinGW\i686-w64-mingw32\lib
Code
 "..\..\..\..\..\Program Files\CodeBlocks\mingw32\i686-w64-mingw32\lib\libwinmm.a"

Tim S.
« Last Edit: November 11, 2023, 02:28:32 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #2 on: November 11, 2023, 02:27:07 pm »
1st warning:
Code
 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:
Code
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&)'|"

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #3 on: November 11, 2023, 02:30:24 pm »
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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #4 on: November 11, 2023, 02:33:21 pm »
yes... was on Project Build Options... i change it. thanks for that.
but the same errors\warnings continues

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #5 on: November 11, 2023, 02:38:44 pm »
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.
« Last Edit: November 11, 2023, 02:46:18 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #6 on: November 11, 2023, 02:46:21 pm »
heres the log and messages on zip file and the H file.


Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #7 on: November 11, 2023, 02:53:00 pm »
You have to stop using libraries from two different toolchains.

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

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #8 on: November 11, 2023, 02:55:05 pm »
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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #9 on: November 11, 2023, 02:58:00 pm »
both 32 bits.

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #10 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 ;)

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #11 on: November 11, 2023, 03:04:43 pm »
Please try using this way to do static library usage
Code
$(TARGET_COMPILER_DIR)/i686-w64-mingw32/lib/libmsimg32.a
Instead of doing this way!
Code
"..\..\..\..\..\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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #12 on: November 11, 2023, 03:08:55 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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline cambalinho

  • Multiple posting newcomer
  • *
  • Posts: 93
Re: what linker options we must use?
« Reply #13 on: November 11, 2023, 03:43:36 pm »
done!!
now lets go to another error:
Code
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:
Code
//KeyBoard events:
        event(KeyDown, (int *Key, int repeat)) = [](int *Key, int repeat) {;};
from:
Code
#define event(EventName, ... ) std::function<void(__VA_ARGS__ )> EventName
now i get the error here:
Code
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?

Online stahta01

  • Lives here!
  • ****
  • Posts: 7607
    • My Best Post
Re: what linker options we must use?
« Reply #14 on: November 11, 2023, 03:56:30 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++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org