User forums > General (but related to Code::Blocks)
how to static link a library
poda19:
i want to statically link a library (wxmsw28u.a) to my program so it will not request for wxmsw28u_gcc.dll when i run it on other machines.
i have googled it since yesterday but i found no results. there where two other topics here asking my question too but there where no proper answer to them.
i have added wxmsw28u.a in Linkersettings->Link libraries and have added "-static" to other linker options.
but nothing happens
am i doing something wrong?
i have never linked a library before, is there any other things i should do to statically link a library?
thanks
oBFusCATed:
If you've build the wxwidgets static library correctly you should not have trouble doing it c::b.
Have you read the documentation of wxwidgets about compiling and linking your project to the various versions of wxwidgets?
Keep in mind that wxWidgets is pretty complex library and there are many things you should have in sync (defines on the command line, defines in setup.h, linking options) in order to build, link and run it correctly.
poda19:
OH, please for the sake of GOD
it is two days i am searching whole the internet and asking in forums and no one is going to answer my question. NOWHERE ON THE NET (if you don't beleive me try it. i dare you) i could find a peice of instruction on what the heck is static linking. all they say is "if you want to eliminate the need of dlls use static linking, but it makes the file size bigger." i don't know if static linking is an innate behavior like swallowing that everyone knows how to do or i am such an stupid person.
i'm not a computer student or a professional programmer, and have no access to a teacher or an informed person. just interested in programming and trying to write a junk program that is not useful for anyone on the earth.
so if there is anyone who could mind showing me some source of a little bit of explanation on linking or a tiny example about how do people statically link their libraries, i would be so very very thankful.
i know you have strict rules here on post contents and i'm sorry for my tone but i'm feeling really desperate.
Alpha:
--- Quote from: poda19 on February 08, 2012, 09:56:50 pm ---NOWHERE ON THE NET (if you don't beleive me try it. i dare you) i could find a peice of instruction on what the heck is static linking.
--- End quote ---
Static library
--- Quote from: Wikipedia ---[...] a static library or statically-linked library is a set of routines, external functions and variables which are [...] copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable.
--- End quote ---
--- Quote from: poda19 on February 08, 2012, 10:41:29 am ---i have added wxmsw28u.a in Linkersettings->Link libraries and have added "-static" to other linker options.
--- End quote ---
What is required here, is for you to look under Search directories->Linker, and change the path that should look something like $(#wx.lib)\gcc_dll to $(#wx.lib)\gcc_lib (this is because wxWidgets chooses to have both static and shared libraries use the same name, but located in different directories). Note that this will only work if your computer also contains a static build of wxWidgets (SHARED=0).
poda19:
i have already read wikipedia(and many other sources) . it has just explained how cool is static linking and has a tiny explanation on creating static libraries. not how to link a library to a program.
--- Quote ---NOWHERE ON THE NET (if you don't beleive me try it. i dare you) i could find a peice of instruction
--- End quote ---
i need an INSTRUCTION, but all that is there in the web(including wikipedia) is INTRODUCTION ;)
i tried what you suggested and there is a bunch of "undefined reference to _imp__wx...".
i don't think my libraries have shared=0, i didn't build them. i installed wxPack.
anyway it's 1:50am and i'm convinced that i can't make it. i give up static linking right here right now.
thanks for your reply Alpha
Navigation
[0] Message Index
[#] Next page
Go to full version