Menu

#1151 Linker problem with selfmade libs

Undefined
invalid
nobody
__imp_Nnnn (1)
Bug_Report
2021-12-16
2021-11-06
Neo Love
No

Hi there,

When linking a project with a self-made library, the linker
is unable to find the relevant "__imp_Nnnn" symbols.

Discovered in C::B 20.03 / MinGW 8.1

I'm unable to determine if this is an error in how Code::Blocks
calls the GCC linker and archiver, or if it's a bug in ld.exe or ar.exe.
The command lines in the build log looks about right, but I notice
any Win32 libs the library depends on is not passed to gcc/g++
or ar when building the library.

How to recreate:

1) In a Win32 GUI project, write a function
that uses a Win32 function, f.ex. GradientFill.
Build and verify that the function is ok.
2) Create a static library project, migrate your function
to the lib, and verify that the lib builds ok.
3) Change your GUI project to use your lib function
instead of the original in-module function.
4) Try to rebuild your GUI app
--> Linker can't find the __imp_Nnnn.

I've put together a little project that demonstrates the bug
so you don't have to go out of your way to recreate it.
You'll find it in "GuiTest/GuiTest.workspace".
To see the bug, uncomment #include <gradrect.h> and rebuild.</gradrect.h>

Best Regards
// Love N

1 Attachments

Discussion

  • Andrew Cottrell

    Andrew Cottrell - 2021-11-07

    Looks like it's not a C::B bug, so it's better to post this in the
    "Using Code::Blocks" forum for help.

     
  • Neo Love

    Neo Love - 2021-11-09

    Hi Andrew,
    Could you please clarify that?
    How else could the linker NOT find symbols that ARE there
    in the linker libraries (proved by the example provided)?
    Did you try building it at all?
    WBR // Love

     
  • Andrew Cottrell

    Andrew Cottrell - 2021-11-09

    Before posting please read the following:
    https://forums.codeblocks.org/index.php/topic,9996.0.html

    It is not a C::B bug, but is how you setup the project and/or library. As such you need to ask for help, not create a bug report that is not a bug with C::B .

    The following forum is where you need to post to request help in using C::B:
    https://forums.codeblocks.org/index.php/board,3.0.html

     

    Last edit: Andrew Cottrell 2021-11-09
  • Miguel Gimenez

    Miguel Gimenez - 2021-12-16
    • status: open --> invalid
     

Log in to post a comment.