Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: lwbbs on May 20, 2011, 10:08:21 am

Title: Static library issue
Post by: lwbbs on May 20, 2011, 10:08:21 am
Hello,

I tried to create a static library. It include a download function which uses wininet functions, such as InternetOpen, etc.
The static library can be compiled without error.

But when I tried to use the static library in other application, MinGW reports some errors when link to the static library:
C:/MinGW/msys/1.0/home/lwbbs/workspace/download.cpp:46: undefined reference to `InternetOpenA@20'

Code::Blocks version: 10.05

Would you please tell me how to fix it?

Thanks.
Title: Re: Static library issue
Post by: oBFusCATed on May 20, 2011, 10:23:07 am
Static libs don't store dependency info in the, thus you have to add the appropriate libraries to the executable/dynamic lib using the static libs.
Title: Re: Static library issue
Post by: lwbbs on May 20, 2011, 10:32:14 am
Thanks for your information.

In my executable project, I have included wininet in the linker setting.
            <Linker>
               <Add library="wininet" />
            </Linker>
The attached file is the setting window.

I don't know why it still reports the error.

Static libs don't store dependency info in the, thus you have to add the appropriate libraries to the executable/dynamic lib using the static libs.
Title: Re: Static library issue
Post by: MortenMacFly on May 20, 2011, 11:21:38 am
I don't know why it still reports the error.
Because the linker still cannot find the reference. Thus the library you added does not provide a feasible implementation for the method (InternetOpenA) you are using. Find the right library.

As this is not a Code::Blocks related question I've locked the topic now, as it violates our forum rules.