Author Topic: Static library issue  (Read 4898 times)

Offline lwbbs

  • Single posting newcomer
  • *
  • Posts: 2
Static library issue
« 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.
« Last Edit: May 20, 2011, 10:17:41 am by lwbbs »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Static library issue
« Reply #1 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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline lwbbs

  • Single posting newcomer
  • *
  • Posts: 2
Re: Static library issue
« Reply #2 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Static library issue
« Reply #3 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ